[Haskell-cafe] Fwd: incorrect MonadPlus law "v >> mzero = mzero"?

John Lato jwlato at gmail.com
Mon Feb 3 23:10:47 UTC 2014

On Mon, Feb 3, 2014 at 3:00 PM, Brandon Allbery <allbery.b at gmail.com> wrote:

> On Mon, Feb 3, 2014 at 5:51 PM, Dan Burton <danburton.email at gmail.com>wrote:
>> Indeed this issue is not limited merely to multiple failure values.
>>     >>> runMaybeT $ lift (putStrLn "effect") >> mzero
>>     effect
>>     >>> runMaybeT mzero
>> So you're right. This law is being violated
> I thought it was fairly well known that IO violates one of the monad laws,
> in a way that would lead to this?

The choice of IO for the underlying monad is irrelevant.  The issue is that
a later mzero in the transformer cannot undo an earlier action in a lower
monad.  For example:

>>> Prelude Control.Monad.Maybe Control.Monad.State> runStateT (runMaybeT $ (lift $ put "bar") >> mzero) "foo"
>>> Prelude Control.Monad.Maybe Control.Monad.State> runStateT (runMaybeT mzero) "foo"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140203/58127aec/attachment.html>

More information about the Haskell-Cafe mailing list