wiki:TemplateHaskell/UsingHaskellSrcExts

Using haskell-src-exts

This page describes a way to "join up" the haskell-src-exts library with Template Haskell, to avoid senseless duplication of effort.

Motivation

It’s stupid, stupid to have both the large Language.Haskell.TH data types for Haskell (in the template-haskell package) and the large Language.Haskell.Exts data types for Haskell (in the haskell-src-exts package).

  • The duplication does not serve our users well. Sometimes they even need to grapple with BOTH data types in the same probram, and We even have a package that converts from one to the other!
  • The duplication does not serve use as developers well. We are duplicating some pretty serious effort on data type design, pretty printer, analysis, etc etc.

Proposal

The proposal is simple: we re-build the template-haskell library to sit on top of haskell-src-exts, using all the latter's data types to represent Haskell syntax. We would do this in collaboration with Niklas Broberg, the author of haskell-src-exts.

Issues

  • There are a few bits in the TH data type that specifically support Template Haskell, including
    • The Nam type (reconciliation needed here)
    • The Q monad and result types for reify (no equivalent in haskell-src-exts)

I think we can solve all this with some negotiation, but I guess it is just possible that there is some major technical obstacle.

  • The massive question is the disruptive effect on existing TH users. Changing all the data types will be a Real Pain for them. But the long term benefits seem quite compelling. We’d need to make a clear blog post/email etc to advertise and seek feedback.

One possibility is to support BOTH for a while (deprecating the existing data types). Perhaps by having two package (old and new). Initially “old” is deprecated but is the package you get by default. But “new” is available, and the same GHC can deal with its data types. I think this would be possible, with some work.

Last modified 18 months ago Last modified on Oct 10, 2012 1:50:23 PM