I think Hspec
being\not being a dependency of the project package is a difference that will trigger the need for a rebuild. Try making it a dependency common to all components in the package decription (eg, if using package.yaml
as the package description, add it to the top-level dependencies
key.)
I don’t have an answer about the ghc-options
field of a component of a project package to hand, but I’ll see if I can get you an answer. EDIT: Empirically, toggling -threaded
as a GHC option (perhaps not the best choice of option to test this) for the test suit component did not trigger a rebuild of the project package. It is Cabal (the library) GHC that is deciding that a rebuild is not required. EDIT2: That is, Stack detects the change in the package description, and involves Cabal (the library). Cabal, in turn, passes things on to GHC.
EDIT3: In terms of the organisation of Stack’s work directories (which include artefacts from past builds of project packages), that is documented at Stack work directories - The Haskell Tool Stack. The project package work directory depends only on the platform and GHC version. The project work directory depends on that and other information, including information about immutable dependencies.