Re: types.
Sean Seefried <[email protected]> Sat, 19 Feb 2005 09:37:13 +1100
| Newsgroups | gmane.comp.lang.haskell.template |
|---|---|
| Message-ID | <[email protected]> |
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