[Haskell-cafe] mtl: Why there is "Monoid w" constraint in the definition of class MonadWriter?

Edward Z. Yang ezyang at MIT.EDU
Sat Dec 8 23:18:38 CET 2012


Excerpts from Roman Cheplyaka's message of Sat Dec 08 14:00:52 -0800 2012:
> * Edward Z. Yang <ezyang at MIT.EDU> [2012-12-08 11:19:01-0800]
> > The monoid instance is necessary to ensure adherence to the monad laws.
> 
> This doesn't make any sense to me. Are you sure you're talking about the
> MonadWriter class and not about the Writer monad?

Well, I assume the rules for Writer generalize for MonadWriter, no?

Here's an example.  Haskell monads have the associativity law:

    (f >=> g) >=> h === f >=> (g >=> h)



More information about the Haskell-Cafe mailing list