Left-bias and non-structural equality.

Arie Peterson ariep at xs4all.nl
Wed Jan 4 12:17:07 EST 2006

Christian Maeder wrote:
> Agreed, but suppose you have Symbols with their positions. Then you may
> like that a set of symbols is printed with the positions last (or first)
> inserted, although positions are ignored in camparisons.
> C.

It seems that there are two uses of Set e:

1) the Ord-comparison of e's is a total ordering / Eq e implements
semantic equality;

2) Eq e is some equivalence relation, such as in Christian's example above.

I agree with Jean-Philippe that 2) must not be advocated: users should
always use a Map instead (e.g. Map Symbol Position, with 'real equality'
on Symbol).

Now, it may save effort to *implement* Map by doing exactly 2), with e =
MapElement a b. The work needed to reimplement Map would have to be
compared to the work needed to ensure that Set supports use 2).

However, this is purely a consideration of implementation, and does not
effect the user experience of Set and Map - provided that she only uses
Set as per 1).



More information about the Libraries mailing list