caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Stefan Holdermans <stefan@vectorfabrics.com>
To: Julien Signoles <julien.signoles@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Converting "fun ... (type t) ..." into a caml < 3.12 code
Date: Wed, 26 Jan 2011 16:17:56 +0100	[thread overview]
Message-ID: <5E6C5936-42DB-4816-9CCC-089440DAD33F@vectorfabrics.com> (raw)
In-Reply-To: <AANLkTinJ9DF-kYzmQmhJDPnD2=OSVmD9v5q9FXqUuLYL@mail.gmail.com>

Julien,

> 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?

> =====
> (* val f: 'a -> 'a list *)
> let f (type u) (x:u) =
>   let module S =
>     Set.Make(struct
>       type t = u
>       let compare = Pervasives.compare
>       let equal = ( = )
>     end)
>   in
>   S.elements (S.singleton x)
> =====
> 
> The contraints are:
> * do not change the type of f
> * use the functor Set.Make where type of keys are the same that type of x

Cheers,

  Stefan


  reply	other threads:[~2011-01-26 15:18 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 [this message]
     [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

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=5E6C5936-42DB-4816-9CCC-089440DAD33F@vectorfabrics.com \
    --to=stefan@vectorfabrics.com \
    --cc=caml-list@inria.fr \
    --cc=julien.signoles@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;
as well as URLs for NNTP newsgroup(s).