[Haskell-cafe] Is ListT a valid MonadPlus?

Richard Wallace rwallace at thewallacepack.net
Thu Feb 9 07:46:19 CET 2012

It appears to me that the MonadPlus instance for ListT breaks the
following MonadPlus law

    m >> mzero   =  mzero

I've tried with every implementation of ListT I could find - the one
in mtl, transformers, List, even "ListT done right" and it's
alternative.  They all seem to violate the above law.  Following is a
ghci session that shows this with the mtl impl.

Prelude> import Control.Monad.List
Prelude Control.Monad.List> let nt = ListT Nothing :: ListT Maybe Int
Prelude Control.Monad.List> let e = mzero :: ListT Maybe Int

Prelude Control.Monad.List> runListT nt
Prelude Control.Monad.List> runListT e
Just []
Prelude Control.Monad.List> runListT $ nt >> e

According to the MonadPlus law above, that last line should evaluate
to `Just []`.

So is ListT a valid MonadPlus?  Or am I missing something?  If not,
can a valid MonadPlus instance for ListT be written?  I've tried a few
things and come up short.


More information about the Haskell-Cafe mailing list