From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0QGUhwY012743 for ; Wed, 26 Jan 2011 17:30:43 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwAAFvbP03RVdQ2kGdsb2JhbACkbwgVAQEBAQkJDAcRBCCiKooAgheFEy6IWQEBAwWFSgSMKYZd X-IronPort-AV: E=Sophos;i="4.60,380,1291590000"; d="scan'208";a="86286900" Received: from mail-vw0-f54.google.com ([209.85.212.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 26 Jan 2011 17:30:27 +0100 Received: by vws9 with SMTP id 9so415334vws.27 for ; Wed, 26 Jan 2011 08:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=oH0Ox0G85IGlkgTmc80TkN+sReszVWATH7qiL/034fM=; b=O+R0GB0Tw+JTCqWvQGVUmS/sk7DBfa2jMd5yv/VsF+3jwJnEwqtd1gavPIhILLsgxE yXEfEM9anoxRjn261Usk3nIxuoMhlshcnJF1whVM9VkBxzHyl1zgXB66ehnC4Eqdpbk4 HwhBTZm7RcWT97G4MfkDOZdL7O6Jkp301ya6s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=RCmqVavxojt9tDhqV1PsOvHbDv0lKiOd8nC8hNLnIEQ9UWbXb8yNQ0UDcas13U3f+U fVjpem2Bht1JImKCCgkpWMP6uidwXmtxGc5yhQws/Hf+XbleiJvvhnK+SBz5cxz6JCLq bfn6Q/4CN7IBZcKlyUETvjnp4OlmifhtYMQxI= MIME-Version: 1.0 Received: by 10.229.188.68 with SMTP id cz4mr538064qcb.261.1296059425980; Wed, 26 Jan 2011 08:30:25 -0800 (PST) Received: by 10.229.186.76 with HTTP; Wed, 26 Jan 2011 08:30:25 -0800 (PST) In-Reply-To: References: <5E6C5936-42DB-4816-9CCC-089440DAD33F@vectorfabrics.com> Date: Wed, 26 Jan 2011 17:30:25 +0100 Message-ID: From: Julien Signoles To: Caml List Content-Type: multipart/alternative; boundary=0016362843cab18f39049ac2597c Subject: [Caml-list] Converting "fun ... (type t) ..." into a caml < 3.12 code --0016362843cab18f39049ac2597c Content-Type: text/plain; charset=ISO-8859-1 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) --0016362843cab18f39049ac2597c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sorry, forgot the list...

---------- Forw= arded message ----------
From: Julien Sign= oles <julien.signoles@gmail.com>
Date: 2011/1/26
Subject: Re: [Caml-list] Converting "fun ... (type = t) ..." into a caml < 3.12 code
To: Stefan Holdermans <stefan@vectorfabrics.com>




2011/1/26 Stefan Holdermans <stefan@vectorfabrics.com>

> How to convert the following ocaml 3.12 code into a typable ocaml <= 3.12 code?

Coincidentally, earlier today, I ran into a situat= ion not that different from the one you describe. I haven't come up wit= h a satisfying solution yet.

> I have a solution using Obj. Is it possible without Obj?

Are you willing to share this solution?
=3D=3D=3D=3D
let g (x:'a) =3D

=A0 let module = S =3D
=A0=A0=A0 Set.Make(struct
=A0=A0=A0 =A0 type t =3D Obj.t<= div class=3D"im">
=A0=A0=A0 =A0 let compare =3D Pervasives.compare
=A0=A0=A0 =A0 let equal =3D ( =3D )
=A0=A0=A0 end)
=A0 in
=A0 (Obj.magic (S.elements (S.singleton (= Obj.repr x))) : 'a list)
(* less efficient but using Obj.obj instead= of Obj.magic: *)
(*=A0 List.rev (S.fold (fun o acc -> (Obj.obj o:= 9;a) :: acc) (S.singleton (Obj.repr x)) []) *)
=3D=3D=3D=3D

Note that:
1) I'm pretty sure someone who initia= ls are XL will be unhappy with such a solution
2) For a real-world appli= cation [*], 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)

--0016362843cab18f39049ac2597c--