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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to