[Haskell-cafe] Comments from OCaml Hacker Brian Hurt

David Menendez dave at zednenem.com
Thu Jan 15 17:43:08 EST 2009


On Thu, Jan 15, 2009 at 5:27 PM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> 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
> documentation.

I assume these are all documented where the type is defined? One
disadvantage of Monoid compared to Monad is that you really need to
explain what operation your Monoid instance performs.

For example, the documentation for Maybe describes what its Monad
instance does, but not its Monoid instance.

I don't think any of the instances for [] are documented. (Admittedly,
this is difficult, since [] is not actually exported from anywhere.)

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list