I was reading part of Real World OCaml, and the book assumes that one uses Jane Street's Core as one's standard library. I had some issues with setting everything up to use Core in the OCaml toplevel, so I made a small guide here on how to get everything working.
To install Core, you need OPAM, the OCaml package manager. On Debian or Ubuntu, OPAM can be installed using
sudo apt-get install opam. Then, once OPAM has been installed,
opam install core installs Core. The installation may take some time.
Now to use Core in the REPL (i.e.
ocaml), three lines need to be added to the ocamlinit file (
(* ~/.ocamlinit *) #use "topfind" #thread #require "core.top"
#thread line is important. Threads need to be enabled for Core to work. Omission of threads will result in an error ("Error: Reference to undefined global 'Condition'").
After this, on starting the OCaml toplevel, Core will be automatically loaded, and you can start using the functions from Core as usual. If you do not prefer to load Core automatically every time the toplevel is started, just type in those three lines manually in the toplevel. Just remember to terminate each line using double semicolons (e.g.
Silent loading of modules
On starting the toplevel, you may have noticed that the toplevel prints a lot of initialization information that you may not want to see. To silence the loading of modules, change your ocamlinit file to this instead:
(* ~/.ocamlinit *) Sys.interactive := false;; #use "topfind" Sys.interactive := true;; #thread #require "core.top"