[Haskell-cafe] MonadPlus

Nicolas Frisby nicolas.frisby at gmail.com
Fri May 9 16:24:40 EDT 2008


It sounds like the semantics of the MonadPlus methods are
under-specified. I recall once writing a newtype wrapper to treat the
same non-determinism monad with different mplus semantics, akin to cut
versus backtracking.

I think of MonadPlus as a less expressive version of msplit, from

  Backtracking, Interleaving, and Terminating Monad Transformers
  The Functional Pearl paper by Oleg Kiselyov, Chung-chieh Shan,
Daniel P. Friedman and Amr Sabry. ICFP 2005.

Is that an over-simplification?

On Fri, May 9, 2008 at 3:12 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list