I want to create a web page where I can execute an OCaml expression
that mentions a prebuilt user-defined library. I find the following
example in the js_of_ocaml/toplevel repository:
https://github.com/ocsigen/js_of_ocaml/tree/master/toplevel/examples/eval
Can I extend this example so that the toplevel is compiled with a
user-defined library? The attached program contains the following
where the first three files are copied from the example in the
js_of_ocaml/toplevel repository.
toplevel/ -- dune
-- eval.ml
-- index.html
-- fac/ -- dune
-- fac.ml
I intend that fac.ml is compiled as a library and I want to use it in
the toplevel. I added "fac" in the libraries stanza of the toplevel
dune file (as in the attached file):
(executables
(names eval)
(libraries
fac
js_of_ocaml-compiler
js_of_ocaml-toplevel)
(link_flags (:standard -linkall))
(preprocess (pps js_of_ocaml-ppx)))
Naturally, fac.ml is compiled and I can use it in the eval.ml, but it
is not visible from the toplevel. I included the following part in
the index.html (as in the attached file):
<script type="text/ocaml" stdout="script3" stderr="script3">
Fac.go 3;;
</script>
<div id="script3"> </div>
but the output says:
File "/dev/fake_stdin", line 2, characters 6-12:
Error: Unbound module Fac
Thank you in advance.
--
Kenichi Asai