oops (was: Re: if-then-else inside a "do")

Kevin Glynn keving@cs.mu.OZ.AU
Wed, 30 Jan 2002 17:16:57 +1100


I think the Haskell Wiki was going to be the place to collect
interesting code fragments.

However,  I must add that these functions are already part of the
Haskell 98 standard.  See the Monad module in the Library Report.

cheers
k



Mark Carroll writes:
 > On Wed, 30 Jan 2002, Bernard James POPE wrote:
 > (snip)
 > > when             :: (Monad m) => Bool -> m () -> m ()
 > > when p s          = if p then s else return ()
 > >
 > > unless           :: (Monad m) => Bool -> m () -> m ()
 > > unless p s        = when (not p) s
 > (snip)
 > 
 > That's cute. People post all sorts of handy little code fragments here.
 > Does anyone collect them together into a sort of "here's some useful stuff
 > that's worth looking at" library?
 > 
 > -- Mark
 > 
 > 
 > _______________________________________________
 > Haskell-Cafe mailing list
 > Haskell-Cafe@haskell.org
 > http://www.haskell.org/mailman/listinfo/haskell-cafe
 >