What is the namespace of the test0 definition in dune utop . environment, given the following ocaml code with dune build definition:
~/_ocaml_/n01$ cat bin/dune
(executable
(public_name n01)
(name main))
~/_ocaml_/n01$ cat bin/main.ml
let test0 = "World!"
let () = print_endline ("Hello " ^ test0)
When started the code produces expected result:
~/_ocaml_/n01$ dune build
~/_ocaml_/n01$ dune exec n01
Hello World!
I believe that your issue is that you cannot access the
test0variable after launchingdune utop ..If I am not mistaken, your issue stems from the fact that the
dune top <path>command loads libraries and not executable. Thus in your setup, theN01module is not part of the utop environment. The idiomatic solution is to split your source files into a library and a small executable that only contains glue code.