Restricted Template Haskell

Simon Peyton Jones simonpj at
Tue Feb 3 11:44:35 UTC 2015

Greg (and everyone else)

The TH documentation is even more woeful than I realised.  At the very least there should be a section for typed TH and a section for untyped TH in the manual.

If I volunteer to write it, it won’t get done.  I’m in too many inner loops.

But here’s an offer: if someone (or a little group) is willing to play author, I will review and correct. It could be a good way to learn the details!

Ideally it would be good to have a compact specification in the user manual, with more detail on the Haskell wiki (where it’s easier for people to edit/improve).  For the latter there is already a page here<>.

I’d really appreciate help with this.


From: Greg Weber [mailto:greg at]
Sent: 03 February 2015 03:42
To: Simon Peyton Jones
Cc: ghc-devs at; GHC users; David Terei; Maxwell Swadling
Subject: Re: Restricted Template Haskell

I would like to figure out how to improve the state of TTH documentation. The GHC wiki is usually for things that are changing, and the page is written in that future style, so it makes one wonder if all things are finished or if some things remain unfinished. Some "this is how it is" documentation in the user guide would seem more useful now.

But I am not sure if the user guide [1] is even correct because it indicates a type of `Q (TExp a)` where I would expect just `TExp a` from reading the wiki [2].


On Mon, Feb 2, 2015 at 11:31 AM, Greg Weber <greg at<mailto:greg at>> wrote:
Hi Simon,

I am just starting the proposal: gathering interested parties and pointers to related information.
Thanks for the pointer to Typed Template Haskell. I was actually unaware of the extent to which Typed Template Haskell is restricted. I have not seen any usage of Typed Template Haskell in the wild or been able to use it myself unfortunately due to backwards compatibility needs (once the next GHC release is out libraries will start to consider dropping 7.6 support and we will see more usage, although Ubuntu still ships 7.6 by default).
I will study Typed Template Haskell.

Greg Weber

On Mon, Feb 2, 2015 at 9:33 AM, Simon Peyton Jones <simonpj at<mailto:simonpj at>> wrote:
The new TH is already split into two parts<> as I’m sure you know

•         Typed TH is for expressions only, and doesn’t have reify, nor any Q monad.

•         Untyped TH is the wild west

Typed TH may get some of what you want?   Certainly you want to acknowledge the existing split in your own design.

The proposal could do with examples to illustrate what the difficulties are.  What bad things happen in the Q monad?  Can you give examples of reasoning that would be valid in level 1 but not in level 2.  etc.  More precision please!


From: Glasgow-haskell-users [mailto:glasgow-haskell-users-bounces at<mailto:glasgow-haskell-users-bounces at>] On Behalf Of Greg Weber
Sent: 30 January 2015 23:39
To: ghc-devs at<mailto:ghc-devs at>; GHC users
Cc: David Terei; Maxwell Swadling
Subject: Restricted Template Haskell

Hello GHC friends!

I am starting up a proposal for variants of Template Haskell that restrict what operations are available. The goal is to make TH easier for users to reason about and to allow for an easier compilation story.

Here is the proposal page:

Right now the proposal does not have any details and the goal is to write out a clear specification.
If this sounds interesting to you, let me know or leave some feedback on the wiki.

Greg Weber

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Glasgow-haskell-users mailing list