[Haskell-cafe] generic filter through MonadPlus
sebf at informatik.uni-kiel.de
Fri May 22 11:01:49 EDT 2009
On May 22, 2009, at 4:13 AM, Jason Dusek wrote:
> I'd like to know what folks think about the use of `MonadPlus` in
> this case.
The |guard| function is almost |filter|:
> import Control.Monad ( MonadPlus, guard )
> filter :: MonadPlus m => (a -> Bool) -> m a -> m a
> filter p m = do a <- m
> guard (p a)
> return a
Underestimating the novelty of the future is a time-honored tradition.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 163 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090522/7d184c1b/PGP.bin
More information about the Haskell-Cafe