Touching a file that uses TH triggers TH recompilation flood
Check out this test case:
I have 2 modules, A and B, both using TH (using aeson) with B importing A.
After the first compilation,
touch A.hs && ghc --make B.hs causes B to be recompiled.
Why should this be the case? If we see that the A.hi file is completely identical with what it was before, why should we recompile B?
This problem actually hits pretty hard when working in projects with > 200 modules.
(This all is under the assumption that TH doesn't do any IO with observably different result; we do already have this assumption if I understand it correctly, since otherwise we would always recompile all TH code, which we don't.)
Another problem is that the process is not very repeatable:
If you do
touch A.hs && ghc --make All.hs and hit
Ctrl-C before everything is done (e.g. after the 3rd modules), and then run just
ghc --make All.hs, then GHC will decide to compile nothing at all, even though it had determined just before that everything needs to be recompiled. Is this expected?