ocamlbuild
ocamlbuild copied to clipboard
lib.mllib with lib.mli but no lib.ml doesn't build
If you have a lib.mllib file for an archive which is to contain Lib from lib.mli but the lib.mli file does not have a corresponding lib.ml file, ocamlbuild will refuse to build the archive by saying it knows of no rules to build target lib.cmo.
I'm a bit confused, I thought that archives were just collection of compiled implementation units, and that you had to provide the .cmi on the side anyway for the type-checker to find. Does it make sense to have a .mli with no .ml in an archive? How does that work when directly invoking the compiler?
That is true but the archive will still be built (but lacking the implementation-less modules) in the other cases. Perhaps the correct solution is to make .mllib files which contain modules without implementations to always fail? There is a disparity between the behaviors when the archive and the implementation-less module share the same name.
Perhaps the correct solution is to make .mllib files which contain modules without implementations to always fail?
Yes, at least that is the behaviour I would expect.
Generally, to use .mli without .ml leads to multiple problems; better to put the content of the .mli in the .ml. I'm not saying that ocamlbuild shouldn't support this use case.
If the compiler supports it and libraries use it, I think the rest of the tools should at least try to support it.
There is no debate here, ocamlbuild does support .mli without .ml.