Running Haskell

This page is organized as follows:

  1. Running Haskell on Eustis
  2. Running Haskell on Your Own Machine
  3. Getting Test Output for Homework
  4. Troubleshooting
  5. Advanced Topics

We recommend using the GHC system for this class.

Running Haskell on Eustis

Most students will find it easiest to use their own computer system for class work. However, if you do not have your own computer, you could use the eustis.cs.ucf.edu system.

You can login to your account at eustis.cs.ucf.edu using your NID and NID password to login.

To access Eustis, use an ssh client like putty, which gives you a shell (terminal-like) interface. This works directly on campus. However, from off-campus, you will need a VPN connection to UCF first. For a VPN account and help, go to https://secure.vpn.ucf.edu/ and login there using your NID and NID password. You will then see instructions on how to download the VPN software for your computer. You can then connect via the VPN to the campus network and log in to Eustis using putty.

Starting Haskell

On Eustis, the GHC (Glasgow Haskell Compiler) system is found in /usr/bin/, which should be in your shell's PATH by default. (Thus you shouldn't have to do anything special to set this up.)

To run GHC, simply issue the command ghci at the shell's prompt.

Exiting Haskell

To quit ghci, use the command :quit at the prompt.

Return to top

Running Haskell on Your Own Machine

The GHC (Glasgow Haskell Compiler) platform is most convenient to use on your own computer. It supports the MS Windows, Apple Mac, and Linux operating systems.

Getting Haskell for your Own Machine

The GHC platform can be downloaded to your computer from haskell.org's downloads page (or go to haskell.org and click on the Downloads menu item at the top right). In the list of the three downloads click on Haskell Platform, then from the list of operating systems under "How to get it", click on the link for your computer's operating system. Follow the installation instructions and the prompts from the installer for your operating system.

Hints for Windows Installation

During the installation process on Windows you may have two installation windows active, and if one of them seems to be hung up, find the other one (the one installing Stack) and see if it is waiting for you to click the "Close" button. If so, then click "Close" to make further progress.

If you were running a shell before the installation, then you will need to start a new shell to have the tools in your path.

After the installation is finished, you should have an interface to GHC, on Windows it is called "WinGHCi", in your start menu.

Hints for Mac OS X Installation

The web pages ask you to install "ghcup" first. To do that, copy and paste the displayed command, without the dollar sign that indicates the shell's prompt, into a shell (terminal window). Press enter when prompted to move the installation process along. It will take a while.

To use GHC from the shell, you will need to source ~/.ghcup/env in your ~/.bashrc file or whatever you use to set your PATH variable.

You may see a popup asking you to install the command line development tools if you have not already done that. Accept that installation to continue. You can also execute the command xcode-select --install from a shell to install the XCode command line tools.

During the installation, you will either need to let the installation of ghcup add ~/ghcup/env to your PATH, or edit a source of that file into your ~/.bashrc file so the executables for GHC are in your PATH. After ensuring that the tools are in your PATH, then you will need to start a new shell (terminal window) to have those available. You can run ghci from a new shell.

After the install of ghcup, you should install stack by following the instructions at docs.haskell.org. This should install GHC.

Then you can run Haskell by executing the command ghci from a shell (terminal window). If that doesn't work, then use the command stack ghci in a shell. The first time you do this it will install GHC.

Hints for Linux Installation

If you are running MS Windows, it is best to install GHC directly on windows instead of using a virutal machine to run Linux and installing Haskell there. Haskell will run faster on the native Windows OS.

Follow the instructions for your version of Linux on the Haskell.org downloads page. However, you may need to search in your package manager for the most appropriate installation package. This seemed necessary with the yum package manager on Redhat Linux.

Conclusion

If you find more details about an operating system that you had trouble with, see the course staff. If you fix such a problem yourself, please let us know how you fixed the problem.

Return to top

Getting Test Output for Homeworks

Homework problems require you to capture the output of our testing tool. It is possible to copy and paste from a shell in some systems. If you use a Windows machine, you can use WinGHCi, which is part of the GHC platform, and copy and paste the output from there.

However, another way to do this may be easier, and which is recommended on Mac OS X and Linux, is to use the runhaskell command and direct the output to a file. (The runhaskell command is part of the Haskell distribution, which should be in your PATH.) For example you can execute a command like the following, where you replace WhateverTests.hs with the name of the appropriate testing file.

      runhaskell WhateverTests.hs > whatever-output.txt
    

Then the contents of the output, in whatever-output.txt can be read into a text editor and copied and pasted into the specified place on webcourses for the homework.

Return to top

Troubleshooting

Type Errors

If you get a type error message, look at the source code in the given location and see if you can understand why that code may be wrong (in some cases).

Other Problems

If you are having a problem not described above, or if the solutions listed above are not working for you, you can look at the webcourses discussions, where we often post answers to other people's questions. If none of that help then please don't hesitate to contact the course staff.

Return to top

Advanced Topics

There are a variety of programming environments for Haskell that are described below.

Leksah

Leksah is an IDE that only supports Haskell, and is also written in Haskell.

Haskell Eclipse Plugin

The EclipseFP plugin for Eclipse is good if you like working in Eclipse.

Running Haskell from Visual Studio

There are several ways to run Haskell from within Visual Studio, including using Haskero.

Running Haskell from Within Emacs

To run Haskell from within Emacs, see https://github.com/haskell/haskell-mode#readme. The instructions at http://haskell.github.io/haskell-mode/manual/latest/Installation.html#Installation are somewhat more detailed and helpful. This is what Gary uses in class.

Windows Keystrokes in Emacs

If you like to use the standard Windows keystrokes for cut, paste, and copy, customize Emacs to use CUA-mode by default. (This assumes that you have Emacs version 22 or later. Use the menu "Options", select "Customize Emacs", and from there the select "Top Level Customizations". then select the "Convenience" group by clicking on the "go to group" link, and then go to the Cua group, and click on the "Value Menu" for enabling this customization.

If the above doesn't work, or if you have a version of Emacs previous to 22, put the following in your emacs initialization file, ~/.emacs.el. (The lines that start with a semicolon are comments, and can be omitted.)

(if (< emacs-major-version 22)
  (progn
    ;; Make emacs more like standard windows applications in terms of
    ;; mouse selections (this is similar to pc-select).
    ;; One advantage is this is that it makes Dragon Dictate work with Emacs.
    (require 'cua)
    ;; Make the behavior of emacs on C-c, C-v, C-x, and C-z to be
    ;; just like that of be as in standard window apps, so you can use
    ;; these keys to copy, paste, and select when there is a selection
    ;; active, then uncomment the following.
    (CUA-mode t)
    ;; Make C-c leave the region active, which is what happens under Windows.
    (setq CUA-mode-keep-region-after-copy t)
  )
  ;; The same for emacs version 22 (and hopefully higher...)
  ;; but not for aquamacs, which already has it.
  (if (not (featurep 'aquamacs))
      (progn (cua-mode)
             (setq cua-enable-cua-keys t)
             (setq cua-mode-keep-region-after-copy t)
      )
  )
)

Alternatively, you can use Gary Leavens's .emacs.el file which includes the above lines and several other things. It should be saved into .emacs.el in your home directory. (On Windows you may not have a home directory yet, so pick one. You also have to set HOME in the environment; this is automatic in Unix and hence on Mac OS X, but needs to be done by hand in Windows.)

Making Emacs find your Customization File

On Linux to have emacs find your ~/.emacs.el file you just have to have it in your home directory. On Windows machines, if the emacs is not finding your ~/.emacs.el file, it is because it doesn't know where your home directory is. To do this, you have to set your environment variable HOME to the right directory.

For Vi Users

If you are a vi user, you may want to use viper-mode in emacs to get the vi keystrokes and still use all the wonderful features of Emacs. To do this, put the following in your .emacs.el file:

(viper-mode)

Return to top

Last modified Tuesday, September 17, 2019.

This web page is for COP 4020 at the University of Central Florida. The details of this course are subject to change as experience dictates. You will be informed of any changes. Please direct any comments or questions to Gary T. Leavens at Leavens@ucf.edu. Some of the policies and web pages for this course are quoted or adapted from other courses I have taught, in partciular, Com S 342.