[Haskell-cafe] Fwd: incorrect MonadPlus law "v >> mzero = mzero"?

Dan Burton danburton.email at gmail.com
Mon Feb 3 23:04:06 UTC 2014


>
> I'm not sure what should be the proper solution. Perhaps to change the
> laws to:
>   return x >> mzero  =  mzero
>   (v >> mzero) >>= f  =  (v >> mzero)`
> That is, if an expression ends with `mzero`, it behaves like `mzero`.


These laws are redundant with existing laws. The first:

    return x >> z = z

Is true forall x and z, and can be proven by just the monad laws. The
second:

    (v >> mzero) >>= f  =  (v >> mzero)

Can be proven by the associativity of monadic operations:

    (v >> mzero) >>= f  =  v >> (mzero >>= f)

And the other MonadPlus law already states that (mzero >>= f) = mzero. So I
don't think any new laws are needed. I just think the (v >> mzero = mzero)
law should be removed, or else a *lot* of instances of MonadPlus need to
come with a disclaimer that they are not law-abiding.

-- Dan Burton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140203/d0dfdc87/attachment.html>


More information about the Haskell-Cafe mailing list