The dreaded M-R
simonmar at microsoft.com
Fri Jan 27 06:02:39 EST 2006
On 27 January 2006 10:54, Simon Peyton-Jones wrote:
>>> How about an even simpler solution:
>>> *All* pattern and variable bindings are monomorphic unless a type
>>> signature is given.
>> Now that IS an interesting idea. The more I think about it, the more
>> I like it.
> I like it too. But be aware that a top-level definition
> reverse = foldr (\x ys -> ys ++ [x]) 
> would get the inferred type
> [()] -> [()]
> because it'd be monomorphic, and completely un constrained type
> variables are defaulted to (), in GHC at least.
This only becomes an issue if the binder is exported, because defaulting
doesn't happen until the complete module has been typechecked. So in
that case, probably the least surprising behaviour is for it to be an
static error to export a binding with unresolved type variables, after
defaulting has been applied.
incedentally, that's the type you get in GHCi
More information about the Haskell-prime