I believe that these are the relevant laws of class MonadPlus:

  m >>= (\x -> mzero) = mzero
  mzero >>= m         = mzero

  m `mplus` mzero = m
  mzero `mplus` m = m

You can get some intuition for this by thinking of mplus as +, mzero as 0, and >>= as multiplication.

I haven't follow much at all of this thread, but, for what it's worth, IO should NOT be instance of MonadPlus, because it has no zero element. For if it did, the IO action:

  putStr "hello" >> mzero

would not print "hello", which is counterintuitive, and in practice I wouldn't know how to implement it.

-Paul

P.S. All of the above is in my book :-)


Jules Bean wrote:
So, anyone? What are the laws that MonadPlus is supposed to satisfy?

The obvious ones are that if MonadPlus m then for all types a, (m a) should be a monoid. But, what about the others, because IO does not appear to satisfy

a >> mzero == mzero

Jules


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to