utop execution of multiple OCaml files

Kenichi Asai <[email protected]> Fri, 15 Aug 2025 09:50:29 +0900
Newsgroups gmane.comp.lang.caml.inria
Message-ID <[email protected]>
Suppose I have a.ml that uses definitions in b.ml (and possibly more).
To compile these files, all I need to do is to prepare a dune file
that mentions only the main file: (executable (name a)), and type
"dune build".

But before I compile the whole program, I often want to play with
functions in a.ml using OCaml toplevel, like utop.  If b.ml were
registered as a library, I could do it by "dune utop ." and then "#use
a.ml".  But to do so, I need to create a directory for the library and
create another dune file for it.

Is there a way to load all the modules into utop, just as simple as
typing "dune build" for the compilation case?

Perhaps, there is a tool to analyze the dependency and produce a list
of commands like the following?

#mod_use "b.ml";;
#mod_use "a.ml";;

-- 
Kenichi Asai