[Haskell] Nested guards?

Iavor Diatchki iavor.diatchki at gmail.com
Tue Dec 4 14:41:37 EST 2007


Hi,
Lately I have been using pattern guards more than usual and I find
that occasionally I need to nest them (i.e., I have alternatives with
a common prefix).  This seems to happen when I need to do some
preliminary checking, followed by some decision making.  Here is an
example:

server text
   | Just xs <- parse text
   ,   | "field1" `elem` xs   = ... do one thing ...
       | "field2" `elem` xs   = ... do something else ...

server  _ = ... invalid request ...

As far as I can see this should be a fairly simple change to the
pattern bindings extension.   Would anyone else find this a useful
feature, and if so what syntax should we use?

-Iavor


More information about the Haskell mailing list