Passing -ddump-splices from Cabal


It's possible to pass GHC flags on the command line when using cabal. One flag that I always end up using when working with Template Haskell is -ddump-splices. The following shows how to pass it to cabal.

$ cabal run --ghc-options="-ddump-splices"

There are a couple things to watch out for.

  • When recompiling, cabal will only recompile source files that have changed. If you are expecting the Template Haskell to be dumped to the console and it's not, you may want to change the file in question by adding extra space or an extra newline. This will cause cabal to see that the file has changed, recompile it, and dump the Template Haskell to the console.
  • --ghc-options (the cabal flag) begins with two hyphens, while -ddump-splices (the ghc flag) begins with only one hyphen.

tags: haskell