With an oasis
pack in oasis bit broken as it compresses the namespace, including all paths in the search path. There is a long-awaited accepted error request, but still stays where they are. But if it worked correctly, it can help you, as it will create library namespaces, allowing you to have modules with the same name in a different folder. But this does not work, so we must forget about it.
The approach we took in the BAP project was to cripple all module names with the ugly bap_subproject_ prefix, which protects us from conflicts with our own modules, as well as from conflicts coming from external libraries. For each bap_subproject , we have a folder with all implementation modules with malformed names and one umbrella module to manage them all. This module is stored in the bap_subproject.ml file, where it defines aliases for all modules and types that it is going to export. It usually contains entries like:
module X = Bap_subproject_x
There is also a large Bap project that consolidates all subareas under one Bap.Std namespace and re-exports everything it needs, so after one open Bap.Std you have access to the Insn module, which is defined in bap_disasm/bap_disasm_insn.ml[i]
No oasis
Disclaimer: This solution may still work with the oasis if you expand it with the plugin.
We used this approach in one project, which, unfortunately, is closed, so I can not provide a link. Each subproject lives in its own subfolder, within its own namespace (we had a parser module in each subfolder, without any clobber). For each subproject, the mlpack file is mlpack in the top folder:
root + | +-- expr.mlpack +-- expr -+ | +- lexer.* +- parser.* +- ast.* +- ... +-- cameo.mlpack +-- cameo-+ | +- lexer.* +- parser.* +- ast.* +- ...
The content of expr.mlpack :
expr/Lexer expr/Parser expr/Ast ...
ocamlbuild sees this expr.mlpack as a standalone module that has Lexer , parser , etc. submodules defined in it (and available as, for example, Expr.Lexer ). And there are no conflicts with the sibling project, which also has Lexer , and also does not conflict with ocaml-libs or any other external Lexer , since the expr folder is never really included in the search path.
If you need to add another layer to your system, for example a package for packages, then you have three options:
- use the same approach recursively, i.e. create another super-folder in which there are
mlpack or mllib files pointing to the child folder. - just add
big.mlpack which references all toplevel mlpack 'ed modules - create
big.ml , which re-introduces all the modules.
The last two approaches require that top-level packaged modules have different names. But this is usually true.