
On 21.01.2011, at 11:52, Daryoush Mehrtash wrote:
Do I have to have MonadPlus m or would any other Monad class work the same way?
Not all monad instances satisfy undefined >>= return . Just = undefined if that's what you are asking for. For example, consider the identity monad. instance Monad Identity where return = Identity m >>= k = k (runIdentity m) Then we have undefined >>= return . Just = undefined >>= Identity . Just = Identity (Just undefined) /= undefined If >>= performs pattern matching on its first argument like most instances do then you get undefined >>= return . Just = undefined. I think that the monadplus laws mplus m n >>= f = mplus (m >>= f) (n >>= f) called (Ldistr) in the paper and mzero >>= f = mzero called (Lzero) in the paper imply undefined >>= return . Just = undefined At least if you have mzero /= mplus m n which is quite desirable. I don't think that this holds for continuation based monads. But Sebastian will most certainly know better as he is one of the authors of the paper. Cheers, Jan