I’m new to Dune and OCaml, and I have the fundamental problem that the content of a .mli file is not visible from the corresponding .ml file. I must be missing something very basic.
Minimal example:
dune init proj myproj
(No changes to any dune files after this.)
Add files lib/foo.ml and lib/foo.mli
(* lib/foo.mli *)
module type Foo_sig = sig
val content : string
end;;
Interfaces (.mli files) are not “included” in the corresponding implementations (.ml files), so the behaviour you observed is expected: what you write in the .mli is not “visible” from the corresponding .ml. In fact, in OCaml it works the other way around: .mli files are used to restrict the visibility of objects defined in .ml files, so that eg specific types or values, or details thereof, may be kept private to the implementation, hidden from the users of the module.
(or remove the explicit module declaration/definition entirely).
The pattern of putting a named module type in the .mli is from a project I’m currently looking at (HOLzero). There it works because everything (.mli and .ml) is just thrown into the toplevel by #use or something similar.