Re: oops (was: Re: if-then-else inside a "do")
On Wed, 30 Jan 2002, Kevin Glynn wrote: > 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. Ah, cool, both points sound good. Thanks. (-: -- Mark (still figuring out the wiki) ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: oops (was: Re: if-then-else inside a "do")
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 > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: oops (was: Re: if-then-else inside a "do")
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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
oops (was: Re: if-then-else inside a "do")
Oops, Thanks to Kevin who pointed out: 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 > So now I tend to use: > >doIf :: Monad a => Bool -> [a b] -> a () >doIf b e = if b then sequence_ e else return () Bernie. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe