[Template-haskell] RE: Documentation Template Haskell

Simon Peyton-Jones simonpj at microsoft.com
Tue Oct 25 05:47:38 EDT 2005


Christoph, and other TH users,

| > I have been waiting for a long while for more documentation
| > about the use of Template Haskell as it is currently implemented,
| > now ghc-6.4.1. The documentation on the web refers to several old

You're absolutely right.  Template Haskell is appallingly badly
documented.  The reason I have not done anything about it is that
there's very little traffic on the Template Haskell list (or any other,
about TH), and that has de-motivated me so far as improving TH is
concerned.  I tend to pay more attention to things that I think people
are actively using and care about.  

TH seems to have had quite a bit less impact than I originally thought
it might, given that it provides something qualitatively new.  But maybe
I'm wrong.  For example, I didn't know that it was important to you.
Maybe there are others.

In any case, as you may guess I find it difficult to find enough time to
do all the GHC related things that GHC's users would like.  That's good,
because it means GHC is being useful, but bad because some things don't
get done. 

 My current hope is to broaden the base of people who are willing to
contribute to GHC themselves, with support from me and Simon, so that
Simon and I aren't always on the critical path.


So here's an offer.  If you'd be willing to draft the documentation you
would like to see, I would be willing to 
	- review it, 
	- answer questions, and 
	- write parts where you don't know what to say. 
But you already know a lot, so you are well placed to write an outline.
Perhaps TH folk would be willing to help too?  RSVP to the TH list
(which I'm ccing).

I know this won't be quite the reply you were hoping for, but I hope
you'll consider it.

Simon



| -----Original Message-----
| From: Christoph Herrmann [mailto:herrmann at uni-passau.de]
| Sent: 22 October 2005 18:42
| To: Simon Peyton-Jones
| Subject: Re: Documentation Template Haskell
| 
| Dear Simon,
| 
| > Anything more than a list of library function types would do it.
| 
| It would be good if it contains some explanations. Recently
| I have found the following example on the mailing list but I can
| only guess what, e.g., "tupP" means.
| 
| sel' :: Int -> Int -> ExpQ
| sel' i n = lamE [pat] rhs
|     where pat = tupP (map varP as)
|           rhs = varE (as !! (i - 1))
|           as = map mkName [ ("a__" ++ show j) | j <- [1..n] ]
| 
| Looking up Google for "tupP TH" leads me to some pages about TH
| where I can either find some old example TH programs without "tupP"
| or a list of library functions where I can only get the type of
"tupP".
| What I need would be a few English words telling what tupP actually
does.
| 
| Also, I'm wondering about the TH function "tuple" below whether it is
| an old version, a plan for the future or even supposed to work with
| ghc-6.4.1 but I forgot some import declarations.
| 
| tuple :: Int -> Q Exp
| tuple n = [|\list -> $(tupE (exprs [|list|])) |]
|   where
|     exprs list = [infixE (Just (list::[Char]))
|                          (varE "!!")
|                          (Just (litE $ integerL (toInteger num)))
|                     | num <- [0..(n - 1)]]
| 
| 
| Christoph Herrmann wrote:
| > Dear Simon,
| >
| > I have been waiting for a long while for more documentation
| > about the use of Template Haskell as it is currently implemented,
| > now ghc-6.4.1. The documentation on the web refers to several old
| > versions of TH and most of the examples don't work any more,
| > e.g., the generation of a function which selects a component
| > from a tuple. I don't know which of the new features you proposed
| > are currently implemented.
| >
| > I need Template Haskell both for my work on metaprogramming
| > and for teaching. Could you please point me to information
| > about the current state? It doesn't matter for me how well it is
| > written, as far as the definitions are up-to-date. Also, some
examples
| > which deal with code construction and reification and which work
with
| > ghc-6.4.1 would be useful for me. Again, I do not care about how
they
| > look like. Anything more than a list of library function types would
do it.
| >
| > Many thanks in advance
| > --
| >  Christoph Herrmann
| >  University of Passau, Germany
| >
| >



More information about the template-haskell mailing list