Ahh, I am doing a form of source to source translation for Haskell. I don't want to maintain the parser for this so TH seemed to be ideal. I would be happy with the restriction of no splices within the meta-quotes. If TH is already type checking (it is, as it will catch type errors in the meta-quoted code) then surely this type info is available, it just needs to be reified? Who maintains that part of the TH code in GHC? Keean Sean Seefried wrote:
On 19/02/2005, at 2:33 AM, Keean Schupke wrote:
Last mail seemed to get lost (think I forgot to CC it to the list):
would this work with:
$(something [d| f a = a + 1 |])
Such that I can reference the reified type of 'f' from inside 'something'. 'something' would be imported from another file. I am using ghc-6.4
As far as I know you *can't* do this. It is true that TH will type check things that are inside quasi quotes but it will only complete this process if there are no inner splices. There's a good reason for this.
TH tries to be as inclusive of meta-programs as it can by not type checking programs at compile-time (unlike, say, MetaML). In fact, unless one heavily restricts the allowable meta-programs type checking them statically is undecidable. So what TH does it wait until all the meta-programming has been done (i.e. all the code has been generated and spliced in) before type checking.
The type checking I referred to in the first paragraph seems to be just an extra check to catch some errors earlier. It's not necessary. For a while I was interested in using TH for the transformation of programs. I wasn't interested in generation at all. I started work on a type checking extension to TH that would type check stuff within in quasi-quotes that a) had everything in scope and b) contained no inner splices.
However, I never got around to finishing it since I'm doing source-to-source transformation another way now.
Cheers,
Sean