简体   繁体   中英

Module packs with ocamlbuild

I have the following file hierarchy:

foo.mlpack
Foo/
   bar.ml
   baz.ml
foo.ml

and I want to be able to do the following:

let () =
  Foo.Bar.some_func1 ();
  Foo.Baz.some_func2 ();
  Foo.some_func3 ()

How can I tell ocamlbuild to take foo.ml into account when creating the Foo module?

Edit 1

Thanks to the answer of daniel-bünzli, I was able to do what I wanted. So now, I'm in the following scenario:

_tags

foo.mllib
foo.ml
Foo/
   bar.ml
   baz.ml

toto.mllib
toto.ml
Toto/
    ...
    bar.ml
    ...

The problem now is that Toto.Bar seems to be occluded by Foo.Bar . I can't access Toto.Bar 's content.

Edit 2

Ok in fact it's not a real problem.

I've just renamed Foo/bar.ml -> Foo/fooBar.ml .

So I have the following in foo.ml :

module Bar = FooBar

If I understand correctly, the guys from Jane Street do the same thing in Core_kernel with Core_list and some other modules.

Don't use mlpack .

Simply define your foo.ml as follows:

module Bar = Bar
module Baz = Baz
let some_func3 () = ...

Then simply define a .mllib with

Foo

Don't forget to <Foo> : include in your _tags file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM