The Glasgow Haskell Compiler

Haskell is a non-strict purely-functional programming language, and the Glasgow Haskell Compiler (GHC) is a terrific compiler for it. This page is mainly about GHC, but also has pointers to more info about Haskell and other Haskell implementations.

(Many of the links in this page are to compressed PostScript of published papers that describe the relevant features of GHC in some detail. Those that do have approximate page counts attached).

The Haskell language

Haskell is a non-strict purely-functional programming language. Designed by an international group, it has become a de facto standard. Haskell 1.4 is the latest version (March, 1997), and the Report is available from Yale.

Haskell 1.4 is accompanied by a separate report describing Haskell's libraries. The libraries report is currently (March '97) only in draft form. A tutorial on Haskell is also available.

The previous Haskell Report [160 pages] (version 1.2) was published as a special issue of SIGPLAN Notices (Vol. 27, No. 5, May 1992) along with a tutorial [50 pages] on the Haskell language, version 1.2. The tutorial is also available as a "literate" Haskell program which can be compiled by all the major Haskell compilers.

Goals of the Glasgow Haskell Compiler

The Glasgow Haskell compiler (GHC) [10 pages] is a fully-featured implementation of Haskell, together with a number of useful extensions. GHC is directed at two main groups of users: Execution performance is in the top league for non-strict languages. (Hartel's papers give some independent data points for this claim: "Benchmark1" [1993, 9 pages], "Benchmark2: [1995,6 pages], and "Pseudoknot" [1995,25 pages, draft].) And arbitrary amounts of "versus C" speed can be clawed back, by using GHC language extensions (the "Pseudoknot" paper above gives a good example of this claw-back).

Standard libraries/interfaces

Input/output

GHC provides an extensible, monadic input/output system [10 pages] that fully supports the Haskell 1.4 I/O specification. GHC also includes a Posix "system library", which provides access to POSIX-compliant operating system facilities. For example, you can write a Unix shell in GHC.

Here's a tutorial on monadic I/O [19 pages] by Kevin Hammond and Andy Gordon.

Calling C

GHC provides the ability to call arbitrary in-line C-language code, using the I/O monad to retain referential transparency. (Indeed, the whole of the I/O system is implemented in Haskell using this facility).

Pointers to external objects (malloc'd C structures, say) can be passed to Haskell; these will be explicitly finalised when the Haskell garbage collector discovers they are no longer referenced. For example, we have used this facility when re-using an image-processing library written in C.

Pointers to Haskell structures can be passed to C, provided they are first registered as "stable pointers", so that the garbage collector knows about them.

Graphical user interfaces

Quite a few people have developed X Window System interfaces for Haskell, but they usually buy into the spaghetti event-loop model that is used by most GUI programs. We are now developing, Haggis [15 pages] a more substantial GUI toolkit, based on Concurrent Haskell.

For more details, please consult the Haggis page.

Language extensions

GHC provides a few significant extensions to Haskell:

Parallelism and concurrency

GHC supports both parallel and concurrent programming.

Parallelism

By "parallel" we mean using implicit parallelism to gain performance. Functional programmers have often made claims about parallel execution, but very few (or even none?) non-toy parallel implementations are publicly available. We have been guilty of this as well, but no longer!

GHC supports parallel execution based on a distributed-memory store model. It currently sits on top of PVM, which means it can be made to run on virtually anything; currently we support networks of workstations and Sun Solaris shared-memory multiprocessors.

GranSim simulator

As well as running your programs on a parallel machine, you can also simulate parallel execution on a uniprocessor. The simulator, called GranSim [20 pages], allows you to control a whole variety of parameters, including message latency, and collects more detailed execution profiles than the real parallel implementation does.

GranSim is fully operational, beginning with GHC 0.29. The GranSim Home Page discusses GranSim in more detail and gives examples how to use it. The GranSim User's Guide is also available on-line (PostScript Version).

Concurrency

Some applications are most easily expressed in a programming language that supports concurrency, notably interactive and distributed systems. The goal is not so much performance but rather expressiveness, and the concurrency is absolutely explicit, rather than implicit.

We have made some modest extensions to Haskell to allow it to express this class of explicitly-concurrent applications; we call the resulting language Concurrent Haskell [20 pages], by analogy with Reppy's Concurrent ML.

Profiling

GHC has an effective profiling system [12 pages], that enables you to find out which bits of your program are eating both time and space. Patrick Sansoms's PhD thesis, "Execution profiling for non-strict functional languages" [200 pages], gives the details.

Online documentation

The GHC distribution comes with extensive documentation on both configuring and using the compiler. The documentation is also available on the Web:

GHC internals

Related (and contributed) software

Boring but useful (contacts, etc.)

The general contact for GHC-related stuff is
Simon Peyton Jones,
Department of Computing Science,
Glasgow University,
Glasgow, SCOTLAND
G12 8QQ.
Email: glasgow-haskell-users-request@dcs.gla.ac.uk

Versions and platforms

Version 2.05 is the current release of GHC [July 97]; it is a compiler for Haskell 1.4, and is of "decent beta quality". We also supply GHC version 0.29 [July 96]; it is an up-to-date version of our "old" compiler for Haskell 1.2; it is comparatively solid. Please see the online documentation for full details.

The GHC installation guide gives full porting info about how well GHC is supported on different platforms.

Downloading GHC

GHC is available for download in a couple of ways, the most convenient being way to grab it is via this WWW download page.

If you prefer the more direct route, GHC is also available by anonymous FTP (username: anonymous; password: your e-mail address) is possible from the following sites:

	Site	 Host name

	Chalmers ftp.cs.chalmers.se
        Glasgow	 ftp.dcs.gla.ac.uk
	Yale	 haskell.cs.yale.edu
	Nottingham ftp.cs.nott.ac.uk

	UKUUG	 sunsite.doc.ic.ac.uk
	  (computing/programming/languages/haskell mirrors Glasgow)

In each case, you'll find the directories:

	pub/haskell/report		The Haskell report
	pub/haskell/tutorial		The Hudak/Fasel tutorial
	pub/haskell/glasgow		GHC

Other subdirectories of pub/haskell contain other Haskell compilers. Note: Specialised material related to a specific implementation (e.g., HBC binaries for the Obscuro 1000) may only be at the implementation's "home site".

`Archie' and similar tools may help you find things which are cached closer to you.

Haskell and GHC mailing lists

There is an electronic mailing list to discuss technical issues related to Haskell. To join this list, send your request to majordomo@dcs.gla.ac.uk; the body of the message should be:

    subscribe haskell Your Name <your-email@where.you.are>

There are also implementation-specific mailing lists. In the case of GHC they are:

    glasgow-haskell-users@dcs.gla.ac.uk
    glasgow-haskell-bugs@dcs.gla.ac.uk
The -bugs list is for reporting of and discussion about bugs in GHC. The -users list is for GHC users to chat among themselves (about GHC-related matter).

In each case, to join, send a message to majordomo@dcs.gla.ac.uk; the body of the message should be:

    subscribe glasgow-haskell-<which> Your Name <your-email@where.you.are>

Both mailing lists have on-line archives: glasgow-haskell-users and glasgow-haskell-bugs.

To contact the list administrator, send a message to list-request (eg glasgow-haskell-users-request).

You can find a wad of Haskell-related research starting from the Glasgow Functional Programming Group home page; papers by members of this group are in pub/glasgow-fp, at ftp.dcs.gla.ac.uk.

Lastly, here's a pointer to the competition: other Haskell compilers.

Contributors

Here are the main people working on GHC at present:

And here are some of the other people who have contributed to GHC in the past:


Last modified: Tue 12 Aug 22:37 BST 1997 by sof@dcs.gla.ac.uk