[Haskell-cafe] Cabal, GHC and Preprocessors
Ashley Yakeley
ashley at semantic.org
Sun Apr 11 23:19:38 EDT 2010
I want identifier concatenation in Haskell. For instance:
#define CDecl(n) = class C_##n a where { f_##n :: a };
CDecl(1)
CDecl(2)
CDecl(3)
(Actual motivator involves generating by type kind.)
I have no trouble switching on CPP, but this doesn't work.
The trouble is, GHC uses gcc for preprocessing, and it passes
"-traditional" which switches this off. There doesn't seem to be a flag
to override this.
I've tried replacing the GHC preprocessor with cpphs using -pgmP, but
GHC passes include files using "-include", while cpphs only accepts
"--include".
I've tried telling Cabal to use cpphs, but even if you rename the source
file to .cpphs, it will still use GHC's gcc preprocessor rather than
cpphs. In any case, it's not clear how to tell Cabal to pass --hashes to
cpphs.
I've tried using Template Haskell instead, but you can't easily splice
identifiers, only expressions, types and top-level declarations.
--
Ashley Yakeley
More information about the Haskell-Cafe
mailing list