From: Leo White <lpw25@cam.ac.uk>
To: Alain Frisch <alain@frisch.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Existential row types
Date: Tue, 15 Jul 2014 23:41:08 +0100 [thread overview]
Message-ID: <86k37e1bzv.fsf@cam.ac.uk> (raw)
In-Reply-To: <53C5481B.3070409@frisch.fr> (Alain Frisch's message of "Tue, 15 Jul 2014 17:26:19 +0200")
Hi Alain,
There is a work-around, but it is quite convoluted:
https://sympa.inria.fr/sympa/arc/caml-list/2012-10/msg00131.html
There is also a feature request for the feature you propose:
http://caml.inria.fr/mantis/view.php?id=6137
Regards,
Leo
Alain Frisch <alain@frisch.fr> writes:
> Dear all,
>
> GADTs allow to restrict existential type variables to being an instance of a row type, as in:
>
> class type c = ...
>
> type s =
> | EX: ((#c as 'a) -> unit) * (unit -> 'a) -> ex
>
>
> I'm wondering if it is possible to simulate such restricted existential quantification with first-class module and
> private row types. Something like:
>
>
> module type S = sig
> type t = private #c
> val f: t -> unit
> val g: unit -> t
> end
>
> let foo (type t_) (f : (#c as t_) -> unit) (g : unit -> t_) =
> let module M = struct
> type t = t_
> let f = f
> let g = g
> end
> in
> (module M : S)
>
>
> This does not work, of course, because of the "... as t_". Is there a local work-around? If not, I'm wondering if if
> would be easy (and make sense) to introduce a form for introducing locally private row types:
>
> let foo (type t_ = private #c) (f : t_ -> unit) (g : unit -> t_) = ...
>
>
>
> -- Alain
next prev parent reply other threads:[~2014-07-15 22:41 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 [this message]
2014-07-16 11:17 ` Alain Frisch
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=86k37e1bzv.fsf@cam.ac.uk \
--to=lpw25@cam.ac.uk \
--cc=alain@frisch.fr \
--cc=caml-list@inria.fr \
/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