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

Holger Siegel holgersiegel74 at yahoo.de
Sun Dec 9 00:51:10 CET 2012


Am 09.12.2012 um 00:27 schrieb Holger Siegel:
> For deriving a monoid instance of w from monad  (Writer w), you will need
> function execWriter:: Writer w a -> w, but in case of a general instance of
> (MonadWriter w m) you would have to use function listen :: m a -> m (a, w)
> that will only provide you a value of type (m w), but not of type w.

sorry, I meant function execWriterT :: Monad m => WriterT w m a -> m w.

> Therefore,
> I'm not yet convinced that every instance of (MonadWriter w m) gives rise
> to a monoid instance of w.



More information about the Haskell-Cafe mailing list