Learn how to install OCaml locally to solve Exercism's exercises on your own machine
To work on the exercises, you will need these pieces of software:
OPAM, the OCaml Package manager
See Real World Ocaml, 2nd Ed.: Installation Instructions
for how to install and configure OPAM for your operating system.
The OCaml compiler
See a list of available versions:
opam switch
If you already have a switch for OCaml 5.1, either load that by running opam switch <switch-name>, or create a new switch by running:
opam switch create exercism 5.4.0
The name exercism here is optional, but naming your switches is a good practice.
Install extended standard libraries and test libraries
Run the following to install the dependencies required by this track:
opam install base core_kernel ounit qcheck
Some exercises use only the OCaml standard library, and some use the extended libraries by Jane Street called Base and Core_kernel. The test library is called OUnit, and some exercises additionally use the QCheck library for property-based tests. Running the above command will install these libraries.
Install and use interactive shell (optional)
A summary of Setting up and using utop:
opam install utop
Create a new file named .ocamlinit in your home directory and add the following lines to it:
#use "topfind";;
#require "base";;
open Base
Install tools in VS Code (optional)
If you use VS Code: