From: Jeremy Yallop <yallop@gmail.com>
To: Pierre-Etienne Meunier <pierreetienne.meunier@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Partial module include
Date: Fri, 21 Sep 2012 18:47:07 +0100 [thread overview]
Message-ID: <CAAxsn=FTwVY757AbZHMCdMYX8Mh0DXTUYGMK_U5bRMZZRnC6vg@mail.gmail.com> (raw)
In-Reply-To: <4C5580B1-5737-40ED-B7B4-83ACFFAD491B@gmail.com>
On 21 September 2012 17:43, Pierre-Etienne Meunier
<pierreetienne.meunier@gmail.com> 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.
prev parent reply other threads:[~2012-09-21 17:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 16:37 Pierre-Etienne Meunier
2012-09-21 16:41 ` David House
2012-09-21 16:43 ` Pierre-Etienne Meunier
2012-09-21 16:47 ` David House
2012-09-21 16:55 ` Markus Mottl
2012-09-21 17:47 ` Jeremy Yallop [this message]
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='CAAxsn=FTwVY757AbZHMCdMYX8Mh0DXTUYGMK_U5bRMZZRnC6vg@mail.gmail.com' \
--to=yallop@gmail.com \
--cc=caml-list@inria.fr \
--cc=pierreetienne.meunier@gmail.com \
/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