For this course, you will need:
- GHC, a Haskell compiler that comes with ghci, an interactive REPL (The course should work for ghc-9.2 or later. Some of the compiler messages in the videos may deviate from the ones you are seeing depending on compiler version. If you are experiencing any problems with the course materials or examples not working for more recent compiler versions, please let us know.)
- cabal-install, a package manager for Haskell,
- a text editor suitable for coding (recommendation is to use Visual Studio Code, but others such as (neo)vim or emacs will do if preferred),
- optionally (but recommended) HLS (Haskell Language Server) for an improved editing experience.
In principle, you can use Linux, MacOS or Windows for this course. Haskell support on Windows is a bit worse compared to the other platforms, so if you have a choice, use Linux or MacOS, but all three should work.
0–1 Setting up GHC and cabal-install
The recommended way is to use ghcup
.
If you run the command shown on the ghcup homepage, ghcup will install itself as a tool, and it will also install ghc, and cabal-install, and HLS.
You may need to install additional operating system packages for GHC to work via your system package manager. If that happens, you can just re-start ghcup installation.
During the installation process, the tool will also ask you whether you want to install
HLS (haskell-language-server
) and whether to install stack
. For the purposes of this
course, we suggest to answer “yes” to haskell-language-server
and “no” to stack
, although
answering “yes” in all cases is also a safe choice.
The ghcup tool will install things to the .ghcup/bin
subdirectory of your home directory,
and usually offers to add this to your PATH
automatically. However, this usually requires
starting a new terminal session to take effect. If auto-adding the directory to your PATH
does not work, you will have to edit your configuration manually to add it.
If successful, you can proceed to testing your installation as explained below.
0–2 Testing your Haskell installation
A basic test can be performed by opening a command line and typing ghci
.
You should get output like this:
GHCi, version 9.8.2: https://www.haskell.org/ghc/ :? for help
ghci>
Then if you type a simple Haskell expression, such as
product [1..50]
you should get the result printed. And you can leave ghci
by typing :q
. So the full
interaction should look like this:
GHCi, version 9.8.2: https://www.haskell.org/ghc/ :? for help
ghci> product [1..50]
30414093201713378043612608166064768844377641568960512000000000000
ghci> :q
Leaving GHCi.
0–3 Setting up vscode (or another editor)
If in doubt, we suggest to use Visual Studio Code as an editor. The homepage contains instructions on how to install it for your platform.
Once installed, you can set up additional support for Haskell by going to File -> Preferences -> Extensions
,
search for the extension called plainly “Haskell”, and install that.
If you want to use another editor, you will probably also need to perform additional steps to set it up to use Haskell Language Server. The documentation of HLS contains some info on how to do that for a number of other popular editors.
Continue this course
Next: Part 1: Introduction.