[Haskell-cafe] Cabal and Strings and CPP
duncan.coutts at worc.ox.ac.uk
Mon Jul 28 18:54:38 EDT 2008
On Mon, 2008-07-28 at 15:02 -0700, Philip Weaver wrote:
> However, passing the same CPP definition via cabal does not work.
> runhaskell Setup.hs build --ghc-options=-DFOO="\"hello world\""
> runhaskell Setup.hs build --ghc-options=-DFOO='"hello world"'
> With either of these commands, I get the same error message as above.
> This is understandable, since cabal has to evaluate the string before
> sending it to GHC, so I lose my escaped quotes.
Cabal has both --prog-option= and --prog-options=. The latter tokenises
the options and passes them as separate flags (like what the shell
does), the former passes the whole arg as one option.
So you want to use:
cabal build --ghc-option=-DFOO="\"hello world\""
When you want to put this in the .cabal file, use cpp-options (not
ghc-options) and you can use Haskell String syntax for options that
More information about the Haskell-Cafe