From: Alain Frisch <alain@frisch.fr>
To: Leo White <lpw25@cam.ac.uk>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Existential row types
Date: Wed, 16 Jul 2014 13:17:16 +0200 [thread overview]
Message-ID: <53C65F3C.6000704@frisch.fr> (raw)
In-Reply-To: <86k37e1bzv.fsf@cam.ac.uk>
Hi Leo,
On 7/15/2014 6:11 PM, Leo White wrote:
> There is a work-around, but it is quite convoluted:
>
> https://sympa.inria.fr/sympa/arc/caml-list/2012-10/msg00131.html
Very clever trick. Thanks!
One can actually use the GADT only to carry the constraint and pass the
value argument(s) separately. This means the GADT definition remains
very simple even if we need to add many fields:
=============================================================
class type c = object end
module type SIG =
sig
type t = private #c
val f: t -> unit
val g: unit -> t
end
type 'a aux = Aux: (#c as 'a) aux
let create f g =
let helper (type u) (Aux : u aux) f g =
(module struct
type t = u
let f = f
let g = g
end : SIG)
in
helper Aux f g
(* or even: *)
let create f g =
let module Aux = struct type 'a t = E: (#c as 'a) t end in
begin fun (type u) (Aux.E : u Aux.t) f g ->
(module struct
type t = u
let f = f
let g = g
end : SIG)
end Aux.E f g
=============================================================
-- Alain
prev parent reply other threads:[~2014-07-16 11:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 15:26 Alain Frisch
2014-07-15 22:41 ` Leo White
2014-07-16 11:17 ` Alain Frisch [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=53C65F3C.6000704@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@inria.fr \
--cc=lpw25@cam.ac.uk \
/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