Let’s get up and running with OCaml and VS Code on a Mac.
If you do not have Brew installed yet, then here is the one-liner you need.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install ocaml
Or, if it’s already installed, we can upgrade ot the latest
brew upgrade ocaml
As of this time of writing, we are running
The OCaml toplevel, version 4.10.0
brew install opam opam init
Merlin provides services such as autocompletion to IDEs such as VSCode.
opam install merlin
opam install ocp-indent
opam install utop
To ensure opam is working as expected, you will want to add the following
to you bash profile (many names such as
eval $(opam env)
If you open a new
Terminal window, you should be able to run
Follow the installation instructions or you can run the script below.
If you don’t have
wget, then install it using brew
brew install wget
Now we can install VSCode.
cd /tmp wget https://go.microsoft.com/fwlink/?LinkID=620882 -O VSCode-darwin-stable.zip && \ unzip VSCode-darwin-stable.zip && \ mv "Visual Studio Code.app" /Applications/ # if this fails, run as `sudo ...`
To be able to run
code from Terminal, open up Visual Code.
And then install the command line tools
We are going to use the OCaml and Reason IDE extension which can be installed directly from VS Code.
And search for
OCaml and Reason IDE.
If everything ran as expected (which is always does), then you should now have a nice IDE for OCaml within VS Code.