[Haskell] Nested guards?

Roberto Zunino zunino at di.unipi.it
Tue Dec 4 15:23:33 EST 2007


Iavor Diatchki wrote:
> server text
>    | Just xs <- parse text
>    ,   | "field1" `elem` xs   = ... do one thing ...
>        | "field2" `elem` xs   = ... do something else ...
> 
> server  _ = ... invalid request ...

What about:

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

Regards,
Zun.


More information about the Haskell mailing list