[Haskell-cafe] Comments from OCaml Hacker Brian Hurt

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Jan 15 17:27:29 EST 2009

On Thu, 2009-01-15 at 21:21 +0000, Andrew Coppin wrote:

> OK, well then my next question would be "in what say is defining 
> configuration files as a monoid superior to, uh, not defining them as a 
> monoid?" What does it allow you to do that you couldn't otherwise? I'm 
> not seeing any obvious advantage, but you presumably did this for a 
> reason...

[ I know I'm repeating myself from elsewhere in this thread but this is
the better question for the answer :-) ]

By making a type an instance of Monoid instead of exporting
emptyFoo, joinFoo functions it makes the API clearer because it shows
that we are re-using an existing familiar concept rather than inventing
a new one. It also means the user already knows that joinFoo must be
associative and have unit emptyFoo without having to read the

Perhaps it's what OO programmers would call a design pattern. Identify a
pattern, give it a name and then when the pattern crops up again (and
again) then the reader of the code will have an easier time because they
are already familiar with that named pattern.

Of course the fact that we can occasionally use the pattern to
parametrise and write more re-usable code is a bonus.


More information about the Haskell-Cafe mailing list