Hi, I’m new to OCaml and I’m trying to understand how to use dune
.
I constructed a minimal example that looks like this:
.
├── dune-project
├── lib
│ ├── dune
│ ├── mylib.ml
│ └── mymod.ml
└── test
├── dune
└── test.ml
The dune-project
file just contains one line: (lang dune 3.12)
The lib/dune
file contains: (library (name mylib))
The test/dune
file contains:
(test
(name test)
(libraries mylib))
The lib/mylib.ml
file contains:
let one = 1
let _ = assert (one = 1)
let _ = assert (Mymod.two = 2)
And the lib/mymod.ml
file, which is supposed to be a submodule, contains:
let two = 2
Now my test in test/test.ml
looks like this:
let _ = assert (Mylib.one = 1)
let _ = assert (Mylib.Mymod.two = 2)
I get the following error:
$ dune test
File "test/test.ml", line 2, characters 16-31:
2 | let _ = assert (Mylib.Mymod.two = 2)
^^^^^^^^^^^^^^^
Error: Unbound module Mylib.Mymod
Why does Mymod.two
work inside lib/mylib.ml
but not inside the test. What am I doing wrong?
11 posts - 4 participants