Reputation: 8385
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.
Upvotes: 2
Views: 72
Reputation: 8385
I used the extra-source-files
configuration in my .cabal
file to get this to work rather than Language.Haskell.TH.Syntax.addDependentFile
as it was sufficient for my use case, so the extra configuration looks like this:
extra-source-files:
src/GTF/Pages/**/*.djot
The wildcard syntax is a bit limited, but for this use-case it is sufficient.
Using addDependentFile
would have required me to add a bit more code as my file-loading function does not know it is being used in TH
.
Upvotes: 3
Reputation: 152682
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!
Upvotes: 4