From: Julien Signoles <julien.signoles@gmail.com>
To: Jeremy Yallop <yallop@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Converting "fun ... (type t) ..." into a caml < 3.12 code
Date: Thu, 27 Jan 2011 15:18:59 +0100 [thread overview]
Message-ID: <AANLkTimrAQEX=zNmFsTXg9f7zCNZAwceo4e6+3d+UhVC@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinpEh2713_9y5C_ojZvRQCxH_Bq7RAe-+XgHjuW@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]
Hello,
2011/1/26 Jeremy Yallop <yallop@gmail.com>
> On 26 January 2011 12:58, Julien Signoles <julien.signoles@gmail.com>
> 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
[-- Attachment #2: Type: text/html, Size: 2002 bytes --]
prev parent reply other threads:[~2011-01-27 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 12:58 Julien Signoles
2011-01-26 15:17 ` Stefan Holdermans
[not found] ` <AANLkTinyQn4L0C8hHHXJP20upzi++2oKU6RC-2ZTEjDA@mail.gmail.com>
2011-01-26 16:30 ` Julien Signoles
2011-01-26 16:55 ` Jeremy Yallop
2011-01-27 14:18 ` Julien Signoles [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTimrAQEX=zNmFsTXg9f7zCNZAwceo4e6+3d+UhVC@mail.gmail.com' \
--to=julien.signoles@gmail.com \
--cc=caml-list@inria.fr \
--cc=yallop@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox