Prelude> let f x = x * 2Thanks!
Prelude> :t f
f :: Num a => a -> a
The typeclass Num is defined like this:
class Num a where
(+), (-), (*) :: a -> a -> a
...
...which means that the operator (*) expects two parameters of type a and returns a value of type a.
Since the definition of expr looks like this:
Prelude> let f x = x * 2
...and 2 is an Int, I would expect that the type inferred for (*) is (Int -> Int -> Int) and thus f should be (Int -> Int)
Can somebody explain this?