Since the function (+) has a signature:
(+) :: Num a => a -> a -> a
Thus, this means that the (+) function requires that the operands be of the same type , and the result is of the same type as the operands.
Your signature will mean that the programmer can select any type of Num as the first operand, and any type of Num as the second operand, and then build any type. Therefore, this would mean that I could specialize the function in sum :: Int -> Float -> Char , but this (+) does not exist.
We can make the type more flexible, for example, using fromIntegral :: (Integral a, Num b) => a -> b :
integralSum :: (Integral i, Integral j, Num c) => i -> j -> c integralSum xy = fromIntegral x + fromIntegral y
source share