[Template-haskell] RE: Template Haskell...

Simon Peyton-Jones simonpj at microsoft.com
Thu Oct 30 09:32:42 EST 2003


| I have one meta-function that generates declarations; and I have
| another meta function that needs to know what definitions generated by
| the first meta function there are (accross module boundaries).

I'm not sure what you're asking for here.  Some kind of monadic function
that stores persistent state, that persists across multiple
compilations?  Presumably held in the file system?  Some kind of
database?  

I suppose you could write a library using strings only that would
support
	write :: FileName -> String -> String -> IO ()
	read :: FileName -> String -> IO String

So (write f key val) writes the (key,value) pair into the file f; and
read gets it back.  Now you could use those in Q (because Q supports
IO).

Alastair wants per-module persistence.  I'm sceptical about that because
TH makes absolutely no guarantees about which order things will be
evaluated in. So how would you know which effect occurs first?

In both cases I feel I'm missing the point.

| reifyImportedModules :: [String] -- or Q [String]
| reifyCurrentModuleName :: String -- or Q String

The latter seems sensible; but what should the former return?  Just the
*direct* imports?  Do-able anyway.

Simon




More information about the template-haskell mailing list