[Haskell-cafe] Re: Guards

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Mon Jan 10 04:55:51 EST 2005


On Sat, 8 Jan 2005, Lemming wrote:

> Jon Cast wrote:
> 
> > Absolutely.  In Haskell's syntax, if-then-else-if interacts badly with
> > do notation, and Haskell lacks a direct analogy to Lisp's cond.
> > 
> > case () of
> >   () | p1 -> e1
> >      | p2 -> e2
> >      ...
> 
> No problem:
> 
> select :: a -> [(Bool, a)] -> a
> select def = maybe def snd . List.find fst

Alternatively:
 select def = fromMaybe def . lookup True



More information about the Haskell-Cafe mailing list