Browse thread
How to make a value uncomparable
[
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: | 2008-04-23 (16:15) |
From: | Berke Durak <berke.durak@e...> |
Subject: | Re: [Caml-list] How to make a value uncomparable |
Christophe Raffalli wrote: >> =20 >> module Uncomparable : >> sig >> type 'a t >> val make : 'a -> 'a t >> val get : 'a t -> 'a >> end >> =3D >> struct >> type 'a t =3D unit -> 'a >> =20 >> let make x =3D fun _ -> x >> =20 >> let get x =3D x () >> end >> =20 Indeed, that's a much simpler solution! :) But there's one minor difference: physical equality works on Weak.t but not on functions. But that can be handled by using a ref to a function. module Structurally_uncomparable : sig type 'a t val make : 'a -> 'a t val get : 'a t -> 'a end = struct type 'a t = (unit -> 'a) ref let make x = ref (fun _ -> x) let get x = (!x)() end -- Berke DURAK