You need to install
- OCaml and the qcheck library (use OCaml's package manager OPAM for this)
- an editor (VS Code) to program/edit OCaml code.
The below instructions are adapted from Scott F. Smith's instructions.
-
Install dependencies (git, m4, make, gcc):
sudo apt-get install git m4 make gcc
(on Ubuntu/Debian Linux and Windows Subsystem for Linux)
On Mac: install the three dependencies via macports or homebrew.
-
Install
opam
. See the OPAM install page for instructions. Depending on which method you use you may then need to run some terminal commands. For a recent Ubuntu (and Ubuntu under Windows Subsystem for Linux) you can run:sudo apt-get install unzip sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
For older Ubuntu versions you can run:
sudo add-apt-repository ppa:avsm/ppa sudo apt update sudo apt install opam
-
opam init
to initialize OPAM;opam init --disable-sandboxing
(on Windows)Answer
y
to allowingopam
to add changes to your.profile
. Also answery
to setting up an init-script hook. -
opam switch create 4.11.1
to build OCaml version 4.11.1;If step 2 above finishes with
installed ocaml.4.11.1
you can skip this step. -
eval $(opam env)
to let the shell know where the OPAM files are. -
Once you have the basics installed, run the following command to install additional necessary packages for the class:
opam install qcheck ocamlfind ocamlbuild merlin ocp-indent user-setup utop
On Windows 10: Install MSFT Bash on Windows and afterwards follow the Linux Ubuntu install instructions to get opam. (Windows 10 only for this unfortunately and it may have some incompatibilities).
For older Windows versions:
- Install a virtual machine with Linux as explained here and install OCaml on that or
- Try this installer: https://fdopen.github.io/opam-repository-mingw/installation/
- Last resort: call Jan
To ensure that OCaml and QCheck is properly installed:
-
check that you can use the arrow keys and backspace in the OCaml toplevel if you run the command
utop
-
check that in the
utop
toplevel
#list;;
lists package qcheck
(version: 0.5 or above)
For the ocaml
toplevel you need to write two lines:
#use "topfind";;
#list;;
-
check that you can run QCheck from the toplevel following this screencast and from utop with this screencast
-
check that you can build a QCheck test with ocamlbuild following this screencast
the code for the latter is also available here: https://github.com/jmid/qcheck-example
-
Install VS Code https://code.visualstudio.com/
-
Install the 'OCaml and Reason IDE' extension to get syntax highlighting, type information, etc: from the 'View' menu select 'Extensions, then type in OCaml and this extension will show up; install it. You can also easily run an ocaml shell from within VSCode, just open it up from the 'Terminal' menu and type
ocaml
orutop
into the terminal. -
On Windows 10: install the 'remote WSL' extension as described here:
https://code.visualstudio.com/docs/remote/wsl
This way, VS Code can find
ocamlfind
andocamlmerlin
in the Windows Subsystem for Linux without further configuration.Enabling a
bash
Terminal rather than a 'Powershell' will also let you runocaml
orutop
from within VS Code.
Troubleshooting: If VS Code complains that it cannot find the QCheck
module on either Windows, Mac, or Linux, create a file called .merlin
with the content
PKG qcheck
This way, you inform the language server merlin
of the qcheck
dependency.