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] How can I check for the use of polymorphic equality?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] How can I check for the use of polymorphic equality?
> In the meantime, I use a hack to help catch errors at runtime.  The idea 
> is this.
>     1. The type you care about is probably abstract.
>     2. Add an abstract value to the data in your type, so that equality
>        will fail (at runtime).
> -- 
> Jason Hickey        
> Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257


Your trick is fine and clever but it seems overcomplex to me: to check
usage of equality, I would just redefine equality!

If you add, in the scope of each module (for instance by systematically
opening a basic code module), a new binding for ( = ) as in

let ( = ) (x : 'a) (y : 'a) = assert false;;

then the generic equality is no more used and any occurrence of ( = )
will raise an assertion failure at runtime.

You could also define assign a special type for your ``fake'' generic
equality that would trigger a typecheckeking error statically. For
instance, define

let ( = ) (x : int) (y : bool) = assert false;;

You probably will catch every reasonable usage of ( = ) that way...

Simple, no ?

Pierre Weis

INRIA, Projet Cristal,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: