Data.Monoid

Cale Gibbard cgibbard at gmail.com
Wed Sep 14 06:31:01 EDT 2005


On 14/09/05, Johannes Waldmann <waldmann at imn.htwk-leipzig.de> wrote:
> Forgive me but the names  mempty, mappend, runEndo  look horrible.
> See http://www.haskell.org//pipermail/haskell/2005-August/016323.html
> --
> -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
> ---- http://www.imn.htwk-leipzig.de/~waldmann/ -------
> 

Well, I agree that appEndo is better, since it really is just wrapped
function application. If you don't like the abbreviation, that would
become applyEndofunction. I think it's reasonably obvious from the
type what it does anyway. It ought to have a short name since infix
application is likely.

The names mempty and mappend are not too bad, even if they're a little
unconventional. The analogy with the list monoid is clear enough.
"unit" or "identity" and "times" or "multiply" would also work. I
personally don't really see the need to change the names, they're
reasonably descriptive, and it was obvious what they referred to the
first time I saw them.

By the way, Data.Set should perhaps be made an instance of Monoid in
the obvious way.

 - Cale


More information about the Libraries mailing list