caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Existential row types
Date: Tue, 15 Jul 2014 17:26:19 +0200	[thread overview]
Message-ID: <53C5481B.3070409@frisch.fr> (raw)

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

             reply	other threads:[~2014-07-15 15:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 15:26 Alain Frisch [this message]
2014-07-15 22:41 ` Leo White
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=53C5481B.3070409@frisch.fr \
    --to=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;
as well as URLs for NNTP newsgroup(s).