[Haskell-cafe] Comments from OCaml Hacker Brian Hurt
jeremy at n-heptane.com
Fri Jan 16 10:13:33 EST 2009
Personally, I would like to see the laws more explicitly listed. Some
-- The Monoid Laws:
-- 1. Associative:
-- x `mappend` (y `mappend` z) == (x `mappend` y) `mappend` z
-- 2. Left Identity:
-- mempty `mappend` y == y
-- 3. Right identity:
-- x `mappend` mempty == x
(Actually, what I'd really like to see is the laws provided as
QuickCheck properties. I know there is a project doing this already.)
At Fri, 16 Jan 2009 13:39:10 +0000,
Duncan Coutts wrote:
> On Fri, 2009-01-16 at 14:16 +0100, david48 wrote:
> > Upon reading this thread, I asked myself : what's a monoid ? I had no
> > idea. I read some posts, then google "haskell monoid".
> > The first link leads me to Data.Monoid which starts with
> > <<
> > Description
> > The Monoid class with various general-purpose instances.
> > Inspired by the paper /Functional Programming with Overloading and
> > Higher-Order Polymorphism/, Mark P Jones
> > (http://citeseer.ist.psu.edu/jones95functional.html) Advanced School
> > of Functional Programming, 1995.
> > >>
> Ross just updated the documentation for the Monoid module. Here is how
> it reads now:
> The module header now reads simply:
> A class for monoids (types with an associative binary operation
> that has an identity) with various general-purpose instances.
> Note, no links to papers.
> And the Monoid class has:
> The class of monoids (types with an associative binary operation
> that has an identity). The method names refer to the monoid of
> lists, but there are many other instances.
> Minimal complete definition: 'mempty' and 'mappend'.
> Some types can be viewed as a monoid in more than one way, e.g.
> both addition and multiplication on numbers. In such cases we
> often define @newtype at s and make those instances of 'Monoid',
> e.g. 'Sum' and 'Product'.
> If you or anyone else has further concrete suggestions / improvements
> then post them here now! :-)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe