Are pattern guards obsolete?

Neil Mitchell ndmitchell at gmail.com
Wed Dec 13 15:21:02 EST 2006


Hi

> in spite of their similarity, all of these constructs handle some of the
> monadic aspects differently. the translations of pattern guards not only
> embed statements in "guard", they also embed the right hand sides of
> generators in "return". translations of list comprehensions only lift
> statements. translation of do-notation lifts neither statements nor
> generators.
>
> does this clarify things?

No. Pattern guards are "obvious", they could only work in one
particular way, and they do work that way. They make common things
easier, and increase abstraction. If your only argument against them
requires category theory, then I'd say that's a pretty solid reason
for them going in.

The argument that people seem to be making is that they are confusing,
I completely disagree.

f value | Just match <- lookup value list = g match

Without thinking too hard, I am curious how anyone could get the
meaning of this wrong if they understand the rest of Haskell. Can you
show a concrete example, where you think a user would get confused?

Thanks

Neil


More information about the Haskell-prime mailing list