From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 76E037ED7A for ; Fri, 21 Sep 2012 19:47:08 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=74.125.82.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 74.125.82.182 as permitted sender) identity=mailfrom; client-ip=74.125.82.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f182.google.com) identity=helo; client-ip=74.125.82.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-we0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApYBAFKnXFBKfVK2kGdsb2JhbABFhgu4BQgjAQEBAQkJDQcUBCOCIAEBAQQSAg8dARsdAQMMBgULDQICJgICIQEBEQEFARwGEwgah1ABAw+aVgkDi1ZPgnWFFgoZJw1ZiHQBBQyBFYkZYoUUgRIDlA+BVYsYgysWKYQI X-IronPort-AV: E=Sophos;i="4.80,463,1344204000"; d="scan'208";a="156554720" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 21 Sep 2012 19:47:07 +0200 Received: by weyx56 with SMTP id x56so3215987wey.27 for ; Fri, 21 Sep 2012 10:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Ei5sgqLufwYk/sX5K3SKbn2ExNGFYf7QYKlvnE3R0FU=; b=pnGAlsuw92FuUDWJrP89OFboHrOuhcdUlQNyFBmh2HVbAZt+I/j55cmcV3hh6+Wgqw 2UtMF4oB2ZDVi64iVn+66wuP42XWBrpjyUBKegapMHTFv5uwRMoNcPk/NlPiPzLid53E 0ctjL4mx672UGQb3JwtxM0cIEhI/9OmO2CJJTbQI6OoOW1pdPdD+8cPx2lYnsZ+htAt9 CHdSwgHiSECpjH7N3NyEaaSq3tZRnZ1KDDLePpMWtayTLNe+mDAU48Zf7eN8BAQr1cBD dCD0JqDucfUytKxvwQub1xB9frY5X0i995Ca3zaBQoOuHUyKX1cQI2AwaU3E475kkKKT H5JA== MIME-Version: 1.0 Received: by 10.216.233.216 with SMTP id p66mr3024590weq.152.1348249627590; Fri, 21 Sep 2012 10:47:07 -0700 (PDT) Received: by 10.194.34.229 with HTTP; Fri, 21 Sep 2012 10:47:07 -0700 (PDT) In-Reply-To: <4C5580B1-5737-40ED-B7B4-83ACFFAD491B@gmail.com> References: <3371F9A1-1248-42DC-9761-8A7797A1C1D1@gmail.com> <4C5580B1-5737-40ED-B7B4-83ACFFAD491B@gmail.com> Date: Fri, 21 Sep 2012 18:47:07 +0100 Message-ID: From: Jeremy Yallop To: Pierre-Etienne Meunier Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Partial module include On 21 September 2012 17:43, Pierre-Etienne Meunier wrote: > module A=struct > let a=0 > module B=struct let b=1 end > end > > module B=struct > include A > module B=struct let b=2 end > end You can achieve this using destructive substitution and 'module type of' in recent versions of OCaml: module A = struct let a = 0 module B = struct let b = 1 end end module B = struct include (A : module type of A with module B := A.B) module B = struct let b = 2 end end The 'with module B := B' construct removes the 'B' component from the type of the 'A' module, allowing you to introduce a replacement: # module type ASIG = module type of A;; module type ASIG = sig val a : int module B : sig val b : int end end # module type ASIG = module type of A with module B := A.B;; module type ASIG = sig val a : int end Jeremy.