
2009/10/8 Cristiano Paris
On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson
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))
I think it is the same thing that my (\f -> f f True) question, i.e. the polymorphism of k is fixed inside foo (you don't want that). So I guess using the rank-2 types and the corresponding type annotation to keep k polymorph should work. In other words, foo is polymorph on k but k is not polymorph when given to foo in a specific application. Thu