[Haskell-cafe] Comments from OCaml Hacker Brian Hurt
Jeremy Shaw
jeremy at n-heptane.com
Thu Jan 22 12:32:26 EST 2009
Hello,
Just some minor suggestions and comments:
The description might read better as two sentences:
A class for monoids with various general-purpose instances. Monoids
are types with an associative binary operation that has an
identity.
One thing that I think is a bit unclear from that description is the
fact that it does not matter *what* the binary operation does, as long
as the laws are followed. That is the whole point of the monoid class
-- you use it when you only care about the laws, not the specific
operation...
For the laws, it would be nice to label each rule, something like
* mappend mempty x = x -- Left Identity
* mappend x empty = x -- Right Identity
* mappend x (mappend y z) = mappend (mappend x y) z -- Associative
* mconcat = foldr mappend mempty -- Not sure what to call this. Perhaps it an axiom?
See the Applicative class for a formatting example:
http://www.haskell.org/ghc/dist/current/docs/libraries/base/Control-Applicative.html
As an expert, seeing the name is faster than reverse engineering the
meaning of each law. I also suspect many people have never heard of
the concept of an identity element (I am pretty sure I hadn't when I
first started Haskell). So, I think it would be nice to tie together
the concepts mentioned in the description with the actual laws so that
the link is explicit.
j.
At Sun, 18 Jan 2009 13:57:07 +0000,
Duncan Coutts wrote:
>
> On Sat, 2009-01-17 at 13:36 -0800, David Leimbach wrote:
> >
> >
> > On Sat, Jan 17, 2009 at 9:16 AM, david48 <dav.vire+haskell at gmail.com>
> > wrote:
> > On Sat, Jan 17, 2009 at 4:08 PM, David Leimbach
> > <leimy2k at gmail.com> wrote:
> >
> > > So you're saying it should be better documented in Haskell
> > what a Monoid is.
> > > Did you say you searched for "C++ class" why not "Haskell
> > Monoid" then?
> > > The first correct google hit that didn't think I meant
> > Monads, takes you
> > > straight to the GHC documentation for Data.Monoid.
> >
> > Read my first post on the thread, that's exactly what I did
> > ( and then
> > complained that the doc for Data.Monoid was close to useless )
> >
> >
> > Sorry missed it! This is an exceptionally long thread! :-) I agree
> > Data.Monoid's docs don't give you much to work with.
>
> Do you think they look better now:
>
> http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Monoid.html
>
> Any other improvements you'd make?
>
> Duncan
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list