[Haskell-cafe] Another monad question...
Miguel Mitrofanov
miguelimo38 at yandex.ru
Sun Jul 15 03:25:17 EDT 2007
DL> Ah! So here's another quick question: if mzero is the identity
DL> element, why isn't it part of the Monad class? Correct me if I'm
DL> wrong but aren't Monads (in the mathematical sense) required an
DL> identity element by definition?
Yes, they do. And this identity element is called "return" in
Haskell, not "mzero".
Consider, for example, the monad (_,M), which maps each object X to
the product of X and M, with M being some chosen monoid. In this case,
"return" is a map from X to (X,M), and return(a) = (a,e), where e is
the identity element of M.
In fact, this monad is called "Writer" in Haskell.
More information about the Haskell-Cafe
mailing list