Let’s take the very daily situation of handling a set of OCaml modules (defined on a module per file basis or as modules within a module-file).
Case 1: only OCaml files
I would like to get a fine grain graph of all dependencies between OCaml components.
ocamldep gives all dependencies for a set of modules, in order to know in which order modules must be compiled.
How can I get a fine grain dependencies graph to the level of values (functions) and types?
Case 2: OCaml files referencing various files and directories (libs, static files, etc.)
Same question with OCaml files and referenced non OCaml files.
Last but not least:
how can you handle the referential integrity of values and types name?
e.g. in a basic web design tool, as soon as you modify the name or path of a file (or of piece of code), all pieces of code in all files that reference it are immediately updated.
In an OCaml file, the basic feature would be: if a value name is changed, then update all values that reference it.
First in the current buffer. Then, when the buffer is saved, in all values in all files that were using that value which name was modified (sync without saving could be an option).
This feature could be enabled/disabled, which would require to manually fix lost referential integrity, or to use a tool to find “dead references/links”, or to setup a meta referential that will keep track of references (established, lost) between values/types.
It’s one of my main concern when editing an Ocaml program that becomes large and distributed in many modules. Using the buffer memory or the (risky) multi-edition feature of the editor is not satisfactory. Even if type-safety protects us, this can be very time-consuming to enforce referential integrity that is anyway required by the compiler to do its job.
Is there any tool/package to do or build that when programming in OCaml?
Opam and Dune are obviously handling dependencies to get their job done, but I’m not enough aware of their internals to figure out how I could use them for that, or if it’s feasible.