If you are participating in the MAC Introduction to Haskell Workshop and want to install Haskell locally, follow these instructions to install Haskell to save time during the workshop. If you don’t want to install Haskell, there will also be an option to code online which does not require you to install anything.
- Install GHCup:
- Windows:
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl -Minimal } catch { Write-Error $_ }
- macOS/Linux:
export BOOTSTRAP_HASKELL_MINIMAL=1 && curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
- Windows:
-
ghcup install stack --set 3.7.1 ghcup install hls --set 2.11.0.0 stack setup 9.8.4
Install GHCup. GHCup is an installer for Haskell and related tooling.
Tip
If you’re on macOS and have Homebrew, you can also do brew install ghcup instead to install it — just make sure to add ~/.ghcup/bin to your PATH environment variable (e.g. addexport PATH="$HOME/.ghcup/bin:$PATH" to your ~/.basrhc or ~/.zshrc). If you don’t know what this means, don’t worry, just follow the GHCup installation instructions listed below.
To speed up the installation, you can use the following commands instead of the ones from the official installation page:
- Windows:
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl -Minimal } catch { Write-Error $_ }
- macOS/Linux:
export BOOTSTRAP_HASKELL_MINIMAL=1 && curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
The only difference from the official installation script is that we stops GHCup from installing GHC (by adding the -Minimal flag to the Windows install script or by setting the environment variable BOOTSTRAP_HASKELL_MINIMAL=1 on Unix), which can take a long time. Instead, we will install GHC via Stack.
Run these commands:
ghcup install stack --set 3.7.1
ghcup install hls --set 2.11.0.0This installs Stack (the tool we use to build our Haskell code and handle all our dependencies) and HLS (Haskell language server, which you will need to get IDE features). The --set flag also sets the version of Stack and HLS to be used to be the version you just installed.
You can confirm this installation worked by running the ghcup tui command, which should give you a terminal UI that looks something like this:
┌───────────────────────GHCup──────────────────────┐
│ Tool Version Tags │
│──────────────────────────────────────────────────│
│✔✔ GHCup 0.1.50.0 latest,recommended │
│──────────────────────────────────────────────────│
│✔✔ Stack 3.7.1 latest │
│✗ Stack 3.5.1 │
│✗ Stack 3.5.1 recommended │
│✗ Stack 2.15.7 │
│──────────────────────────────────────────────────│
│✔✔ HLS 2.11.0.0 latest │
│✗ HLS 2.10.0.0 recommended │
│✗ HLS 2.9.0.1 latest │
│✗ HLS 2.9.0.0 │
│✗ HLS 2.8.0.0 │
│✗ HLS 2.7.0.0 │
│✗ HLS 2.6.0.0 │
│──────────────────────────────────────────────────│
You can also use this interface instead of the ghcup install commands to install these tools.
- Use the arrow keys or scroll to move up and down
- Press
ito install - Press
sto set that as the version to use - Two ticks (
✔✔) indicates that the version is currently being used - One tick (
✓) indicates that the version has been installed but is not ‘set’ as the current version. - A cross (
✗) indicates that the version has not been installed
Run this command:
stack setup 9.8.4This gets Stack to install GHC v9.8.4, which is the version we will use in the workshop. GHC stands for Glasgow Haskell Compiler and, as the name suggests, is the Haskell compiler.
We won’t normally need to do this, as Stack will install the appropriate version of GHC for us when we build/test/run our Haskell projects. (You also won’t need to run this command for FIT2102.) However, installing GHC can take a long time, so I’m including this command here so that you can get it installed before the MAC workshop.