Avoiding linking final executable to TH
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? - Einar Karttunen
On 7/4/05, Einar Karttunen
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
participants (2)
-
Einar Karttunen -
Lemmih