I'm studying Haskell, and I do not understand why this code does not compile:
foo :: Int -> Double -> Double
foo a b = a+b
The error message is:
Couldn't match expected type 'Double' with actual type 'Int'
In the first argument of '(+)', namely 'a'
In the expression: a + b
In an equation for 'foo': foo a b = a + b
I know that the '+' operator is a function with the parameters
(+) :: (Num a) => a -> a -> a
but Int and Double types are Num instances
So, why does not the compiler accept this code ??
Thank you!