Notes about getting and using GHCi

(written Fall 2014)

There's basically three steps:

Things will go a bit differently depending on which OS you're using. If you're not experienced with using a Linux-style terminal, Windows is probably the easiest OS to use. If you like using the terminal, Linux and Mac OS are both a bit nicer than Windows. Installation is a slight pain in Mac OS, but not difficult.

1: Download the software

Visit www.haskell.org and download The Haskell Platform for your operating system.

2: Install the software

Windows

Open the installer that you downloaded and click through. You can tweak the settings if you understand any of them, or just accept all the defaults.

Mac OS

You'll need to follow directions on the download page to install some development tools. You can check your version of OS X by choosing "About this Mac" from the Apple menu. Both Xcode 3.2 (for 10.6) and the standalone "Command Line Tools for Xcode" can be downloaded for free from Apple at their developer site. They require you to register your AppleID (create one if you don't have one) and answer some bogus questions on their website before you download. But the downloads will be free.

After you get the developer tools, run the haskell installer that you downloaded and click through it.

Linux

On Ubuntu there is a package called "ghc" in the standard list of packages to install. From the terminal this should do it:

sudo apt-get install ghc

For other major Linux distributions it works similarly- follow links from the haskell download page to see the packages for your system.

3: Get a good text editor

Generally you can use any text editor you like to write your programs. You should not try to use a full-featured word processor (like Microsoft Word). An editor designed for writing computer code will be best. Here's some suggestions if you don't already have a favorite.

Windows

A good free code editor for Windows is Notepad++, which will color your code nicely when you're writing in Haskell.

Mac OS

A good free code editor for MacOS is Textmate 2 (now in alpha, but works great), which will color your code nicely when you're writing in Haskell.

Linux

Emacs and vim are the standard code editors for Linux, and both can be configured to color up Haskell code nicely.

4: Using GHCi

Windows

The simplest way to use GHCi in Windows is by running the program "WinGHCi" which will appear in the Haskell directory that gets created during installation. From WinGHCi you can load your code files using the menus or by clicking the buttons at the top.

Mac OS & Linux

On Mac OS & Linux, you will run GHCi from the terminal. In Mac OS, the terminal is an Application found in "Utilities" folder inside the "Applications" folder. There are lots of complicated and great things you can do with the terminal, but we won't need to do anything fancy. If you want, you can find lots of guides online. The Mac OS terminal engine is called "bash", which is exactly the same terminal that is typically used in Linux. So any guide for using the linux terminal will work exactly the same in Mac OS, and vice-versa.

The two terminal commands you'll need to use are "ls" and "cd". When you launch the terminal you'll start in your home user folder (a folder is also called a "directory"). Type "ls" and hit return to see a listing of what's in that folder. Use "cd" to change directory. So if you have a folder called "haskell" inside your home folder, type "cd haskell" to switch into that directory. You can press Tab after typing part of a folder name to complete it.

After launching the terminal use "cd" to switch to the directory where your haskell programs are. Once you get to that directory, type "ghci" to launch GHCi. Inside GHCi, load your files using ":l". So if you have a file called "project1.hs", load it into GHCi by typing ":l project1.hs" inside GHCi.