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

Alastair Reid alastair at reid-consulting-uk.ltd.uk
Mon Nov 3 12:53:16 EST 2003


On Friday 31 October 2003 5:45 pm, Simon Peyton-Jones wrote:
> Not so. We split at top-level declaration splices.  What about this,
> though?  NO splitting involved.
>
> f :: Int -> Q Exp
> f n = [| n+2 |]
>
> g x = x + $(f 3)

The standard dependency analysis done for typechecking will have already found 
a reasonable approximation of the transitive closure of templates needed by 
g.  But, more importantly, tell me again why you need to find those 
dependencies first anyway?  Would the problem not go away if you 
byte-code-compiled f lazily?

> Furthermore, we don't want to *always* compile-to-byte-code all the
> preceding code in a module.  usually none of it'll b needed

Would lazy compilation help?  You'd have to build a bunch of thunks which, if 
evaluated, would yield byte-code objects but you wouldn't have to actually 
compile the code.

--
Alastair Reid




More information about the template-haskell mailing list