[Haskell-cafe] Applicative Monoid instance

Brian Hurt bhurt at spnz.org
Mon Sep 5 18:54:20 UTC 2016


This may be a stupid question, but I'm wondering why the following instance
isn't in prelude:

instance (Applicative m, Monoid a) => Monoid (m a) where
    mempty = pure mempty
    mappend a b = mappend <$> a <*> b

?

I ask, because being able to use a WriterT (IO ()) STM a to debug complex
STM expressions would be really nice.  But it depends upon IO () being a
monoid.

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160905/7457ba45/attachment.html>


More information about the Haskell-Cafe mailing list