> Your thought would destroy equational reasoning! For example you
> would be able to define different equalties on the same data
> structure. So Red==Black could be False in one place and True
> in another place. Does that make any sense?
well, yes and no, of course :-)
for instance, i could want to sort a list,
according to two different criteria,
using two different instances of Ord.
moreover, i would need these instances only while sorting,
so i would like to keep them local.
as for equational reasoning, one had to use fully qualified names,
and there's nothing wrong with having two different equivalence relations
foo.(==) and bar.(==) on the same set.
an implementation problem is that we need to record somewhere
(in the data on the heap?) which instance is to be used.
i fear there are more problems hidden. let's take this:
data T = ...
xx = let instance Ord T where ...
x :: T = ...
in x
yy = let instance Ord T where ...
y :: T = ...
in y
do xx and yy have the same type? yes and no, again,
it looks like they belong to different (incomparable) subtypes of T.
what about the expression (xx < yy)? which instance to use?
none - on the outside it's not visible that T is any Ord instance,
so you cannot compare them at all.
--
Dr. Johannes Waldmann Institut fur Informatik Universitat Leipzig
[EMAIL PROTECTED] http://www.informatik.uni-leipzig.de/~joe/
Augustusplatz, D-04109 Leipzig, Germany, Tel/Fax (+49) 341 97 32 204/209