Latest update Sep 28, 2004.

To avoid spam, all mail addresses on this page have the "@" replaced by "#".

Getting started

Starting Hugs

We will be using Hugs for Windows. To run it, simply click the Start button and then click on Hugs 98, which you will find under Programs/Hugs. This will open the following window:

To the left, you have a menu with buttons for the most common tasks. In the main window, you can see the prompt, the Prelude> string in green; this is where you enter your commands. You can also enter and evaluate simple expressions.

Enter the command :? and you will get a list of all legal commands. The one you will use the most is the :load <filenames> command, which loads the modules in the specified files into the system. The :reload command reloads the latest loaded module(s). This is all you have to know about Hugs to get started.

There is also a version of Hugs for Windows called "winhugs", which provides a sligthly more convenient user interface, with some buttons for commonly used commands. It does not appear in the main menu (Start button), but can be found under C:\Program\Hugs98 (blue icon with white dots). You can easily make a link ("genväg") to it and put on the desktop.

Starting Emacs

You can use any text editor you like to write the Haskell programs. We recommend the Emacs text editor. As with Hugs, you'll find it on the start menu under Programs/Emacs. Click on Emacs and the following window will appear:

In Emacs you enter your text, in this case the Haskell program your writing, into a buffer. You save the buffer to a file, which then can be loaded into Hugs.

Useful commands

Emacs is a very advanced and powerful editor but there are only a few commands that you really need to know:

Open File - click on the File menu and choose Open File.... Alternatively you can type the command C-x C-f, the "C-" part means that you should hold down the Ctrl-button, so you type this command by holding down the Ctrl-button while pressing the first the letter x and then f.

At he bottom of the screen you have the minibuffer, which will look like the following picture when you give the "Open File" command.

By default, emacs will assume that the file to open resides in its own directory, which typically is C:\Program Files\Emacs\bin/. Erase this path and type the search path and filename of the file you want to create. Remember that files with Haskell code should have the suffix .hs.

All open buffers are listed under the Buffers menu. You switch between them by simply clicking on them in the list.

Save Buffer (or C-x C-s). This command saves the buffer to the file that you specified when you opened the buffer. If you want to save the buffer to another file, you should use the Save Buffer As... (or C-x C-w) command. Both commands are found under the Files menu.

Kill Current Buffer (or C-x k). This command closes the active buffer. It is also found under the Files menu. If you have modified the buffer since the last save, Emacs will warn you about this and ask if you still want to kill the buffer.

Edit. Emacs has a number of commands for editing text. We mention the most important ones here. You select text in the usual way by holding down the left mouse button and marking the text. You’ll find commands for copying, cutting, and pasting under the Edit menu (selected text is actually automatically copied). The C-k command is also useful. This command deletes everything from the marker to the end of the line.

Those are the commands that you will use the most. You will find manuals and tutorials under the Help menu if you want to learn more.

An Alternative Editor

In case you don't want to use emacs: there is decent editor on the lab computer systems named med. Compared to notepad, it's really good. You can find it in the start menu. It is available for free download, in case you want to install it at home.


Björn Lisper
bjorn.lisper#mdh.se