[Haskell-cafe] MonadPlus

Bryan O'Sullivan bos at serpentine.com
Fri May 9 16:12:08 EDT 2008


Andrew Coppin wrote:

> ...so it's a kind of choice operator? Run all actions until you get to
> one that succeeds and return the result from that?

In the context of Parsec, yes.  In the grander scheme of things, the
behaviour depends on whatever is appropriate for the particular monad
you're working in.

So, for example, mplus for lists is (++) and mzero is [], which is quite
a different set of behaviours from the Parsec case.  Usually, you can
rely on MonadPlus behaving like a monoid.  There are occasional
exceptions, which is a mite upsetting.

http://www.haskell.org/haskellwiki/MonadPlus

	<b


More information about the Haskell-Cafe mailing list