
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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe