
(sorry to mess up mail threading, but I couldn't properly reply to the message the way I'm using email right now--broken mail clients)
Recently, however, there has been some interest in using named instance declarations in other ways, so perhaps we will see features like this creeping into future versions of the language.
In what kinds of ways? Sounds interesting.
[Of course, there is a way of naming instance declarations with the current Haskell syntax, although it is a little verbose, and would require more work on the implementers part than simple matching of strings. The syntax I'm thinking of would look something like the following:
module M(C(..), instance C Int, instance C a => C [a]) where ...
This is the sort of thing I was thinking too. But I would probably want to extend that to classes and types. For instance module M (class Eq a=>C a (...), type A, instance C A, instance C a => C [a]) where ... If I am not mistaken, this would allow separation of the type namespace from the typeclass namespace, and would make it obvious whether the thing being exported is a type or a class. It could also potentially allow the context(s) for class and instance declarations to be more restrictive in the header or in imports than in the module body. The latter could perhaps allow resolution of overlapping instances at import time, by restricting the instances to the point of non-overlap. I'm not sure that the former would actually be useful. Hmmm.... speaking of overlapping instances... Would there be a practical way to add negation (of classes and possibly even types) to the context syntax? This would let you say instance (Integral a) => C (T a) where ... instance (not Integral a, Real a) => C (T a) where ... instance (not Num a) => C (T a) where ... .... It would also seem nice to be able to say instance (Integral a, not a Int) => C a where .... and instance C Int where ..... but this seems even more questionable.

Hi David, | >Recently, however, there has been some interest in using named instance | >declarations in other ways, so perhaps we will see features like this | >creeping into future versions of the language. | | In what kinds of ways? Sounds interesting. I was thinking of a couple of papers from the most recent Haskell workshop. See http://www.cs.uu.nl/people/ralf/hw2001.html for some pointers (the second session). | > module M(C(..), instance C Int, instance C a => C [a]) where ... | | This is the sort of thing I was thinking too. But I would probably want | to extend that to classes and types. For instance | | module M (class Eq a=>C a (...), type A, instance C A, instance C a => C | [a]) | where ... Yes, that's also what I had in mind at the more verbose end of the spectrum (which is not to say that I think it would be a bad thing). A richer, more explicit syntax for export lists might provide some useful documentation and be easier to read than a syntax that leaves you guessing whether C(..) refers to a type or a class. On the other hand, if things start to get too wordy, you might instead want to add a separate notation for describing interfaces. The following is an throwaway syntax, intended only to hint at the basic idea: interface I where class C a where f :: a -> a instance C Int instance C a => C [a] module M implements I where ... ... Start allowing parameterization and other interesting features and this begins to look somewhat like ML style modules (and related systems). All the best, Mark
participants (2)
-
David Feuer
-
Mark P Jones