[Haskell-cafe] type inference question

Cristiano Paris frodo at theshire.org
Thu Oct 8 11:14:20 EDT 2009


On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson
<lennart at augustsson.net> wrote:
> The reason a gets a single type is the monomorphism restriction (read
> the report).
> Using NoMonomorphismRestriction your example with a works fine.

Could you explain why, under NoMonomorphismRestriction, this typechecks:

let a = 1 in (a + (1 :: Int),a + (1 :: Float))

while this not:

foo :: Num a => a -> (Int,Float)
foo k = (k + (1 :: Int), k + (1.0 :: Float))

Thanks!

Cristiano


More information about the Haskell-Cafe mailing list