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] Hunting polymorphic function applications
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alain Frisch <Alain.Frisch@e...>
Subject: Re: [Caml-list] Hunting polymorphic function applications
On Fri, 23 Jul 2004, Jon Harrop wrote:

> For elegance, I've been using the built-in polymorphic comparisons
> (particularly equality) to compare ASTs. I just added some metadata to my AST
> type and now it needs its own comparison function (or polymorphic compare
> bails at run-time with Invalid_argument "equal: functional value").
> Is there an easy way, or does anyone have a tool, which will let me track down
> all applications of polymorphic functions to my AST type so that I can alter
> them to use my customised versions?

I sometimes use the following trick: redefine the operators at the
beginning of the module. E.g.:

let (=) (x:unit) : unit = assert false
let (<=) (x:unit) : unit = assert false
let compare (x:unit) : unit = assert false

This should produce type-errors where expected.

(Variant: "let (<=) = ((<=) : int -> int -> bool)" to
restrict the use to the integer case)

-- Alain

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