<br><br><br><div class="gmail_quote">On Mon, Jul 26, 2010 at 11:55 AM, John Lato <span dir="ltr"><<a href="mailto:jwlato@gmail.com">jwlato@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
I was wondering today, is this generally true?<br>
<br>
instance (Monad m, Monoid a) => Monoid (m a) where<br>
mempty = return mempty<br>
mappend = liftM2 mappend<br>
<br></blockquote><div><br>Yes.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I know it isn't a good idea to use this instance, but assuming that<br>
the instance head does what I mean, is it valid? Or more generally is<br>
it true for applicative functors as well? I think it works for a few<br>
tricky monads, but that's not any sort of proof. I don't even know<br>
how to express what would need to be proven here.<br></blockquote><div><br>There are multiple potential monoids that you may be interested in here.<br>
<br>
There is the monoid formed by MonadPlus, there is the monoid formed by
wrapping a monad (or applicative) around a monoid, which usually forms
part of a right seminearring because of the left-distributive law, there
are also potentially other monoids for particular monads.<br>
<br>
See the monad module in my monoids package:<br>
<br>
<a href="http://hackage.haskell.org/packages/archive/monoids/0.2.0.2/doc/html/Data-Monoid-Monad.html">http://hackage.haskell.org/packages/archive/monoids/0.2.0.2/doc/html/Data-Monoid-Monad.html</a><br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Any resources for how I could develop a means to reason about this<br>
sort of property?<br></blockquote><div><br>The types are not enough.<br><br>What you need is the associativity of Kleisli arrow composition and the two identity laws. <br><br>The three monad laws are precisely what you need to form this monoid. There are analogous laws for Applicative that serve the same purpose.<br>
<br>-Edward Kmett<br></div></div>