How to create the minimal .mli files (using Dune)

Hi!

Assuming an existing project, is there a tool / setting to generate the minimal interface files that make the build succeed? (Minimal by the number of entries.)

Thanks!

As far as I know, no. You can generate interfaces from implementations with ocamlc -i, but they won’t be minimal.

Cheers,
Nicolas

That would require some cross-module whole-project analysis. There is reanalyze, which does some analyses like that (in particular dead code): GitHub - rescript-association/reanalyze: Experimental analyses for ReScript and OCaml: globally dead values/types, exception analysis, and termination analysis..

It doesn’t have the exact feature you’re asking for, but it might provide a good starting point for implementing such analysis with the information it already has. Or maybe its dead code analysis already can say which interface elements (from an automatically generated complete interface) are dead? It’s been a while since I last used reanalyze.

2 Likes