Browse thread
[Caml-list] User-defined equality on types?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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? John. ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr