Use multiple modules in OCaml utop

I am reading an OCaml project recently, and I want to put the source files in utop so that I can do some experiments.
Suppose I have two amodule.ml files , bmodule.ml .
bmodule.ml will use the functions defined in amodule.ml , for example, bmodule use Amodule.anyfunction (), where any function () is defined in amodule.ml .
I want to put both of them in utop:

#directory "/directory contain amodule.ml and bmodule.ml" #use "amodule.ml" #use "bmodule.ml" 

And this does not work, because Amodule is the base of the module name in the amodule.ml file, and, as I think, utop does not know these things. <w> So, how can I put these files in utop without changing the contents of the file?

+7
ocaml ocamlbuild ocamlfind
source share
1 answer

#use a.ml executes each statement in a.ml just as if you typed these statements directly at the top level. This way you are not defining module A , so your other file cannot have things like A.foo . If you want module A , you must first compile a.ml and then #load a.cmo .

+8
source share

All Articles