|
|
|
|
|
by rawatson
5307 days ago
|
|
Haskell uses type inference, but that's not the same as implicit coercion, which Haskell explicitly avoids. That is: if you type
4 + 4.2 Then the compiler will infer that you mean
(4::Fractional a=>a) + (4.2::Fractional a => a) However, you cannot add an integer and a float:
(4::Int) + (4.2::Float) Couldn't match expected type `Int' with actual type `Float'
In the second argument of `(+)', namely `(4.2 :: Float)'
In the expression: (4 :: Int) + (4.2 :: Float)
In an equation for `it': it = (4 :: Int) + (4.2 :: Float)
This follows from the type of (+) :: Num a => a -> a -> a |
|