[Haskell-cafe] Re: how do you deal with mplus?

Jonathan Cast jonathanccast at fastmail.fm
Thu Oct 9 14:15:03 EDT 2008


On Thu, 2008-10-09 at 20:20 +0200, apfelmus wrote:
> Daryoush Mehrtash wrote:
> > Assuming A, B, C are monadic operation.   How do you read the following
> > function:
> > 
> >     do
> >         A 'mplus'  B
> >         C
> > 
> > I expect this to translate to:
> > 
> > (A 'mplus' B) >>= C
> 
> It translates to
> 
>    (A `mplus` B) >> C
> 
> > Can I then say it is equivalent to:
> > 
> >   (A >>=C)  mplus (B >>=C)
> 
> Sounds like a desirable law, but it doesn't always hold.

It holds for a couple of interesting monads, though.  In particular, it
holds for [] and for back-tracking or parallel parsers.

>  See also
> 
>   http://www.haskell.org/haskellwiki/MonadPlus
> 
> Currently, there's no consensus concerning the laws that MonadPlus
> should obey.

jcc




More information about the Haskell-Cafe mailing list