[Haskell-cafe] Fwd: incorrect MonadPlus law "v >> mzero = mzero"?
Petr Pudlák
petr.mvd at gmail.com
Tue Feb 4 08:32:19 UTC 2014
I would argue that a monad transformer "cannot undo earlier action in a
lower monad." For example, in the case of MaybeT: In order to determine of
an action succeeded or failed, it needs to evaluate in the underlying
monad. But what if the underlying monad doesn't provide any means to
restore its state to some previous point? So I believe having 'v >> mzero =
mzero' for a transformer with MonadPlus would be only possible if the
underlying monad provided some kind of check-pointing.
2014-02-04 Dan Burton <danburton.email at gmail.com>:
> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140204/30fde7b1/attachment.html>
More information about the Haskell-Cafe
mailing list