[Haskell-cafe] Learning about haskell compilers

Bernard Pope bjpop at csse.unimelb.edu.au
Tue Dec 20 23:58:48 EST 2005


On Tue, 2005-12-20 at 16:58 -0800, John Meacham wrote:
> On Tue, Dec 20, 2005 at 10:36:36AM -0600, Creighton Hogg wrote:
> > I was wondering where I should get started in learing about 
> > how to implement a haskell compiler?

Warning: a whole Haskell compiler is a LOT of work.

Nonetheless there are examples of mostly-single-person compilers and
interpreters out there, so it is possible to do one on your own. Though
I don't think reading their source code is necessarily the best way to
get started. 

I agree with what John said, especially this:

> there are various other abstract machines out there, the Lazy Virtual
> Machine used by Helium described in Daan Leijen's Phd thesis is quite
> interesting, and might make a better first target than G-machine code.

If you want to write a compiler,
targeting LVM is (I believe) the easiest way to get something working.
You could get the source code for hatchet from him to give you a front
end.

Another approach is to write a simple interpreter for a small functional
language and add features in bit-by-bit, as your enthusiasm dictates.
That way, you get the satisfaction of having something work early on. If
you write a compiler it might take weeks or months before it does
anything interesting. Then you can custom build your language with
whatever features take your fancy. For instance you can add a better
record system, or play with meta-programming facilities. I started a
little project like this a while ago, called baskell, which you can get
from here:

   http://www.cs.mu.oz.au/~bjpop/code.html

It has a rudimentary type checker, and a little REPL interface. Feel
free to hack it to pieces.

Cheers,
Bernie.



More information about the Haskell-Cafe mailing list