
3 Feb
2014
3 Feb
'14
6:21 p.m.
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