[Haskell-cafe] What is MonadPlus good for?

Josef Svenningsson josef.svenningsson at gmail.com
Tue Feb 15 07:23:58 EST 2005


On Mon, 14 Feb 2005 19:01:53 -0500, ajb at spamcop.net <ajb at spamcop.net> wrote:
> I was thinking more along the lines of Ralf Hinze's nondeterminism
> transformer monad:
> 
>     http://haskell.org/hawiki/NonDeterminism
> 
> The relevant instance is this:
> 
>     instance (Monad m) => MonadPlus (NondetT m)
> 
> That is, if m is a Monad, then NondetT m is a MonadPlus.  This is not
> true if a requirement for MonadPlus is that it include the "mzero is a
> right zero for bind" law.  Indeed, such a transformer is impossible to
> write if that law is a requirement.
> 
Ah, I see. You are quite right.

> > You claimed that monad transformers break the
> > mzero-is-right-identity-for-bind law because they can be applied to
> > IO. I say, it's not the monad transformers fault. They cannot possibly
> > be expected to repair the law if they are given a faulty monad.
> 
> IO is not a faulty monad.  It satisfies all of the laws that a monad is
> supposed to satisfy.
> 
Sloppy terminology on my side again. What I meant to say is that any
MonadPlus instance of IO is faulty if we insist on the
mzero-is-right-identity-for-bind law. I agree with you that the law
should be dropped.

Cheers,

/Josef


More information about the Haskell-Cafe mailing list