
Jorge Adriano Aires wrote:
On the list monad, I think of the mplus operation as the "union" two non-deterministic states. Mzero is the state that works as the identity (which is when you have no possible state at all).
Okay... thats a definition of a monoid.
What would happen if this was the definition?
instance MonadPlus [] where mzero = [] mplus a b
| a == [] = b | otherwise = a
Isn't the above a monoid as well?
a `mplus` [] = a [] `mplus` b = b Still looks like an identity to me.... Is there only on correct definition of a monad/monoid on lists - or does anything that satisfies the monad laws count? I got the impression you could define anthing you liked for mzero and mplus - providing the laws are upheld?
Then, I'd say you're not thinking of monadic sums, but of catching errors, and the appropriate place for that is the class MonadError.
I am thinking about how some monads are summed - like Maybe and the Parser monad. It seems there are two possibilities - either the definitions of MonadPlus for Maybe and Parser monads are in Error, or there can be two different acceptable definitions of MonadPlus on the List? Keean