From: Leo White <lpw25@cam.ac.uk>
To: Jordan W <jordojw@gmail.com>
Cc: "caml-list\@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Module aliases ideal name-spacing
Date: Sun, 28 Dec 2014 18:15:46 +0000 [thread overview]
Message-ID: <87d273ljxp.fsf@study.localdomain> (raw)
In-Reply-To: <CAPOA5_5nmdNTst8GJk5TgUABOviuRdLbh4UUazDewEHZWxydWw@mail.gmail.com> (Jordan W.'s message of "Sat, 27 Dec 2014 15:04:13 -0800")
> One set of modules that form a kind of namespaced "project" MyLib.
> ---------
>
> ~/myLib/myModule.ml
> open MyLib (* This is not needed - short names are same as long *)
> (* Sees Utils belonging to MyLib *)
>
> ~/myLib/utils.ml
> open MyLib (* This is not needed - short names are same as long *)
>
> ~/myLib/myLib.mli and ~/myLib/myLib.ml
> module MyModule = MyModule
> module Utils = Utils
>
> Another set of modules ("project") that depends on the previous project YourLib
> ---------
>
> ~/yourLib/yourModule.ml
> open YourLib (* This is not needed - short names are same as long *)
> (* Sees Utils belonging to YourLib *)
>
> ~/yourLib/utils.ml
> open YourLib (* This is not needed - short names are same as long *)
>
> ~/yourLib/yourLib.mli and ~/yourLib/yourLib.ml
> module YourModule = YourModule
> module Utils = Utils
>
> Finally, an application "project" that uses the namespaces generated by the previous two projects
> ---------
>
> ~/myApp/myApp.ml
> let x = MyLib.Utils.x + YourLib.Utils.y
>
You can use the `-o` and `-open` command-line options to get the
behaviour you are after. If you change myLib/myLib.ml(i) to be
module MyModule = MyLibMyModule
module Utils = MyLibUtils
and make similar changes to yourLib/yourLib.ml(i), then you can use the
following commands:
cd ~/myLib
ocamlc -no-alias-deps myLib.mli
ocamlc -no-alias-deps myLib.ml
ocamlc -c -open MyLib -o myLibUtils.cmo utils.ml
ocamlc -c -open MyLib -o myLibMyModule.cmo myModule.ml
cd ~/yourLib
ocamlc -c -no-alias-deps yourLib.mli
ocamlc -c -no-alias-deps yourLib.ml
ocamlc -c -open YourLib -o yourLibUtils.cmo utils.ml
ocamlc -c -open YourLib -o yourLibYourModule.cmo yourModule.ml
cd ~/myApp
ocamlc -c -I ../myLib -I ../yourLib myApp.ml
Setting up this compilation scheme in your build system might be a bit
of effort, but it should work.
Regards,
Leo
next prev parent reply other threads:[~2014-12-28 17:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-27 23:04 Jordan W
2014-12-28 18:15 ` Leo White [this message]
2014-12-28 20:34 ` Jordo
2014-12-28 21:26 ` Leo White
2014-12-28 23:25 ` Jordan W
2014-12-29 0:14 ` Leo White
2015-01-07 15:15 ` Goswin von Brederlow
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=87d273ljxp.fsf@study.localdomain \
--to=lpw25@cam.ac.uk \
--cc=caml-list@inria.fr \
--cc=jordojw@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