On 26/09/2006, at 12:19 AM, Christian Sievers wrote:

Bernie Pope answered:

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 4.4.3.2 that the first can be translated into the second.

Indeed, I meant to allude to this translation.

A simple pattern binding is one where the lhs is a variable only.

That's consistent with the second reason for rule one of the MR.

However, the mentioned section 4.4.3.2 defines it differently:

   A simple pattern binding has form p = e.

And if there is any doubt about what p stands for, it goes on:

   The pattern p ...

Contrasting to that:

The general form of a pattern binding is p match, where a match is the same structure as for function bindings above; in other words, a pattern binding
   is:

   p    | g1    = e1
        | g2    = e2
        ...
        | gm    = em
        where { decls }


So according to this definition, a pattern binding is simple iff
there are no guards (unless they are in the expression).
Also the translation to a "simple pattern binding" only gets rid of guards.

So there seems to be an error in the report, which can be fixed by either redefining "simple pattern binding", or using a differnet description in the
MR.

Aha,

Christian I see what you mean. It seems I did not read section 4.4.3.2 carefully. In fact
I think I was interpreting that section in light of the MR.

So I am now as puzzled as you are.

Anyway, thanks for persisting on this point.

Cheers,
Bernie.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to