[Haskell-cafe] monoids and monads
jwlato at gmail.com
Tue Jul 27 05:49:29 EDT 2010
On Mon, Jul 26, 2010 at 5:02 PM, Edward Kmett <ekmett at gmail.com> wrote:
> On Mon, Jul 26, 2010 at 11:55 AM, John Lato <jwlato at gmail.com> wrote:
>> I was wondering today, is this generally true?
>> instance (Monad m, Monoid a) => Monoid (m a) where
>> mempty = return mempty
>> mappend = liftM2 mappend
> There are multiple potential monoids that you may be interested in here.
> 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.
> See the monad module in my monoids package:
I think your monoids package has grown since I last looked at it.
I'll take a look.
>> Any resources for how I could develop a means to reason about this
>> sort of property?
> The types are not enough.
> What you need is the associativity of Kleisli arrow composition and the two
> identity laws.
> The three monad laws are precisely what you need to form this monoid. There
> are analogous laws for Applicative that serve the same purpose.
Thanks very much. With this and Henning's hints, I think I can make
some progress with this now.
More information about the Haskell-Cafe