[Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of
bjpop at csse.unimelb.edu.au
Sat Sep 23 08:28:15 EDT 2006
On 23/09/2006, at 4:33 AM, Christian Sievers wrote:
> I don't take my advice to go to haskell-cafe :-)
I will take your advice :)
> The discussion continued outside the mailing list, and now I have
> two questions myself:
> 1. Why do the rules of the monomorphism restriction explicitly mention
> *simple* pattern bindings?
> Where is the difference, especially as there is a translation to
> simple pattern bindings?
> Why should
> p | "a"=="b" = 2
> | otherwise = 3
> be treated different than
> p = if "a"=="b" then 2 else 3
They are the same (both are simple pattern bindings). The report says
in section 220.127.116.11 that the first can be translated into the second.
A simple pattern binding is one where the lhs is a variable only.
If a pattern binding is not simple, it must have a data constructor
on the lhs, therefore it cannot be overloaded. So the (dreaded) MR only
applies to simple pattern bindings.
More information about the Haskell-Cafe