The monomorphism restriction and monomorphic pattern bindings

Sittampalam, Ganesh ganesh.sittampalam at
Fri Apr 25 03:46:30 EDT 2008

Simon Peyton Jones wrote:

> 3. I'm more concerned about the programmer than the implementation.  
> Consider
>        (f,g) = (negate, show)
> What type do you expect 'f' to have?  A straightforward answer might
>        f :: (Num a, Show b) => a -> a
> If you don't want that, you need to explain a more complicated typing 
> rule for pattern bindings.    I'll ask the same about
>        (f,g) = (reverse, length)
> A simple and consistent story is that all the pattern bound variables 
> are generalised over all the class constraints and all the type 
> variables of the RHS.  But I bet that is not what you want.

I think this is reasonable. In general, something of type (Num a, Show
b) => (a -> a, b -> String), might have an occurrence of b hidden inside
a -> a. I
wouldn't expect specific expressions of this type to be given special 



Please access the attached hyperlink for an important electronic communications disclaimer:

More information about the Haskell-prime mailing list