On 09/03/2008 04:00 AM, David Roundy wrote: > > I generally dislike qualified imports, and think that this is a bad > precedent that Data.ByteString has set. When you find that you want to use > precisely the same names in several modules, you probably should define a > type class. It's unfortunate that the Prelude stomps on all the best > names, but I don't think qualified imports are a reasonable substitute for > what ought to be type classes. > >
This is not directed specifically to David but to anyone who has any thoughts on the idea of using type classes much more in order to avoid qualified imports. I'm curious if this could work or not. ---- If I understand you correctly, you're saying that there should be a type class for things that support `first` and a type class for things that support `last` and `size` and `depth` and `empty` and `new` and `compress` and `factor` and `merge` and thousands of other functions that are common (or else we have to disambiguate by making longer, less convenient names like newList, emptyList, newParser, etc.). In principle, I agree that everything that supports a `first` function that returns a first something according to some ordering should be an instance of the same type class. The type class captures the intuition that we have regarding a `first` function and the purpose it serves, and of course there are functions that we might like to define that require only that the argument supports `first` and not that it is a list or a queue or a tree, etc. In practice though, I think this would be a disaster due to the thousands of new type classes that we would all have to keep track of if we actually did this, almost all of which would just have one method. Is there some way to use type classes a lot more to capture the idea that all `first` functions are related without it being prohibitively difficult (to keep track of all the classes) and inconvenient (due to the additional contexts that would be required for many, many functions)? If not, is this a limitation or can anyone make an argument that it's a feature and not a bug? Cheers, joseph _______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
