Pattern guards

Yitzchak Gale gale at
Mon Oct 2 18:35:15 EDT 2006

> The need for supplemental condition testing and
> splitting the pattern matching among the where
> clause and the boolean guards is considered
> very cumbersome by some.

Yes, it is. But that was only an artificial construction,
meant to work in general. I wouldn't do it that way
really. When an individual problem is reformulated
in the correct monad, the entire program becomes
much simpler.

> the (<-) notation isn't overloaded at all really, any
> more than it is in list comprehensions. <- always
> means monadic bind. it is fully general in 'do'.
> restricted to the list monad in list comprehensions,
> and restricted to something like the exit monad you
> mention in pattern guards. They are all consistent
> uses of (<-).

No, they are not the same. Bind in a list comprehension
translates to the exact same bind in do notation.
I cannot think of any translation of pattern guards for
which the same thing is true. For example, in my
construction, pat <- e translates to pat <- return (e).
That is a very significant semantic difference.


More information about the Haskell-prime mailing list