I’m cleaning up an older piece of OCaml code as I work on it. The author included a huge personal library (basically their own giant stdlib++) and it isn’t obvious what parts of it are and aren’t relevant to the code I’m actually using.
Are there any good tools for figuring out what code is and isn’t live in a program?
within a module, the ocaml compiler itself can find code (values, modules…) that is defined but not exposed in the interface if you enable the corresponding warnings. If the build system is a bit custom, the flags might be hardcoded to something that hide these low hanging fruits.
if you have a good test suite, bisect_ppx will help you find what code is not executed from your tests. That can point you to some dead utility functions.
as mentioned in another comment, DCE can find some problems as well: dead code, but also optional arguments that are always or never passed.
I’ll have a look at that, but most of the dead code is code not being used between modules. I’m almost certain that most of the code in question is unused but I’m not sure how to find all of it easily. I’ll have a look at the LexFi tool though.