Template Haskell attempts to load unnecessary packages
To run TH splices, GHC's interpreter loads all packages specified on the command line, even if they are not needed. This causes compilation to fail when an unused package works with the compiler, but not with the interpreter.
Consider the one-line program {-# LANGUAGE TemplateHaskell #-} main = print $([|1|])
. I can compile it with ghc --make Main.hs
. If I add the extra command line parameter -package WeakTest
, compilation fails when attempting to load the WeakTest package. (This package demonstrates a GHCi bug and is attached to #3333 (closed)).
Why put a superfluous package on the command line? This may happen because a build system uses the same set of flags to compile every file. This is the current behavior of Cabal.
A possible solution would be for GHC to reuse the mechanism that GHC --make uses for deciding which command line packages to actually load. This way, extra packages won't prevent compilation. This would make it easier to use TH in a project that relies on non-interpreted packages.
See also #3333 (closed). Possibly related #2555 (closed).
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |