We make use of Jupyter notebooks with OCaml kernel in this course. Following installation instructions should work on Unix-based systems (Linux and Mac) and Windows with WSL installed.
- Opam is the official package manager for OCaml. You can use Opam to install OCaml. To install opam:
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
- Set Opam env:
eval $(opam env)
3.Update Opam repositories:
opam update
- Install OCaml base compiler version 4.12.1 (You may use any version >= 4.08 and < 4.15):
opam switch create 4.12.1
- Install Jupyter via python’s package manager pip:
pip install jupyterlab
- Install ocaml-jupyter package:
opam install jupyter
- Configure
ocamlinit
:grep topfind ~/.ocamlinit || echo '#use "topfind";;' >> ~/.ocamlinit # For using '#require' directive grep Topfind.log ~/.ocamlinit || echo 'Topfind.log:=ignore;;' >> ~/.ocamlinit # Suppress logging of topfind (recommended but not necessary) ocaml-jupyter-opam-genspec
- Install OCaml kernel for Jupyter (may need
sudo
sometimes):jupyter kernelspec install --name "ocaml-jupyter-$(opam var switch)" "$(opam var share)/jupyter"
- Type
jupyter-lab
and press enter. A browser page with Jupyter notebook UI should open with an option to create OCaml notebooks.