Since we're talking about monads, it's not clear that generalizing the left-seminearring laws makes any sense. There's an inherent directional bias to (>>=) which gets in the way of this generalization. But if we're not generalizing the distributivity laws, then Maybe forms a right-seminearring just fine.
Is this what you had in mind: ma >>= (\a -> f a `mplus` g a) = (ma >>= f) `mplus` (ma >>= g)? If so, then this is definitely going to break for IO etc. Just consider ma = print "blah" >> mzero; one side of the proposed equation only prints once, whereas the other prints twice. So even if that happens to work out for Maybe, it's not really a solution to what MonadPlus should mean.
no subject
Date: 2014-02-06 09:59 pm (UTC)From:(>>=)
which gets in the way of this generalization. But if we're not generalizing the distributivity laws, thenMaybe
forms a right-seminearring just fine.Is this what you had in mind:
ma >>= (\a -> f a `mplus` g a) = (ma >>= f) `mplus` (ma >>= g)
? If so, then this is definitely going to break forIO
etc. Just considerma = print "blah" >> mzero
; one side of the proposed equation only prints once, whereas the other prints twice. So even if that happens to work out forMaybe
, it's not really a solution to whatMonadPlus
should mean.