Template Haskell

This web page serves to summarise the state of play vis-a-vis Template Haskell.

If you'd like to help with any aspect of the implementation, please yell.

What is Template Haskell?

Template Haskell is an extension to Haskell 98 that allows you to do type-safe compile-time meta-programming, with Haskell both as the manipulating language and the language being manipulated.

Intuitively Template Haskell provides new language features that allow us to convert back and forth between concrete syntax, i.e. what you would type when you write normal Haskell code, and abstract syntax trees. These abstract syntax trees are represented using Haskell datatypes and, at compile time, they can be manipulated by Haskell code. This allows you to reify (convert from concrete syntax to an abstract syntax tree) some code, transform it and splice it back in (convert back again), or even to produce completely new code and splice that in, while the compiler is compiling your module.

For more details see the papers that have been written on it.

Mailing list and wiki page

There is a Template Haskell mailing list. The archives are available. There is also a page in the Haskell wiki on Template Haskell.

Implementations

At present there is only one implementation, in GHC. It has now been released as part of GHC 6.0, but the interface and design is still experimental so be prepared to have to rewrite code for future releases! It is documented as part of the user's guide.

Since the 6.0 release some changes have been made to the implementation in CVS. The key ones are described in a mail the the mailing list. Details of more dramatic (as yet unimplemented) changes to the design will appear shortly.

Not all of even the original design has been implemented yet. The known issues are:

If you find yourself needing any of the above then please let us know as it helps focus effort in the right direction.

Examples

Tarball of a few multi-stage programming examples ported from MetaOCaml.

People

Here is a list fo the people using Template Haskell and a quick overview of what they are doing with it. If you want to be added then drop me a line.

Gabriel Dos Reis <gdr@integrable-solutions.net>

I'm using Template Haskell for exploring the design space of generic programming and programming languages and applications to scientific computations. My background is mostly C++-template grounded; however, I'm fairly fluent in functional languages, and interested in their implementations.

At the last ACCU conference, I attended Simon's talk on template metaprogramming with Haskell – which I appreciated very much.

Ian Lynagh <igloo@earth.li>

For my DPhil I will be focussing on working with Template Haskell. As such, you will find uses of it scattered throughout my work. I have also written a couple of papers on it; in particular, Template Haskell: A Report From The Field provides a good summary on my work with Template Haskell to date.

Dmitry Malenko <maldim@gmx.net>

As part of my research (though it can become a main goal) I want to use Template Haskell to implement compile-time program transformation. The idea is to create an entity that might be called "compile-time module" to allow one to express "idea" of the algorithm. That is if one came up with an idea of how to improve algorithm he is able code it for further reuse.

Sean Seefried <sseefried@cse.unsw.edu.au>

I am interested in the application of Template Haskell and meta-programming in general as a means to implement Domain Specific Languages. For more information see Template Haskell for EDSLs.

Papers

This is a list of all the papers on Template Haskell of which I am aware in approximately chronological order. For each paper is a local copy, to try to avoid dead links, along with its BiBTeX entry; you can also get the latest BiBTeX entries for all papers in a single file.

If you have written a paper on Template Haskell that isn't listed here then please let me know where I can find it along with a .bib file (please try to make it as complete as possible).

There is a more detailed page that also includes the abstracts of each paper which you may find helpful if browsing.


Valid XHTML 1.0!

Last updated 2 June 2003.

Ian Lynagh - <igloo@earth.li>