CPP extension and multiline literals in Haskell
- by jetxee
Is it possible to use CPP extension on Haskell code which contains multiline string literals? Are there other conditional compilation techniques for Haskell?
For example, let's take this code:
-- If the next line is uncommented, the program does not compile.
-- {-# LANGUAGE CPP #-}
msg = "Hello\
\ Wor\
\ld!"
main = putStrLn msg
If I uncomment {-# LANGUAGE CPP #-}, then GHC refutes this code with a lexical error:
[1 of 1] Compiling Main ( cpp-multiline.hs, cpp-multiline.o )
cpp-multiline.hs:4:17:
lexical error in string/character literal at character 'o'
Using GHC 6.12.1, cpphs is available.
I confirm that using cpphs.compat wrapper and -pgmP cpphs.compat option helps, but I'd like to have a solution which does not depend on custom shell scripts. -pgmP cpphs does not work.
P.S. I need to use different code for GHC < 6.12 and GHC = 6.12, is it possible without preprocessor?