Install Haskell!

So Dr. Yorgey sent you here to install Haskell on your computer, eh? What a sadistic jerk. Fortunately, installing Haskell is not too difficult these days, and I bet he would be happy to help if you run into any issues!

Windows

If your computer runs Windows, the first thing you will want to do is install Windows Subsystem for Linux (WSL2), if you don’t already have it.

  1. Open a command prompt or PowerShell terminal.
  2. At the prompt, type wsl --install.

This will install Windows Subsystem for Linux, which gives you Linux running inside a virtual machine. From now on, you can open a command prompt/PowerShell terminal and type wsl to get a Linux prompt.

Now, at a Linux prompt, type

apt install build-essential curl libffi-dev libffi8 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5

Once that completes, follow the directions below to install ghcup.

Mac OS

On Mac OS, just open a terminal and try to follow the directions below to install ghcup. If you run into errors complaining about a C compiler that is missing or does not work, try installing the XCode command-line tools by typing this command in a terminal:

xcode-select --install

ghcup

ghcup is a convenient tool for managing all the different pieces of a Haskell toolchain (compiler, language server, package manager…).

Follow the directions at the ghcup website to install it. That is, at a command prompt (i.e. a terminal in Mac OS, or a wsl prompt in Windows), enter

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

You can just keep hitting Enter to accept all the defaults.

Once ghcup is installed (you may need to close and re-open the command prompt for the installation to take effect), you can use it to install GHC and HLS, by typing the following two lines at a command prompt:

ghcup install --set ghc 9.10.1
ghcup install hls

To make sure it worked, try typing ghci at a command prompt. If Haskell starts up, congratulations!