[Haskell-cafe] Documentation [Comments from OCaml Hacker Brian Hurt]

Dan Piponi dpiponi at gmail.com
Fri Jan 16 19:23:59 EST 2009

On Fri, Jan 16, 2009 at 12:09 PM, Paul Moore <p.f.moore at gmail.com> wrote:

> How about "associativity means that how you pair up the operations
> does not affect the result"?

I think a better way is this: If you have an element of a monoid, a,
there are two ways to combine it with another element, on the left or
on the right. You get

a `mappend` x
x `mappend` a.

Now suppose you're going to combine a with x on the left and y on the
right. Associativity means it doesn't matter which you do first.

You can think of each element of a monoid as having two sides. The
idea is that the left side and right side are independent things that
don't interfere with each other. For example, adding some stuff at the
beginning of a list, and adding some stuff at the end of a list, don't
affect each other, and it doesn't matter which you do first.

That's the idea that associativity captures.

More information about the Haskell-Cafe mailing list