template-haskell should *not* be added as an implicit dependency
The following program should fail to compile when using -hide-all-packages
and not passing -package template-haskell
.
{-# LANGUAGE TemplateHaskellQuotes #-}
module T5 where
a = [| () |]
ghc T5.hs -hide-all-packages -package base
When does this cause an issue? If a package only uses TemplateHaskell implicitly then Cabal does not know about the template-haskell
dependency so it doesn't make it into the depends:
field in the package.conf file. Then there is no guarantee that the template-haskell
library will be built or in the search path if you build tool determines it isn't used.
This seems to work with the dynamic linker because it finds the library in the search path but you can imagine a build system which curates a directory to only include dependencies which are going to be needed.
Solution: Make a user explicitly depend on template-haskell
if they use TH quotes.