Pardon if my terminology is a bit off, but this is my first haskell language
suggestion. In any case I thought a feature that might be very useful for
haskell would be the ability to supertype as well as subtype classes. Basically
it would allow you too add nodes anywhere in the class inheritence tree rather
than just extending the bottom. It is VERY useful to allow reuseability of code
in ways the original author did not anticipate.
for an example from algebra imagine you are given a class Num a which basically
represents a field and you need a Group class and would like to reuse the
standard operators in Num as well as have all types (Num a) automatically work
as Groups. With supertyping you can without modifying or accessing the original
code at all. you simply declare the following:
(ex. in psuedo-haskell)
class Num a <= Group a where
(+) :: a -> a -> a
negate :: a -> a
note the <=, this decares the new class Group from which the existing Num
is derived.
this would create the new class Group and add it to the class inheritance tree
above Num, note that the operations in Group must be a subset of what is
currently contained in Num, the effect is the exact same as if Num had derived
from Group in the first place.
this would take much of the burden of any author writing reuseable componants to
come up with the 'perfect' class inheritence tree. It would also be particulary
useful in haskell since overloading takes place only via classes so a not well
thought out class can eat up a lot of the namespace which you would like to
reuse for more fine grained components (as in the above example.)
This functionality becomes even more necisarry when faced with binary-only
libraries and standard language features which cannot be easily rewritten or
overridden without great effort.
note that supertyping has been used successfully in Sather
(http://gnu.org/software/sather). Although sather is an imperitive OO language
its type systems consists of declarative inheritence of interfaces which are
somewhat similar to simple haskell classes.
let me know what you think... if this functionality already exists or it
horribly breaks the soundness of the typesystem then i apologize. It does not
seem to adversly affect the typesystem as far as i can tell as it does not
really add any new constructs it only generalizes class hierchy construction...
of course, as always, i could just be plain wrong.
John
--
--------------------------------------------------------------
John Meacham http://synergy.foo.net/~john/ [EMAIL PROTECTED]
California Institute of Technology, Student.
--------------------------------------------------------------