haskellcabaltemplate-haskell

Is there a way to get `cabal` to detect changes to non-Haskell source files?


I'm using template haskell to include content from non-Haskell files in some of my code, and this content is then parsed and used. The problem that I have with using cabal as a build tool for this is that it doesn't detect when these files changes and so I find myself using cabal clean; cabal build which forces the whole project to be rebuilt (including some dependencies) which is slower than it could otherwise be.


Solution

  • Call Language.Haskell.TH.Syntax.addDependentFile, then wait for this cabal issue to get fixed.

    As a workaround, you can add a comment to some relevant Haskell source file(s) to get them to rebuild (and re-execute their TH). Don't forget to delete it again next build and certainly before you check your source in!