[Template-haskell] Avoiding linking final executable to TH

Lemmih lemmih at gmail.com
Mon Jul 4 16:45:03 EDT 2005


On 7/4/05, Einar Karttunen <ekarttun at cs.helsinki.fi> wrote:
> Hello
> 
> Are there currently any plans to avoid linking the final executable with
> TH? As far as I understand currently the situation is as follows:
> 
> Module M uses TH code defined in MTH.
> Module MTH imports TH modules and thus needs to be linked with template-haskell.
> 
> The simplest way to deal with this could be to use a special
> compile-time import construct between M and MTH - so that MTH would
> not need to be linked with M (and thus template-haskell would not be
> needed either).
> 
> Are there any plans regarding something like this or an another solution?

I hacked up Zeroth to overcome the linking problem. Zeroth is a
preprocessor which scans Haskell source files (using haskell-src-exts)
for top level splices and evaluates them. For example:

> module TestTH where
> #ifdef HASTH
> -- import TH modules here.
> #endif
> -- Simple declaration
> $( [d| x = "test" |] )

becomes

> module TestTH
> -- Simple declaration
> x = "test"

However, Zeroth is hardly more than a dirty fix so use with care.

Darcs repository: http://www.scannedinavian.org/~lemmih/zerothHead
Haskell-src-exts: http://www.cs.chalmers.se/%7Ed00nibro/haskell-src-exts/
I've attached a patch with Cabal support for zeroth.

-- 
Friendly,
  Lemmih
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zeroth.patch
Type: text/x-patch
Size: 14476 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/template-haskell/attachments/20050704/7ab0d02a/zeroth.bin


More information about the template-haskell mailing list