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.

  1. 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)"
    
  2. Set Opam env:
    eval $(opam env)
    

    3.Update Opam repositories:

    opam update
    
  3. Install OCaml base compiler version 4.12.1 (You may use any version >= 4.08 and < 4.15):
    opam switch create 4.12.1
    
  4. Install Jupyter via python’s package manager pip:
    pip install jupyterlab
    
  5. Install ocaml-jupyter package:
    opam install jupyter
    
  6. 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
    
  7. Install OCaml kernel for Jupyter (may need sudo sometimes):
    jupyter kernelspec install --name "ocaml-jupyter-$(opam var switch)" "$(opam var share)/jupyter" 
    
  8. Type jupyter-lab and press enter. A browser page with Jupyter notebook UI should open with an option to create OCaml notebooks.