
11 Jan
2009
11 Jan
'09
6:13 a.m.
Wolfgang Jeltsch wrote:
Hello,
I wonder why there isn’t a MonadPlus instance for ContT. In my opinion, this one would be natural:
instance (MonadPlus monad) => MonadPlus (ContT result monad) where
mzero = ContT $ return mzero
ContT cont1 `mplus` ContT cont2 = ContT $ liftM2 mplus cont1 cont2
return and liftM2 are the ones of (->) (o -> monad result).
What do you think?
As long as it satisfies the MonadPlus rules. All of these: mplus mzero a = a mplus a mzero = a mplus (mplus a b) c = mplus a (mplus b c) mzero >>= k = mzero and one of these: mplus a b >>= k = mplus (a >>= k) (b >>= k) mplus (return a) b = return a -- Ashley Yakeley