Left-bias and non-structural equality.

Adrian Hey ahey at iee.org
Wed Jan 4 11:37:20 EST 2006

On Wednesday 04 Jan 2006 3:25 pm, Christian Maeder wrote:
> I would not like to drop biasing distinction, as I don't think this
> costs too much. With biasing, maps could be implemented via "biased
> sets" (Set (MapEntry a b)):
> data MapEntry a b = a := b
> instance Eq/Ord a => Eq/Ord (MapEntry a b) where
>      compare (a1 := _) (a2 := _) = compare a1 a2

Yikes! You've just done exactly the Bad Thing I was talking
about :-). This is broken IMO. E.G.

val :: MapEntry a b -> b

We can now have (val x) and (val y) yielding different results
even though x and y may be "equal", according to the above Ord

But I guess you know all this already, so I'm somewhat surprised
by this suggestion. I think we should be clear about why we define
classes (and instances thereof) at all. Is it because they provide
some kind of semantic guarantee, or because they save lazy
programmers the effort of passing arbitrary functions about
as explicit arguments? I hope it's the former :-) 

Adrian Hey

More information about the Libraries mailing list