incorrect MonadPlus law "v >> mzero = mzero"?

wren ng thornton winterkoninkje at gmail.com
Thu Feb 6 03:05:29 UTC 2014


On Wed, Feb 5, 2014 at 9:32 PM, wren ng thornton
<winterkoninkje at gmail.com> wrote:
> I still think the above laws are the most sensible ones. I discuss a
> bit about why I believe that in this blog post I just posted[1]. The
> only alternative I see is to drop every law about how mplus interacts
> with bind, which isn't a solution quite so much as giving up.
>
> [1] <http://winterkoninkje.dreamwidth.org/90905.html>

I had commented in that post about how the generalization of the
distributivity law could possibly lead to problems, but didn't really
explore it. I just now posted an addendum showing that (for
Maybe/MaybeT) it is indeed the generalization itself which causes the
problems; and that, if we use the *exact* distributivity law from
seminearrings[2] rather than the generalized version, then the problem
goes away (for Maybe). I still submit that this is the right law to
have, following the same overall justification as before. The
generalized law is nice, but I wouldn't be too sad about using the
non-generalized law instead.

Any IO/STM examples which break the non-generalized law?


[2] That is,

    mzero >>= f  =  mzero  -- this one is still generalized

    (x `mplus` y) >> z  =  (x >> z) `mplus` (y >> z)  -- no longer generalized

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

    x `mplus` mzero  =  x

    mzero `mplus` y  =  y

-- 
Live well,
~wren


More information about the Libraries mailing list