It’s because of namespacing. Dune wraps each library component in a toplevel module which has the same name as the library: Stanza Reference — Dune documentation
(wrapped <boolean>)
specifies whether the library modules should be available only through the top-level library module, or if they should all be exposed at the top level. The default istrue
, and it’s highly recommended to keep it this way. Because OCaml top-level modules must all be unique when linking an executables, polluting the top-level namespace will make your library unusable with other libraries if there is a module name clash. This option is only intended for libraries that manually prefix all their modules by the library name and to ease porting of existing projects to Dune.
In this case suppose you have lib/
which contains:
dune
mymodule.ml
othermodule.ml
And dune
contains:
(library
(name lib))
Then the modules will be available as: Lib.Mymodule
and Lib.Othermodule
.