CSCI 189 - Assignment 1 Lab

Complete this lab and the Problem set by 5:00pm September 12, 2005

Many of the assignments in this course will require you to use a Mac or a PC, either in a lab on campus or your own.  We will use the Mac lab in 128 Searles for our problem sessions, but all the public labs that are open in the evenings and weekends will also have Haskell available. 

Here's how to start Haskell for editing or running a program on a Mac:

  1. Open the file http://www.bowdoin.edu/~allen/courses/cs189/Asst1/Asst1.lhs from a Web browser.
  2. Save this file as Asst1.lhs (do not append the .txt suffix) on the Desktop.
  3. Open two windows:

    (a) A Unix "Shell" where you can run Haskell programs: select Macintosh HD -> Applications -> Utilities -> Terminal

    (b) A text editor where you can edit Haskell programs: select Macintosh HD -> Applications -> TextEdit

  4. Line up these two window side by side so that you can see them both, as shown below:

  1. Now switch to the TextEdit window and open the file Asst1.lhs by selecting File -> Open -> Asst1.lhs The following text should appear in that window.

> module Asst1 where

--------------------------------------------
Using Haskell to Explore Propositional Logic
Allen Tucker
January 2004
--------------------------------------------

Propositional logic is supported in Haskell, but some of the notation for operators and variables is different from your text. The logical operators for conjunction (^), disjunction (v), and negation (') in your text are written in Haskell as &&, ||, and not, respectively. Moreover, logical variables are written in Haskell in lower case, rather than in upper. So the following logical expression in your text:

P ^ Q v R'

is written in Haskell as

p && q || not R

  1. Now switch to the left-hand window and type the following two lines:
  2. This will start Haskell running and it will look something like this:

 

  1. Finally, type :load Asst1 in the left-hand window. This will prepare you to run commands that are discussed in the text in the right-hand window.

In later assignments, you can follow these same steps to start a Haskell lab session. The rest of the work in the lab will be self-explanatory - just follow the text in the right-hand window. The labs are designed to supplement the Problem set (see below), and in many cases they will provide useful tools for solving problems from your book.

The Problem set for Assignment 1 is a separate document. You may print it on paper or just leave it open on your screen. Your written answers to the questions in the Problem set can be done either by hand or by typing and printing a new document using TextEdit. Later in the semester, there will be advantages to using TextEdit for problem solving.

Saving your work and logging out

When you are finished in the lab, be sure to save your work (e.g., by e-mailing it to yourself).

Finally, be sure to log out from your computer. This will ensure that your work will not be accessed by someone else who uses that computer after you leave.

Running Haskell on a Windows Machine

Completing the above steps on a PC is almost identical, except for the following:

Downloading Haskell to run on your own Mac or Windows machine

You may download and install a free copy of Haskell on your own computer by visiting the Web site http://www.haskell.org/hugs/. The Haskell home page http://www.haskell.org is a source of lots of information, such as tutorials and other goodies. You may want to visit this page during the semester, but for the time being you should not need additional resources.