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

Dan Burton danburton.email at gmail.com
Mon Feb 3 23:21:41 UTC 2014


>
> The issue is that a later mzero in the transformer cannot undo an earlier
> action in a lower monad.


Precisely. Another example, for fun:

>>> print (runMaybeT $ lift [1,2,3] >> mzero :: [Maybe Int])
[Nothing, Nothing, Nothing]

>>> print (runMaybeT mzero :: [Maybe Int])
[Nothing]

Actually, I'd say the problem *isn't *that a transformer "cannot undo
earlier action in a lower monad." I'd just say that most transformers *happen
to be implemented *in this "forgetful" manner. It's conceivable that we
could implement some of them differently, in a way that would obey the
MonadPlus laws. Whether or not obedience to this particular law is
worthwhile... well, that's debatable.

-- Dan Burton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140203/61cecec9/attachment.html>


More information about the Haskell-Cafe mailing list