caml-list - the Caml user's mailing list
 help / 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)
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 index

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 publically 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

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox