[Haskell-cafe] MonadPlus
Andrew Coppin
andrewcoppin at btinternet.com
Fri May 9 15:56:03 EDT 2008
Bryan O'Sullivan wrote:
> 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.
>
...so it's a kind of choice operator? Run all actions until you get to
one that succeeds and return the result from that?
More information about the Haskell-Cafe
mailing list