From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0REJ60m005044 for ; Thu, 27 Jan 2011 15:19:06 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar4BAN8NQU3RVdQ2kGdsb2JhbACcZAGIDggWAQEBCQkMBxEEIKEqiX+CF4UFLohZAQEDBYVKBIwnhls X-IronPort-AV: E=Sophos;i="4.60,386,1291590000"; d="scan'208";a="97115970" Received: from mail-vw0-f54.google.com ([209.85.212.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 27 Jan 2011 15:19:00 +0100 Received: by vws9 with SMTP id 9so723351vws.27 for ; Thu, 27 Jan 2011 06:19:00 -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:cc:content-type; bh=5UOdckq2ByWqDALrOauOOKjVCOnOZ7l1nkKtS7quw3A=; b=AMx9qhpgvU+KVQ8SY2P9AOn/6A/W1dhNWxltOq5bkhqSwzCF5onJS+aXwNHb2zEp7y jdPWs+UNs+zYqZkOCtnd2vPTJVa6MzoAU4eLNylilMYLo4mmjk9ilme55zIEM73Fd3KG PwKxC6tgrTLTSUbAH0VpPvmJNVJCpHhhj/3ic= 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 :cc:content-type; b=b0IXpj86cDLYh/g01YBDBraeozyrJwSe1XFC4ZQIWxAEC8oRD8v3h40/IZEYPXmLlD H9O9pXV9VMoVyFdo7Fi8+fJi5gL7GaTRLLfM5xiaRDPTMkSryfGNXXrAjk/4mqjv5r5Y CALO7dxuv62SdcI2eR8UVofaihZWk1fVaJba4= MIME-Version: 1.0 Received: by 10.229.230.10 with SMTP id jk10mr1594322qcb.299.1296137939590; Thu, 27 Jan 2011 06:18:59 -0800 (PST) Received: by 10.229.186.76 with HTTP; Thu, 27 Jan 2011 06:18:59 -0800 (PST) In-Reply-To: References: Date: Thu, 27 Jan 2011 15:18:59 +0100 Message-ID: From: Julien Signoles To: Jeremy Yallop Cc: Caml List Content-Type: multipart/alternative; boundary=0016364ec8c8782075049ad4a11f Subject: Re: [Caml-list] Converting "fun ... (type t) ..." into a caml < 3.12 code --0016364ec8c8782075049ad4a11f Content-Type: text/plain; charset=ISO-8859-1 Hello, 2011/1/26 Jeremy Yallop > On 26 January 2011 12:58, Julien Signoles > wrote: > > How to convert the following ocaml 3.12 code into a typable ocaml < 3.12 > > code? > > I have a solution using Obj. Is it possible without Obj? > > There are safer approaches (than Obj) to a "universal type" described here: > > http://ocaml.janestreet.com/?q=node/18 > > Whether your problem can be solved with such an approach depends on > how flexible your definition of "the same [type]" is. You can > certainly write a function of the same type and behaviour as 'f' that > way, though. > I'm aware of such an universal type. It works fine for the small example of my original post. However I see no way to use it on my real case because it is a bit more complex. Actually it looks like: ===== (* val f: 'a u -> 'a list u *) type 'a u = ... (* a phantom type, defined in another file *) let f (type v) (x:v u) = let module S = F(struct type t = v u (* waiting a type t of the form w u for some w *) let x = x (* an additional list of operations over t *) let equal = ( = ) (* ... *) end) in (S.y : v list u) (* S.y is opaque: no way to destruct it *) ===== I see no way to inject and project values [x] and/or [S.y] to any universal type since the conversion from [x] to [S.y] is done internally by the functor F. Thanks for your help, Julien --0016364ec8c8782075049ad4a11f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

2011/1/26 Jeremy Yallop <yallop@gmail.com>
On 26 January 2011 12:58, Julien Signoles <julien.signoles@gmail.com> wrote:<= br> > How to convert the following ocaml 3.12 code into a typable ocaml <= 3.12
> code?
> I have a solution using Obj. Is it possible without Obj?

There are safer approaches (than Obj) to a "universal type"= described here:

=A0 =A0http://ocaml.janestreet.com/?q=3Dnode/18

Whether your problem can be solved with such an approach depends on
how flexible your definition of "the same [type]" is. =A0You can<= br> certainly write a function of the same type and behaviour as 'f' th= at
way, though.

I'm aware of such an universal ty= pe. It works fine for the small example of my original post. However I see = no way to use it on my real case because it is a bit more complex. Actually= it looks like:
=3D=3D=3D=3D=3D
(* val f: 'a u -> 'a list u *)
type 'a= u =3D ... (* a phantom type, defined in another file *)
let f (type v) = (x:v u) =3D
=A0 let module S =3D
=A0=A0=A0 F(struct
=A0=A0=A0 =A0 type t =3D v u = (* waiting a type t of the form w u for some w *)
=A0=A0=A0=A0=A0 let x = =3D x
=A0=A0=A0=A0=A0 (* an additional list of operations over t *)
= =A0=A0=A0=A0=A0 let equal =3D ( =3D ) (* ... *)
=A0=A0=A0 end)
=A0 in
=A0 (S.y : v list u) (* S.y is opaque: no way to destruct it *)=3D=3D=3D=3D=3D
I see no way to inject and project values [x] and/or [= S.y] to any universal type since the conversion from [x] to [S.y] is done i= nternally by the functor F.

Thanks for your help,
Julien

--0016364ec8c8782075049ad4a11f--