[Template-haskell] Splice Imports

Simon Peyton-Jones simonpj at microsoft.com
Mon Feb 6 03:48:19 EST 2006


| Could module import splicing be added into Template Haskell? Other
than
| updating the syntax and pretty printer in Language.Haskell.TH, what
else
| would need to be done?

So you want to be able to say
	$(f 4)
and have that expand to
	import X
or 	
	import Y
or whatever?

That seems convenient, and it's not very hard to implement.  Import
statements have to become regular declarations, able to appear anywhere;
we need TH syntax for them; and so on.  It came up a while ago, and
Lemmih was quite keen to do it.  

But I've held off doing it because it'll break ghc -M and ghc --make.
It'll mean that GHC can't figure out dependencies until it's actually
compiling. This is an issue even for crude Cpp-ery, but we run CPP
before ghc -M and ghc --make.  That's not possible for TH because you
have to typecheck the module before running the splices.

One could say that the programmer has to write his own dependencies in
the makefile, but that still doesn't help with ghc --make.  I don't see
an easy path.

Anyway that's why it's remained un-done.

Simon



| -----Original Message-----
| From: template-haskell-bounces at haskell.org
[mailto:template-haskell-bounces at haskell.org] On
| Behalf Of Simon Foster
| Sent: 03 February 2006 20:45
| To: template-haskell at haskell.org
| Subject: [Template-haskell] Splice Imports
| 
| Hi,
| 
| Could module import splicing be added into Template Haskell? Other
than
| updating the syntax and pretty printer in Language.Haskell.TH, what
else
| would need to be done?
| 
| Thanks,
| 
| -Simon Foster.
| 
| _______________________________________________
| template-haskell mailing list
| template-haskell at haskell.org
| http://www.haskell.org/mailman/listinfo/template-haskell


More information about the template-haskell mailing list