CS_191 Functional Programming

Working with GHCi in the Linux lab 217

  1. Open a terminal: click on Linux Chameleon > Applications > scroll right (twice) choose Terminal Program or 32-bit Terminal Program.
  2. Create a directory where you will keep your Functional Programming lab work and your coursework. For example, type "mkdir fp1".
    Move to the directory fp1 by typing "cd fp1".
  3. Open the editor emacs by typing "emacs&".
    A new window should pop up.
    Open a file, for example "test.hs" by typing in the new emacs window "C-x-f test.hs" ("C-x-f" means pressing the control key and typing the letters "x" and "f" while keeping the control key pressed down). Alternatively, you may ode the drop down menue.
  4. Enter your first Haskell definitions (don't forget to save your file).
  5. Start ghci by typing "ghci" in the terminal.
    You should get a prompt "Prelude>" indicating that the module Prelude is loaded.
    By typing ":?" you obtain all commands which are available in ghci.
  6. Now, by typing ":load test.hs" you load the script and, if there are no typing errors in your program, you end up with a prompt "Main>".
  7. Finally, you may run your first program by calling your definitions with any inputs.
  8. "lpr test.hs" sends your source code file to the default printer.
Useful emacs commands may be found on the Emacs Reference Card.
Here are the most essential emacs commands.
Useful commands for handling files and directories in Linux are available via the Unix Reference Card.

Working with Hugs in the Windows lab 216

Working under Windows on your PC (if you have installed hugs)

  1. You may start hugs just by calling: Start -> Programs -> Hugs98.
  2. Use any editor to produce a file name.hs with your haskell definitions and store it in the directory hugs98. Then you may proceed as described above, in the linux case.
  3. Alternatively, you may start winhugs (in the directory hugs98) which directly comes with an editor. The files are automatically stored in the right directory.

In case there are any further questions please contact me or one of the program advisors during the lab classes or write an email to u.berger@swan.ac.uk.

Ulrich Berger

  • Back to CS-191
  • Back to Information for Students
  • Back to my Homepage

  • Ulrich Berger, Monika Seisenberger, September, 2006