How to make dune watch some files (for possible dependency incompatibilities) but not compile them

In my project I have certain .ml files which I call “used not compiled”, i.e. I load them using #use (or copy-paste a small part of them) into the terminal but I don’t compile them.

Such is the case of one big “archive” file consisting of (about a hundred, at the time of writing this) unrelated biolerplate code snippets which I don’t consider reusable enough to put in a new module, but which I still consider worth keeping somewhere.
Such is also the case of some experimental projects in which there are several distinct parts each involving some heavy computation, and for which the best way to develop is by copy-pasting selected parts of one big master-file into the terminal as needed (rather than systematically putting the parts into heavy modules which are recompiled very frequently, causing recompilation times to increase noticeably and painfully).

On one hand, I don’t want those files to be recompiled each time by dune (as they would slow down the batch recompilation process) but on the other hand I also want dune to keep track of them à la merlin, so that when a very minor small change the compiled part in my homemade library creates an incompatibility with one of this files, I am warned and can fix the incompatibility immediately.

Are there dune options/field dealing with this kind of situation ?

Do you use dune watch mode -w ? Is that not fast enough ? Do you use the @check alias ?

If not, for the first case, you could also add a level to your directory hierarchy, with your “use” .ml files on one side (in a snippets directory or whatever), and the library code in another (src).
Then after an initial dune build, just run dune build @src/check -w for instance, I think that should be enough to keep merlin working in your snippets files.
(If you want to keep your hierarchy flatter, you could add an alias that builds several directories)

For your second case, I don’t understand what you’re saying well enough, it seems a weird workflow to me… Again the @check alias seems useful there.

1 Like