caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Thierry Martinez <thierry.martinez@inria.fr>
To: Vadim <vadim@radovel.ru>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] How to shadow nested submodules?
Date: Fri, 11 Oct 2019 17:40:06 +0200 (CEST)	[thread overview]
Message-ID: <1296445821.9982847.1570808406866.JavaMail.zimbra@inria.fr> (raw)
In-Reply-To: <0634cce4-0468-c10e-30c8-8e8e7ec937d7@radovel.ru>

Hello, Vadim!

Vadim:
> Hello! I'm trying to figure out how shadow/override nested modules in
> OCaml.

A generic solution for old OCaml versions (<4.08) has been explained by
Gabriel Scherer in the following blog post:
http://gallium.inria.fr/blog/overriding-submodules/

The idea is to use destructive substitution while including the original
Ipaddr:
http://caml.inria.fr/pub/docs/manual-ocaml-4.01/extn.html#sec234

module Ipaddr = struct
  include (Ipaddr : module type of Ipaddr with module Prefix := Ipaddr.Prefix)
  ...
end

But I guess that the code you posted should work just fine with OCaml >=4.08
thanks to the following change:
https://github.com/ocaml/ocaml/pull/1892

Best regards.
-- 
Thierry Martinez.

  reply	other threads:[~2019-10-11 15:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 15:24 Vadim
2019-10-11 15:40 ` Thierry Martinez [this message]
2019-10-11 16:09   ` Vadim

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=1296445821.9982847.1570808406866.JavaMail.zimbra@inria.fr \
    --to=thierry.martinez@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=vadim@radovel.ru \
    /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).