Hi, On Mon, Jan 19, 2009 at 11:06 AM, Jonathan Cast <[email protected]> wrote: > On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote: >> Hello, >> The multitude of newtypes in the Monoid module are a good indication >> that the Monoid class is not a good fit for the class system > > I would say rather that the class system is not a good fit for Monoid. > Proposals for local instances, multiple instances, instance > import/export control, etc. come up quite frequently on this list; the > phenomena in question are not restricted to Monoid.
I disagree with you but that is a moot point because we are discussing Haskell, which does not have any of these features. Also, I find that in many situations where people want to use them, simpler solutions (like some of the ideas I mentioned in my previous post) suffice. That is not to say that we should stop trying to figure out how to improve the class system, but language changes require a lot more work than improving the design of the libraries. >> I usually >> avoid using the "newtype" trick as I find it inconvenient: usually >> the newtype does not have the same operations as the underlying type >> and so it cannot be used directly, and if you are going to wrap thing >> just when you use the class methods, > > OTOH, I think you mean here `when you use class methods and when you use > overloaded functions'. Sure, the point is that you are essentially adding a type annotation, which is like using a non-overloaded function. Compare, for example: "mappend add x y" and "getSum (mappend (Sum x) (Sum y))". I think that the first one is quite a bit more readable but, of course, this is somewhat subjective. -Iavor _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
