[Haskell-cafe] Comments from OCaml Hacker Brian Hurt

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Fri Jan 16 08:20:31 EST 2009


On Thu, 2009-01-15 at 18:41 -0500, Cale Gibbard wrote:
> 2009/1/15 Andrew Coppin <andrewcoppin at btinternet.com>:
> > 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 can't speak from the perspective of the Cabal developers, but
> combining configurations with partial information using a monoid
> operation is generally a good way to structure things. Basically, this
> would be analogous to the way that the First monoid (or the Last
> monoid) works, but across a number of fields. You have an empty or
> default configuration which specifies nothing that serves as the
> identity, and then a way of layering choices together, which is the
> monoid operation.

Exactly. Some fields are the Last monoid (we call it Flag) and some are
the list monoid. Whole sets of such settings are monoids point-wise.

It is indeed great for combining/overriding setting from defaults,
config files and the command line.

Duncan



More information about the Haskell-Cafe mailing list