[Template-haskell] RE: Template Haskell...
alastair at reid-consulting-uk.ltd.uk
Wed Oct 29 21:33:26 EST 2003
> Another thing that I'm really missing with the current Template Haskell
> is a "decent" way to pass state between different meta-functions. Let
> me provide a few examples of the things I want to do:
> Manuel Chakravarty provided me with a nice workaround involving the use
> of (unsafePerformIO $ newIORef ...) global variables from the Q monad.
This is an absolutely essential feature. It's a critical part of Template
Unfortunately, the workaround (which is the same one I use) doesn't work with
ghc --make because the global variable doesn't get reset between modules. So
it tends to contain information from compiling whichever random set of
modules needed recompiling. The workaround for this is not to use --make.
It would also be nice to be able to pass state _between_ modules. For
example, in Template Greencard, I want to declare Data Interface Schemes
(rules for how to marshal objects to/from C) in one module and use them in
another module. This would, presumably, have to be done by providing a hook
where my TH code could provide things to include in .hi files and provide a
way for my TH code to ask ghc for them back. (This may be the same thing
that Wolfgang is asking for.)
Alastair Reid www.haskell-consulting.com
More information about the template-haskell