On Wed, Feb 5, 2014 at 5:01 PM, wren ng thornton <winterkoninkje@gmail.com> wrote:
On Wed, Feb 5, 2014 at 7:59 PM, wren ng thornton
<winterkoninkje@gmail.com> wrote:
> The rules I'd expect MonadPlus to obey are:
>
>     mzero >>= f    =    mzero
>
>     (x `mplus` y) >> mzero    =    (x >> mzero) `mplus` (y >> mzero)

Er, sorry, that should've been:

    (x `mplus` y) >> z    =    (x >> z) `mplus` (y >> z)

from which the above instance follows trivially.

I don't think this is correct. consider the original instance with x /= mzero.  Then we have

left side
(x `mplus` y) >> mzero
x >> mzero                   -- by def. of mplus

right side
(x >> mzero) `mplus` (y >> mzero)
mzero'x `mplus` (y >> mzero)           -- mzero'x is a zero with x's effects, this reduction comes from the monad laws
(y >> mzero)                                   -- by mplus

Or concretely,

> let x = lift (print "x!") :: MaybeT IO ()
> let y = lift (print "y!") :: MaybeT IO ()
> runMaybeT $ (x `mplus` y) >> mzero
"x!"
Nothing
> runMaybeT $ (x >> mzero) `mplus` (y >> mzero)
"x!"
"y!"
Nothing
John