[Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of numeric constants)

Christian Sievers sievers at math2.nat.tu-bs.de
Mon Sep 25 10:19:04 EDT 2006

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 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 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
   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

Christian Sievers

More information about the Haskell-Cafe mailing list