[Template-haskell] RE: Template Haskell, [p|...|]

Simon Peyton-Jones simonpj@microsoft.com
Thu, 3 Jul 2003 11:23:35 +0100


There's a separate Template Haskell mailing list, which it'd be worth
ccing on this (are you on it)?

Ian Lynagh has a home page for Template Haskell, at
	 http://www.haskell.org/th/

[IAN: it'd be worth noting the current unimplemented features of TH on
the home page, perhaps.  And is the TH page linked from Haskell.org?
Couldn't find the link, if it exists.]

| trying to adapt the zipN-example in the paper
| "Template Meta-programming for Haskell" by
| Sheard and Peyton Jones to Language.Haskell.THSyntax
| I found that quasi-quotation for patterns does not seem
| to work with ghci-6.0, e.g., the following results in
| "Parse error in pattern":
|=20
|    pcons x xs =3D [p| $x : $xs |]

Yes -- pattern splices are not implemented at all.  The user manual
should say this, but doesn't. There are good reasons for this, as you'll
see by looking at the TH mailing list archive.

| Trying to use the standard list representation by
|=20
|    pcons x xs =3D Pcon "(:)" [x,xs]
|=20
| I got the error message
|=20
|    Data constructor not in scope: `(:)'
|    tcLookupDataCon: `(:)' is not in scope

You need to say "GHC.Base::" to name precisely the (:) defined by GHC.
This is clearly Bad and Horrible, and is on the list for a radical clean
up.

Tim Sheard is working on a design document describing what we have in
mind.  Tim?

Simon