Skip to content

ghc does not pick up TH changes across package boundaries

I have the following three modules:

module Types where

data Foo = Bar
{-# LANGUAGE TemplateHaskell #-}
module TH where

import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import Types

th_string = lift . show =<< reify ''Foo
{-# LANGUAGE TemplateHaskell #-}
module Main where

import TH

main = putStrLn $(th_string)

The goal is to make Main recompile if the definition of Types.Foo changes.

If I simply put the three files in the same directory and compile with ghc, it works.

However, if I put Types and TH in package A and Main in package B, then ghc doesn't recompile B.Main if I change the definition of A.Types.Foo and reinstall the package A.

I tried this with both stack and cabal-install. In both cases I compiled B.Main directly with ghc, so it's not Cabal that's hiding the changes. If I pass -fforce-recomp to ghc, Main recompiles as expected.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information