We will do most of our programming this quarter in OCaml (as well as other languages we create). To install OCaml, we will use OPAM, which is the OCaml ecosystem's package manager.
If you just want to try out a quick idea, you can use the OCaml Playground. You must still install OCaml on your machine, though, because some of our projects will require more complex build setups than those supported by the playground.
The OCaml community is rapidly improving its support for Windows, but things are still in flux. There are three possible ways to do it: via WSL2 (Windows Subsystem for Linux), via "OPAM for Windows" (which uses Cygwin), or via the DkML installer (native Windows). Confusingly, these are all completely separate and unrelated to each other.
If you have Unix experience (e.g., Linux, macOS), or are interested in becoming more familiar with Unix (it's good for you), we recommend using the WSL2 approach.
If you are already familiar with Cygwin, you may like the "OPAM for Windows" approach. Otherwise, we don't recommend this for anyone.
If you like Windows PowerShell or Command Prompt, or if you prefer Windows native solutions, then we recommend the DkML installer.
If none of these approaches work for you, you can try one of the "Alternate approaches" at the bottom of this page.
via WSL2
Install WSL2 if you don't already have it. Instructions
Inside of WSL, install make
and a C compiler via
sudo apt install build-essential
Now follow the Linux, macOS, and WSL instructions below.
"OPAM for Windows" (which uses Cygwin)
This method is only recommended for those with prior experience using Cygwin.
Follow the instructions on the "OPAM for Windows" page.
After installation completes (it takes a while), open the cygwin shell created in the previous step, called something like cygwin64 Terminal, and proceed to Step 2.
via DkML
Follow the instructions under the section called "1. Use the DKML Installer" (and only that section).
Proceed to Step 2.
sudo apt install unzip
.opam init --disable-sandboxing --reinit
xcode-select --install
opam install dune utop ocaml-lsp-server
ocaml-lsp-server
if you don't plan to use an IDE such as VS Code.)The VS Code website provides installers for Windows, Linux, and MacOS.
Note: if you installed OCaml via WSL on Windows, follow these instructions to develop in WSL using VS Code. This will let you edit files in WSL using VS Code and use the terminal in WSL to use your OCaml installation.
Install the OCaml Platform extension to VS Code by clicking the big green button at the top of this page
If you used the Cygwin method ("OCaml on Windows"), then you must open VS Code from inside the Cygwin terminal, not by clicking the VS Code icon.
Every time you want to open VS Code, instead you should open Cygwin terminal and run this command:
/cygdrive/c/Users/Frank\ Smith/AppData/Local/Programs/Microsoft\ VS\ Code/Code.exe
utop
(Completely Optional)utop
like in lectureIn your home directory, create a file .config/utop/init.ml
with these contents:
#utop_prompt_dummy;;
UTop.set_show_box false
utop
In your home directory, create a file .utoprc
with these contents:
profile: light
identifier.foreground: none
module.foreground: x-forestgreen
comment.foreground: x-firebrick
doc.foreground: x-violetred4
constant.foreground: x-darkcyan
keyword.foreground: x-purple
symbol.foreground: x-purple
string.foreground: x-violetred4
char.foreground: x-violetred4
quotation.foreground: x-purple
error.foreground: red
directive.foreground: x-mediumorchid4
parenthesis.background: light-blue
attu
via SSH or VS Code remote connection.