The version of GHC used in these instructions is GHC 8.6.5. You will need to install GHC on your machine to compile Haskell code, and VSCode, the editor we will use in the labs.

There is an OS-specific section to install GHC and VSCode for each each operating system:

Windows 10

These instructions have been tested on Windows 10.

If you have previously installed an old version of the Haskell Platform, uninstall it before proceeding with these instructions.

Uninstall instructions (only if you have previously installed Haskell)

  1. Open the “Add or Remove Programs” by searching in the start menu.
  2. Find “Haskell Platform 8.x.x” and “Haskell Stack” and click uninstall on both.
  3. Go to the Start menu and type %APPDATA%.
  4. Click on the first option, and delete the “Cabal” folder using the file browser.

Chocolatey

Chocolatey is a package manager for Windows. We will use it to install GHC and VSCode.

  1. Visit https://chocolatey.org/install and follow the instructions. You will need to open the Windows Powershell application as administrator; right-click on the icon in the start menu to do this.
    2-windows
  2. Run choco to check that chocolatey is working.
    4-windows
  3. Run choco install -y msys2 to install some other tools needed to build certain haskell libraries.
  4. Open an MSYS terminal by running C:\tools\msys64\msys2.exe and then run pacman -Syuu within that window. Close the MSYS window when it finishes.
    5-windows
    6-windows
  5. Run choco install -y ghc --version 8.6.5 to install GHC. 7-windows
  6. Run choco install -y vscode to install the VSCode editor.
  7. Close the powershell window.

GHC Setup

  1. Open a Command Prompt by typing cmd.exe in the start menu.
  2. Run cabal v2-update. This will update the list of haskell packages your system knows about.
  3. Run cabal v2-install --install-method=copy ghcid. This installs ghcid — a tool that automatically reloads code when you save, making it easier to detect and fix errors.
  4. Run cabal v2-install --install-method=copy doctest 8-windows

VSCode Setup

  1. Launch VSCode.
  2. Install Haskell support. Select “File > Preferences > Extensions”, search for haskell and install the “Haskell Syntax Highlighting” and “haskell-ghcid” extensions by clicking the green Install buttons.
    9-mac
  3. In the bottom left, click on the cog icon, then click “Settings”. Change the autosave setting from “off” to “afterDelay” using the dropdown box.
    6-ubuntu
    7-ubuntu

MacOS

These instructions have been tested on Mojave 10.14.6 and Catalina 10.15.3.

If you have previously installed the Haskell Platform on your Mac, uninstall it before proceeding with these instructions.

Uninstall instructions (only if you have previously installed Haskell)

  1. Open a Terminal.
  2. Run sudo uninstall-hs all --remove, followed by entering your computer’s account password.
  3. Run rm -rf $HOME/.cabal.
  4. Run rm -rf ~/.ghcup/*.

GHC

  1. Install the command-line developer tools from a terminal by typing xcode-select --install, and then click agree. This may take a few minutes.
    1-mac
    2-mac
  2. Run the ghcup installer from a terminal by typing curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh. You will need to press enter a couple times when prompted. This may take a few minutes. It may ask if you want to update your shell configuration — type YES and then press enter.
    4-mac
  3. Run ghcup install 8.6.5 and then ghcup set 8.6.5
  4. Close the terminal and open a new one. Check that GHC is properly installed by running ghc --version and checking that it says The Glorious Glasgow Haskell Compilation System, version 8.6.5.
    5-mac

VSCode

  1. Go to https://code.visualstudio.com/download and select the Mac option.
  2. Double click the archive to extract the VSCode application.
  3. Drag the VSCode application into your Applications folder.
  4. Go to your Applications folder, and run VSCode by right clicking and selecting Open. You should only need to do this the first time - in future you can open it using the regular Application menu.
    7-mac

GHC Setup

  1. Open a Terminal.
  2. Run cabal v2-update. This will update the list of haskell packages your system knows about.
    8-mac
  3. Run cabal v2-install ghcid. This installs ghcid — a tool that automatically reloads code when you save, making it easier to detect and fix errors.

VSCode Setup

  1. Launch VSCode.
  2. Install Haskell support. Select “Code > Preferences > Extensions” menu, search for haskell and install the “Haskell Syntax Highlighting” and “haskell-ghcid”` extensions by clicking the green “Install” buttons. 9-mac
  3. In the bottom left, click on the cog icon, then click Settings. Then change the autosave setting from “off” to “afterDelay” using the dropdown box.
    6-ubuntu
    7-ubuntu

Linux Ubuntu

If you have previously installed the Haskell Platform on your computer, uninstall it before proceeding with these instructions.

Uninstall instructions (only if you have previously installed Haskell)

  1. Open a Terminal.
  2. Run sudo apt-get remove --purge ghc-8.4.4 cabal-install happy.
  3. Run rm -rf ~/.ghc ~/.cabal.
  4. Close the Terminal.

GHC

We will install ghcup, which lets us select and install specific GHC versions, and then install some tools which we will need in the course.

  1. Open a Terminal
  2. Install ghcup dependencies. Run sudo apt-get install -y build-essential curl git libgmp-dev libffi-dev libncurses-dev libtinfo5 zlib1g-dev
    2-ubuntu
  3. Run the ghcup installer from a terminal by running curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh. You will need to press enter a couple times when prompted. This may take a few minutes. It may ask if you want to update your shell configuration — type YES and then press enter.
    1-ubuntu
  4. Run ghcup install 8.6.5 and then ghcup set 8.6.5
  5. Close the terminal and open a new one. Check that GHC is properly installed by running ghc --version and checking that it says The Glorious Glasgow Haskell Compilation System, version 8.6.5.
    5-mac

VSCode

  1. Go to https://code.visualstudio.com/download and select the appropriate linux option.

GHC Setup

  1. Open a Terminal.
  2. Run cabal v2-update. This will update the list of haskell packages your system knows about.
  3. Run cabal v2-install ghcid. This installs ghcid — a tool that automatically reloads code when you save, making it easier to detect and fix errors.

VSCode Setup

  1. Launch VSCode.
  2. Install Haskell support. Select “File > Preferences > Extensions”, search for haskell and install the “Haskell Syntax Highlighting” and “haskell-ghcid” extensions by clicking the green “Install” buttons.
    9-mac
  3. In the bottom left, click on the cog icon, then click Settings. Then change the autosave setting from “off” to “afterDelay” using the dropdown box.
    6-ubuntu
    7-ubuntu

Updated:    02 Feb 2021 / Responsible Officer:    Director, RSCS / Page Contact:    Course Convenor