<div dir="ltr">Hello all,<br><br>I'm trying to use CPP-defined strings in a Haskell module, like this:<br><br> main :: IO ()<br> main = putStrLn FOO<br><br>This of course will not work:<br><br>
ghc -DFOO="hello world" --make Main.hs -o test<br>
<br>You'll get this error message:<br><br> ./Main.hs:6:16: Not in scope: `hello'<br>
./Main.hs:6:22: Not in scope: `world'<br>
<br>Either of these will do what I want:<br><br> ghc -DFOO="\"hello world\"" --make Main.hs -o test<br><br> ghc -DFOO='"hello world"' --make Main.hs -o test # (that's double quotes inside single quotes)<br>
<br>However, passing the same CPP definition via cabal does not work.<br><br> runhaskell Setup.hs build --ghc-options=-DFOO="\"hello world\""<br><br> runhaskell Setup.hs build --ghc-options=-DFOO='"hello world"'<br>
<br>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.<br><br>Any idea how I could change the Haskell module or the command line argument so that I get what I want? I've tried many combinations of quotes and escaped quotes with no luck.<br>
<br>Thanks,<br>- Phil<br><br></div>