
Hi GHC users! Does anyone know if an import that is only used by Template Haskell (i.e. not in "actual" code) is reflected in the produced executable? Example: import LargeModule(thFunction) $thfunction ... Is LargeModule linked in the executable file? (Assume thFunction is not referenced by the code it generates or elsewhere in the example) Best regards Jonas

It probably is linked if you use --make, but should not be if you use an explicit link command ghc -o run-me A.o B.o C.o Just omit LargeThModule.o Hmm. Maybe this won't work, because there is a module initialisation tree, in which each module calls the initialisation function of the modules it imports. So probably the module that imports LargeThModule will call LargeThModule's initialisation function, so omitting LargeThModule.o would give a link error. I suppose you could hack around this by commenting out the body of LargeThModule and recompiling it to make a small .o file for runtime linking, but it would be a gross hack. Oh, here's a thought. If you use -split-objs, the linker should drop all non-executed code, so that will probably do what you want. Simon From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On Behalf Of Jonas Almström Duregård Sent: 17 September 2010 21:48 To: glasgow-haskell-users@haskell.org Subject: Template Haskell and linking Hi GHC users! Does anyone know if an import that is only used by Template Haskell (i.e. not in "actual" code) is reflected in the produced executable? Example: import LargeModule(thFunction) $thfunction ... Is LargeModule linked in the executable file? (Assume thFunction is not referenced by the code it generates or elsewhere in the example) Best regards Jonas
participants (2)
-
Jonas Almström Duregård
-
Simon Peyton-Jones