Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Francisco Valverde Albacete <fva@t...>
Subject: Re: [Caml-list] User-defined equality on types?
Hi, please read below the question:

John R Harrison wrote:

> 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?

Have you considered using functors defining your datatype structures? In that way
you can customise the use of equality throught the whole module with something like:

module ParameterisedADT
    (Eq: sig
               type t
               val (=) : t -> t -> bool
            end)
    =
    struct
        (* code of the ADT with whatever uses of your own "="! *)
    end

you just have to supply a structure for formal parameter Eq with the adequate
semantics. The semantics of this new operation will be entirely up to the
implementation in the parameter module (you can do really strange things here).

Hope it helps.

            Fran Valverde

PS: I apologise for the lack of French version. My French is way too rusty to write
anything sensible with it. FVA.


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr