[Haskell-cafe] Problem with type signature in local function
Christian Hofer
Christian.Hofer at gmx.de
Fri Dec 24 06:38:05 EST 2004
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
More information about the Haskell-Cafe
mailing list