
In Wed, Jul 1, 2009 at 3:38 PM, Thomas Schilling
2009/7/1 David Leimbach
Just because the compiler can figure out what I mean because it has a great type system, I might not be able to figure out what I mean a year from now if I see ++ everywhere.
Yep, had the same experience. On the one hand, using monoids lets you delay some design decisions for later and lets you reuse more library code. On the other hand, it sometimes makes it really hard to see what the code is actually doing--especially if you use more than one monoid.
For this reason on of the first advanced features I implemented in the (yet unreleased) scion IDE library allows you to look up the instantiated type of an identifier. Unfortunately, jumping to the definition (or documentation) of the monoid instance is a bit more difficult. Haddock should allow documentation on instance declarations...
I disagree. The solution is to not create instances when it isn't
obvious what the instance does. That's why we have Sum and Prod in
Data.Monoid instead of declaring instances directly for Int.
With Monoid, I'd go further and say that you should not use mempty and
mappend unless you are writing polymorphic code. If you are writing to
a specific monoid instance, you should use a specific function.
--
Dave Menendez