On Fri, 2008-05-09 at 12:48 -0700, Bryan O'Sullivan wrote: > Andrew Coppin wrote: > > But here's a > > question: what is the purpose of the MonadPlus class? > > It gives you a way of working with monads as monoids.
I find this description mostly useless. Monads form monoids without being MonadPlus. instance Monad m => Monoid (m ()) where mempty = return () mappend = (<<) You can form monoids out of Kleisli arrows, instance Monad m => Monoid (a -> m a) where mempty = return mappend = (<=<) You could form monads into a monoid in another way, instance (Monad m, Monoid a) => Monoid (m a) mempty = return mempty mappend = liftM2 mappend So "It gives you a way of working with monads as monoids." is significantly underspecified and doesn't actually say what MonadPlus means, let alone what it is intended for. A more interesting statement in that vein is: It gives you a way of working with monads as (distributive) near-rigs. This statement does actually encode some (all?) of the intended meaning of MonadPlus, e.g. mzero is intended to be a zero of (>>) beyond simply being a unit for mplus. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe