Sorry, forgot the list... ---------- Forwarded message ---------- From: Julien Signoles Date: 2011/1/26 Subject: Re: [Caml-list] Converting "fun ... (type t) ..." into a caml < 3.12 code To: Stefan Holdermans 2011/1/26 Stefan Holdermans > How to convert the following ocaml 3.12 code into a typable ocaml < 3.12 > code? > > Coincidentally, earlier today, I ran into a situation not that different > from the one you describe. I haven't come up with a satisfying solution yet. > > > I have a solution using Obj. Is it possible without Obj? > > Are you willing to share this solution? > ==== let g (x:'a) = let module S = Set.Make(struct type t = Obj.t let compare = Pervasives.compare let equal = ( = ) end) in (Obj.magic (S.elements (S.singleton (Obj.repr x))) : 'a list) (* less efficient but using Obj.obj instead of Obj.magic: *) (* List.rev (S.fold (fun o acc -> (Obj.obj o:'a) :: acc) (S.singleton (Obj.repr x)) []) *) ==== Note that: 1) I'm pretty sure someone who initials are XL will be unhappy with such a solution 2) For a real-world application [*], I prefer to leave a known bug instead of fixing it using such a solution... And either waiting for a solution without Obj or waiting for a future day where our software will require ocaml 3.12 -- Julien [*] Frama-C (http://frama-c.com)