
15 Jul
2007
15 Jul
'07
3:25 a.m.
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.