[Haskell-cafe] Re: [Haskell] Nested guards?

Neil Mitchell ndmitchell at gmail.com
Tue Dec 4 15:46:09 EST 2007


> server text
>    | Just xs <- parse text = let
>      x | "field1" `elem` xs   = error "... do one thing ..."
>        | "field2" `elem` xs   = error "... do something else ..."
>      in x
> server  _ = error "... invalid request ..."

This now has the wrong semantics - before if parse text returned Just
[] the error invalid request branch was invoked, now its a pattern
match failure.

I haven't used pattern guards that much (but will once Haskell'
standardises them, or they get implemented in Hugs!), but their syntax
seems quite natural. This extension seems to make it harder to
understand them, and gives some nasty , | parsing issues for a human
at least - quite possibly for a compiler too. Perhaps if you gave a
little grammar for extended pattern guards (compared to the original)
it would be easier to see how naturally they fit in.



More information about the Haskell-Cafe mailing list