« Return to Thread: MonadPlus

Re: MonadPlus

by Bryan O'Sullivan :: Rate this Message:

Reply to Author | View in Thread

Andrew Coppin wrote:
> But here's a
> question: what is the purpose of the MonadPlus class?

It gives you a way of working with monads as monoids.  Consider a Parsec
example:

metasyntactic = text "foo" `mplus` text "bar" `mplus` text "baz"

You'll get back whichever one matched, in left-to-right-order, or mzero
(a parse failure) if all of them fail.

        <b
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: MonadPlus