I'm learning OCaml following the tutorial http://caml.inria.fr/pub/docs/oreilly-book/html/index.html. I'd like to try some examples using list functions of 'core' library. I start ocaml-top (http://www.typerex.org/ocaml-top.html) and get the following error when open 'Core.Std':
# open Core.Std
Characters 0-13:
open Core.Std;;
^^^^^^^^^^^^^
Error: Unbound module Core
The file ~/.ocamlinit contains the following lines (added from Ocaml and Opam: unbound module Core):
(* Added by OPAM. *)
let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
;;
#use "topfind"
#camlp4o
#thread
#require "core"
#require "core.top"
#require "core.syntax"
Executing ocaml from command line works fine (it loads a lot of .cma files on init) and there is no problem opening 'Core.Std'. I can compile the module with:
$ ocamlfind ocamlc -thread -package core calc.ml
I've created my own toplevel linked with 'core', and works fine too:
$ ocamlfind ocamlmktop -o coretop -thread -package core
But ocaml-top can't open 'Core.Std'. Launching ocaml-top with my toplevel doesn't open 'Core.Std'
$ ocaml-top -ocaml /home/thelinuxkitten/coretop
Inserting the contents of ~/.ocamlinit at ocaml-top's prompt
(* Added by OPAM. *)
let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
;;
#use "topfind";;
#camlp4o;;
#thread;;
#require "core";;
#require "core.top";;
#require "core.syntax";;
produces the following output in the evaluation panel:
OCaml version 4.01.0
# let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
# #use "topfind"
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #camlp4o
Camlp4 Parsing version 4.01.0
# #thread
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/dynlink.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/camlp4: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/camlp4/camlp4o.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/threads: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/unix.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/threads/threads.cma: loaded
# #require "core"
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/bigarray.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/bin_prot: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/bin_prot/bin_prot.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/variantslib: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/variantslib/variantslib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/sexplib: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/sexplib/sexplib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/fieldslib: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/fieldslib/fieldslib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_bench: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_bench/pa_bench_lib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/oUnit: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/oUnit/oUnitAdvanced.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/oUnit/oUnit.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_ounit: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_ounit/pa_ounit_lib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/typerep_kernel: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/typerep_kernel/typerep_kernel.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core_kernel: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core_kernel/raise_without_backtrace.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core_kernel/core_kernel.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_test: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_test/pa_test.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core/core.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core/core_top.cma: loaded
# #require "core.top"
# #require "core.syntax"
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/core/core_top.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/type_conv: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/type_conv/pa_type_conv.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/sexplib/pa_sexp_conv.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/fieldslib/pa_fields_conv.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/variantslib/pa_variants_conv.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/comparelib: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/comparelib/comparelib.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/comparelib/pa_compare.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/bin_prot/pa_bin_prot.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/custom_printf: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/custom_printf/pa_custom_printf.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_pipebang: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/pa_pipebang/pa_pipebang.cma: loaded
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/herelib: added to search path
/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/herelib/pa_herelib.cma: loaded
#
I've installed OCaml, core and ocaml-top with OPAM
$ opam config env
CAML_LD_LIBRARY_PATH="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/stublibs:/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/lib/ocaml/stublibs"; export CAML_LD_LIBRARY_PATH;
OPAMROOT="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam"; export OPAMROOT;
PERL5LIB="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/perl5:"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
MANPATH="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/man:/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/man:/usr/local/man:/usr/brlcad/share/man"; export MANPATH;
PATH="/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/.opam/system/bin:/home/thelinuxkitten/ocamlbrew/ocaml-4.01.0/bin:/home/thelinuxkitten/debian/script:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/brlcad/bin"; export PATH;
ocaml-top's web have a simplest documentation. So, my question is: Anyone knowns if ocaml-top can load and open external libs like 'core'?
Thanks
Notice how .ocamlinit
has #use "topfind"
before it issues other directives. That's because topfind
is an ocaml script that adds support for that #require
directives.