Hi,

in order to understand the reason for strange compiler error messages, I often find it convenient to add type signatures to every function. But sometimes this seems to be impossible when using type variables.

I try to give a very easy example:

add :: Num a => a -> a -> a
add n1 n2 = addToN1 n2
   where addToN1 :: Num a => a -> a
         addToN1 number = n1 + number

ghc says "Inferred type is less polymorphic than expected", and justly so, because the type variable "a" in addToN1 must of course be the same as in add. Is there a way to specify this?

Regards,
Chris

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to