The following instructions may help you in installing Haskell and compiling the WHILE interpreter in linux and MAC os. I have tested them on Ubuntu 8.06 and Leopard 10.5.5 but expect them to also work for other linux distributions and older osx versions.
Step 1: Installing Haskell
The first step is to install a Haskell compiler to your machine (if you don't have one already installed). I would recommend the most recent version of GHC (version 6.8.3).
The following two links provide useful information on how to install GHC in most operating systems. Most of the specific instructions given below follow these two references.
http://book.realworldhaskell.org/read/installing-ghc-and-haskell-libraries.html
http://www.haskell.org/ghc/download_ghc_683.html
MAC OS: You can download the binary installer for Intel processors directly from here. The installation is straightforward as long as you make sure that you have XCode Version 3.0 already installed.
For PowerPC, check this link.
I have checked the above process for Leopard 10.5.5 (intel) but the process should go through for older versions as well (provided that Code 3.0 is installed).
Ubuntu: Download and unzip the following file to get a folder named ghc-6.8.3. Open a terminal within this folder and type:
./configure (if you want to specify an alternative path for installation type ./configure --prefix=my_path)
sudo make install
More detailed instructions can be found in the INSTALL file within the ghc-6.8.3 folder.
Checking your installation: After completing the installation process you might want to check if your haskell compiler works. You can do so by opening a terminal and typing ghci (you should get the prompt Prelude) or by writing a tiny haskell program, compiling it and running it. Check this link for writing, compiling and running haskell programs.
Step 2: Compiling the WHILE interpreter
Download the source code of the interpreter from here (or copy paste it from class'webpage) and rename it (if you want) to whatever name. Let file_name.hs be the name of the file that contains the source code for the WHILE interpreter in your local folder (make sure it has the .hs extension). If you installed ghc version 5.2 or later you don't need to install any packages from the parsec library.
Open a terminal in the folder where the file_name.hs is located and type:
ghc --make file_name.hs
This will give you the executable file_name.
Step 3: Interpreting a WHILE program with the WHILE interpreter
Suppose that while_file.wh is the WHILE program you want to run and let arg1,...,argk be the arguments (input) of your program. There are two ways to .
- Once you have the executable file_name from step 2, you can simply type:
./file_name ‹ while_name.wh arg1 ... argk
- Alternatively, you can execute directly from the source code by typing:
runghc file_name.hs ‹ while_name.wh arg1 ... argk.
In this case you don't need to compile the WHILE interpreter in Step 2.
Further questions can be sent at pmol (at) cse (dot) ucsd (dot) edu