How to install&use EHC and the tools it requires (on a Windows system)

This is a step-by-step guide to get a working EHC system on your Windows computer. You will get the source and all necessary tools, to be able to experment with and extend EHC yourself. For other operating systems (Linux, MacOS) you can just skip step 1 and 2.

You will need tools from six different sources, so have some patience to install them all. The good news is that you may find the tools useful in different situations as well.

  1. Cygwin: a command line shell
  2. Tortoise: SVN version management client
  3. GHC: Haskell compiler
  4. UUlib: Additional Haskell libraries from Utrecht University
  5. UU-AGC: Attribute Grammar Compiler
  6. EHC: Extensible Haskell Compiler

1. Cygwin: a command line shell

EHC makes use of Unix-style development tools, like make and configure. For being able to use such command line tools without having to go so far as to install Linux, you can use Cygwin: a command line shell which comes with many of the needed development tools.

To install Cygwin, go to the Cygwin website and download the small (250k) installation program. During installation it asks for:

After installation you will have a desktop icon and/or an item in the start menu.

to test whether it works:

1a. Patch Cygwin "make" bug

There is a bug in the Cygwin "make" utility, which exists in version 3.81 and maybe also in version 4. You can download file "make.exe" version 3.80 and copy it to c:\cygwin\bin. to test whether it works:
Type at a Cygwin prompt:
     
make --version
it should reply: "GNU Make 3.80".

2. Tortoise: SVN version management client

The tools in step 4 to 6 are maintained in a collaborative version management system called Subversion, or SVN. You need a Subversion client to download files from a repository. Tortoise offers a graphical user interface to SVN. It integrates in the explorer, so you will hardly notice it exists as a seprate program: you will just notice enhanced explorer behaviour.

Download Tortoise SVN here and install it.

to test whether it works:
Open the file explorer, and rightclick any directory. A context menu Tortoise SVN should be present.

3. GHC: Haskell compiler

The Glasgow Haskell Compiler (GHC) is an industrial-strength Haskell compiler, including many libraries. To install it: to test whether it works:

4. UUlib: Additional Haskell libraries from Utrecht University

Haskell comes with a large number of libraries, but of course we like our own better. Download and install them as follows:

5. UU-AGC: Attribute Grammar Compiler

The Attribute Grammar Compiler is a preprocessor to Haskell that generates recursive tree walks. Input to this preprocessor is a custom description of an attribute grammar.

Download and install it as follows:

6. EHC: Extensible Haskell Compiler

Now you are ready to get our Extensible Haskell Compiler, and soon you'll be extending it yourself.

Download and install it as follows:

Note that there are various versions of the compiler, which correspond to various stages of extension. In the example above, we build version 8 of the compiler, which is a good start because it is the simplest version that has code generation. to test whether it works:
Type the following commands:
     
    cd testgrinc
    ../bin/8/ehc.exe -cexe sum.hs
    sum.exe
This will compile an example program sum (a Haskell program that calculates the sum of the numbers 1 to 10). Because of the -cexe flag, EHC will generate a C file, and compile it with the C compiler gcc that comes with Cygwin. Finally, sum.exe is the compiled program which shows the answer 55 when run.
Alternatively, you can use -cbexe to generate bytecode embedded in an interpreter.