[Haskell-cafe] MPTCs and rigid variables

Simon Peyton-Jones simonpj at microsoft.com
Tue Mar 6 15:32:29 EST 2007


| > 4.  The "rigid type variable" thing isn't just an implementation question.  What *would* you like the
| error message to say when you write
| >        f :: ([a], Int) -> Int
| >        f (x:xs, y) = x+y
| > Here we unify 'a' with Int, which is wrong.  What would a nicer error message say?
|
| "Inferred type was monomorphic but a polymorphic type was given", or
| something. Hugs says "Inferred type not as polymorphic as expected",
| which is the right kind of area.

Hmm.  But at the moment the type error happens, we are indeed unifying 'a' with Int, and I think it's helpful to say so.  What Hugs does (I think) is to infer the most general type of the untyped fn, and compare with the signature. But in general that gives worse error messages; and when you have higher-rank types you can't ignore the type sig and do inference first.

I'm not against adding "type is too monomorphic" or something like that if you think it'd help, but I'd like to say something about the incompatibility of 'a' and 'Int'.  No?

Smon


More information about the Haskell-Cafe mailing list