On Sun, Jul 15, 2007 at 12:03:06AM -0400, David LaPalomento wrote:
> On 7/14/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote:
>> Your base case is subtly wrong - it should be return [], not mzero.
>> Mzero always fails - mzero `mplus` x = x, by one of the MonadPlus laws.
>
>
> Ah!  So here's another quick question: if mzero is the identity element, why
> isn't it part of the Monad class?  Correct me if I'm wrong but aren't Monads
> (in the mathematical sense) required an identity element by definition?

You're probably confusing Monads with Monoids.

Monoid:
  * Concept from abstract algebra
  * A set Ty, a distinguished element mempty :: Ty, and a binary operator
    mappend :: Ty -> Ty -> Ty
  * mempty `mappend` x = x
  * x `mappend` mempty = x
  * a `mappend` (b `mappend` c) = (a `mappend` b) `mappend` c

Monad:
  * Concept from category theory
  * A category C (assumed to be Haskell objects in the type class)
  * A functor F :: C -> C
  * Two natural transformations η :: F^0 -> F^1, μ :: F^2 -> F^1
  * the monad laws

MonadPlus:
  * Monads that are also monoids
  * mappend, mempty named mplus, mzero to avoid conflicts
  * (OK it was the other way around, monadplus came first)

I've heard that Monads are in some way like Monoids, hence the name.
But I don't understand the explanation yet myself :(

Stefan

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to