Skip to content

Instantly share code, notes, and snippets.

@cherryblossom000
Last active August 16, 2024 14:14
Show Gist options
  • Save cherryblossom000/9e78310218882425f76a65eba4ce60bb to your computer and use it in GitHub Desktop.
Save cherryblossom000/9e78310218882425f76a65eba4ce60bb to your computer and use it in GitHub Desktop.
Haskell installation instructions

Haskell Installation Instructions

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.

TLDR

  • Install GHCup
  • ghcup install stack --set
    ghcup install hls --set
    stack setup 9.2.8

1. Install GHCup

Install GHCup. GHCup is an installer for Haskell and related tooling.

  • 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 linked above.

2. Install Stack and HLS

Run these commands:

ghcup install stack --set
ghcup install hls --set

This 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.

Optional: ghcup tui

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.30.0   latest,recommended           │
│──────────────────────────────────────────────────│
│✔✔  Stack 3.1.1      latest,recommended           │
│✗   Stack 2.15.7                                  │
│──────────────────────────────────────────────────│
│✗   HLS   2.9.0.1    latest                       │
│✗   HLS   2.9.0.0                                 │
│✗   HLS   2.8.0.0                                 │
│✔✔  HLS   2.7.0.0    recommended                  │
│✗   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 i to install
  • Press s to 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

3. Install GHC

Run this command:

stack setup 9.2.8

This gets Stack to install GHC v9.2.8, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment