Want to keep learning?

This content is taken from the The University of Glasgow's online course, Functional Programming in Haskell: Supercharge Your Coding. Join the course to learn more.
2.9

The University of Glasgow

Running ghc in a terminal

GHC stands for the ‘Glasgow Haskell Compiler’. This is actually a set of components that allow you to execute Haskell programs on your local machine.

GHC works on Windows, Mac and Linux - although you will need to follow different instructions below for each operating system. Sadly, it does not currently run on mobile devices. There are alternative systems available, like Raskell for iOS.

The two bundled distributions of GHC are the Haskell Platform and Stack. We give instructions for installing the Haskell Platform below, since this is what we use. However many people prefer Stack. Perhaps it’s best to consult the comments section to see what other learners are saying, then make your choice.

Windows

Download the installation program and follow the instructions. If you have a recent Windows version (7 or later) you will probably use the 64-bit Haskell. If you have an earlier Windows, you might need the 32-bit version.

Mac OS X

Download the installation program and follow the instructions. You can also use MacPorts or build from source if you are feeling more adventurous.

Linux

Follow the instructions for your distro. Most common distros have haskell-platform as a package in their package managers. You could also build from source if you are feeling more adventurous.

How do I know it works?

You will need to open a terminal (cmd.exe on Windows, terminal on Mac OS, xterm on Linux) and type in ghci then press enter. If you see the prompt as in the screenshot above, then everything is ok. Type :help then press enter for an overview of the available commands; type :quit then press enter to finish ghci.

What if it doesn’t work?

Check the comments below. If you seem to be having a different problem, then post your own comment below and we will get back to you as soon as possible.