From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id D3C4F7FA31 for ; Wed, 16 Jul 2014 13:17:17 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=193.252.23.215; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=193.252.23.215; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@msa.smtpout.orange.fr) identity=helo; client-ip=193.252.23.215; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@msa.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgABAIRexlPB/BfXnGdsb2JhbABZDoNSV8Iqh0IBgScPAQEBAQEIFAk8hAQBBScRQAEQCw4KCRYPCQMCAQIBRQYNAQcBAYhCCcpOEwSPGDMHhEMBBJschxSQFURqAQ X-IPAS-Result: AgABAIRexlPB/BfXnGdsb2JhbABZDoNSV8Iqh0IBgScPAQEBAQEIFAk8hAQBBScRQAEQCw4KCRYPCQMCAQIBRQYNAQcBAYhCCcpOEwSPGDMHhEMBBJschxSQFURqAQ X-IronPort-AV: E=Sophos;i="5.01,671,1400018400"; d="scan'208";a="71572200" Received: from msa06.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.215]) by mail3-smtp-sop.national.inria.fr with ESMTP; 16 Jul 2014 13:17:17 +0200 Received: from [192.168.1.133] ([92.151.54.109]) by mwinf5d47 with ME id SzHG1o00G2MNqdG03zHGxa; Wed, 16 Jul 2014 13:17:16 +0200 X-ME-Helo: [192.168.1.133] X-ME-Auth: bGV4aWZpQHdhbmFkb28uZnI= X-ME-Date: Wed, 16 Jul 2014 13:17:16 +0200 X-ME-IP: 92.151.54.109 Message-ID: <53C65F3C.6000704@frisch.fr> Date: Wed, 16 Jul 2014 13:17:16 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Leo White CC: caml-list References: <53C5481B.3070409@frisch.fr> <86k37e1bzv.fsf@cam.ac.uk> In-Reply-To: <86k37e1bzv.fsf@cam.ac.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Existential row types 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