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

Mark Carroll mark@chaos.x-philes.com
Wed, 30 Jan 2002 00:19:34 -0500 (EST)


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