OCaml Quickstart

Posted on | 127 words | ~1 min
Programming OCaml vim editor

OCaml is a great language. However, the tooling for newbies is kinda confusing. Here’s a guide to setup a working OCaml development environment in neovim on MacOS.

Install opam

$ brew install opam

Install ocaml 4.09.0

$ opam switch create 4.09.0 4.09.0
# follow the instructions to setup bash env

Install utop(REPL) and dune(build system)

$ opam install utop dune

Setup editor

You need to install all dependencies (with dune) and build it once to get a working LSP.

Build a project

Let’s test our environment on an existing project.

$ git clone git@github.com:inhabitedtype/httpaf.git
$ cd httpaf

# install dependencies
$ opam pin add -n httpaf .
$ opam install --deps-only httpaf

# run tests
$ dune runtest