
15 Jan
2009
15 Jan
'09
5:32 p.m.
Duncan Coutts wrote:
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 don't know about you, but rather than knowing that joinFoo is associative, I'd be *far* more interested in finding out what it actually _does_. Knowing that it's a monoid doesn't really tell me anything useful. A monoid can be almost anything. As an aside, the integers form two different monoids. Haskell can't [easily] handle that. Does anybody know of a language that can?