Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] User-defined equality on types?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-04-19 (11:41)
From: John R Harrison <johnh@i...>
Subject: [Caml-list] User-defined equality on types?

I'd like to suggest allowing the user to define a chosen interpretation
of the equality symbol, and perhaps the polymorphic orderings too, on
each new (maybe just abstract) data type. This seems natural in the 
context of abstract data types with non-canonical representation, giving
a kind of quotient type. Has this ever been considered? Are there good
reasons against it? Of course, I'd be happy for behaviour to be
undefined if the user nominates, say, a non-reflexive or non-substitutive
"equality" relation.

At present, I find that it's often quite inconvenient to use complicated
structures involving abstract types. In particular, I use the type of
arbitrary-precision numbers a lot, and frequently end up having to
define variants of standard polymorphic operations like set union for
several different types involving ":num". This would be avoided if I
could just automatically interpret "=" on the type ":num" as the special
comparison operator "=/".

Any opinions?
To unsubscribe, mail  Archives: