Browse thread
[Caml-list] How can I check for the use of polymorphic equality?
[
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: | 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 http://www.cs.caltech.edu/~jyh > Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257 Hi, 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, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners