From: "Richard W.M. Jones" <rich@annexia.org>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] #use is not textual inclusion
Date: Sat, 29 Feb 2020 10:32:38 +0000 [thread overview]
Message-ID: <20200229103238.GE11122@rich.annexia.org> (raw)
In-Reply-To: <CAPFanBFcX2gLbdBVt=k+S6P79x2VpSH3CURQmecauR6xgJm=Ww@mail.gmail.com>
On Sat, Feb 29, 2020 at 10:09:51AM +0100, Gabriel Scherer wrote:
> I think that your example is rejected not because of the semantics of #use,
> but because toplevel directives in general are parsed at the level of
> toplevel *phrases*, and not possibly-in-depth structure items. In other
> words, a toplevel script is a sequence of structure items or toplevel
> directives, but directives are not (nestable) structure items. The
> documentation seems correct -- consistent with this behavior.
>
> I see a way to do what you want using #mod_use, but it is a bit indirect
> because #mod_use does not directly support signature checking:
>
> module type Foo_sig = sig ... end
> #mod_use "implementation.ml";;
> module Foo = (Implementation : Foo_sig);;
>
> This approach defines a suitably restricted Foo, but it also exposes the
> Implementation module in the rest of the scope. You can avoid this if you
> use the same .ml name as the module name you want, so that shadowing hides
> the implementation module
>
> module type Foo_sig = sig ... end
> #mod_use "foo.ml <http://implementation.ml>";;
> module Foo = (Foo : Foo_sig);;
These do pretty much what I want, thanks.
Rich.
prev parent reply other threads:[~2020-02-29 10:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-29 8:53 Richard W.M. Jones
2020-02-29 9:09 ` Gabriel Scherer
2020-02-29 10:32 ` Richard W.M. Jones [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=20200229103238.GE11122@rich.annexia.org \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@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;
as well as URLs for NNTP newsgroup(s).