Installation & Tooling Setup
2.1 opam — the OCaml package manager
Linux / macOS Windows (opam 2.2+ supports Windows natively)
Alternatively use WSL2 and follow the Linux instructions.
bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh)"
opam init -y
eval $(opam env)winget install Git.Git OCaml.opam
opam init -y
(& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }2.2 Switches (isolated compiler environments)
opam switch list-available # compilers you can install
opam switch create 5.3.0 # create a global switch
opam switch create . 5.3.0 # a local switch in the current project (_opam/)
opam switch # list switches
eval $(opam env) # activate in the current shell2.3 Essential developer tools
Basic toplevel (REPL) Enhanced REPL with completion and history
Language server (VS Code, Neovim, Emacs) Editor intelligence engine
opam install dune utop ocaml-lsp-server ocamlformat odoc merlin2.4 Editor setup
VS Code: install the *OCaml Platform* extension (uses ocaml-lsp-server).
Neovim: nvim-lspconfig → ocamllsp.
Emacs: tuareg + merlin or eglot/lsp-mode.
Hovering an expression shows its inferred type — use this constantly while learning.