On Wed, Sep 10, 2014 at 02:26:28PM +0200, Gerd Stolpmann wrote: > type t = ... > type t_cmp = t * int > > let wrap x = (x, Hashtbl.hash x) > > let my_compare (x1,h1) (x2,h2) = > if h1=h2 then > compare x1 x2 > else > h1-h2 This code is incorrect when h1 is large and negative. You should use "compare h1 h2" and annotate h1 and/or h2 with its type (int), so that int-compare is called directly. Also, if you store the hash before the actual value, compare will probably stop comparing after it finds that the hashes are not equal, so you can simply use the polymorphic compare on t_cmp. I don't know this for sure, since I haven't looked at the source, but I would assume this is true. -- Pippijn