I'm reading an OCaml project recently and I want to put the source files in the utop so I can do some experiments.
Suppose I have two files amodule.ml, bmodule.ml.
bmodule.ml will use functions defined in amodule.ml, for example, bmodule use Amodule.anyfunction() where anyfunction() 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 doesn't work because Amodule is a module name base on the amodule.ml file and the utop don't know these things, I think.
So how I can put these files in the utop without changing the file content?
#use a.ml
executes every statement in a.ml just as if you had typed those statements in the toplevel directly. Thus, you do not get amodule A
defined, so your other file cannot have things likeA.foo
. If you wantmodule A
, you must first byte compile a.ml, and then#load a.cmo
.