User defined annotations for Haskell (Was: [Haskell-cafe] packages and QuickCheck)

Max Bolingbroke batterseapower at
Wed Sep 10 08:56:54 EDT 2008

2008/9/10 Johannes Waldmann <waldmann at>:
>>> Has there ever been a discussion of typed, user-definable,
>>> user-processable source code annotations for Haskell?
>> afair it was on haskell-prime list
> if you can call that a discussion :-)

I had to implement a kind of annotation system for GHC as part of my
Summer of Code project for compiler plugins. You can see a discussion
though I was not aware of that Haskell' ticket.

The system as I have implemented is quite basic: the absolute minimum
I needed for plugins. The syntax is essentially:

{-# ANN foo "I am an annotation!" #-}

Where "I am an annotation" may be replaced with any Typeable value,
and is subject to staging requirements analgous to Template Haskell
(e.g. you may not refer to things in the module being compiled other
than by Template Haskell Name).

As well as values you can annotate types and modules, and annotations
are accessible via the GHC API. See that wiki page for full details.

This system has not yet been merged into GHC (or even code reviewed by
GHC HQ), so if/when it becomes available to end users the design may
have changed drastically.


More information about the Haskell-Cafe mailing list