caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Existential row types
@ 2014-07-15 15:26 Alain Frisch
  2014-07-15 22:41 ` Leo White
  0 siblings, 1 reply; 3+ messages in thread
From: Alain Frisch @ 2014-07-15 15:26 UTC (permalink / raw)
  To: caml-list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-16 11:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 15:26 [Caml-list] Existential row types Alain Frisch
2014-07-15 22:41 ` Leo White
2014-07-16 11:17   ` Alain Frisch

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).