Pragma not recognised when wrapped in #ifdef

Neil Mitchell ndmitchell at
Wed Feb 11 04:11:15 EST 2009


> Is there still a need for CPP now that Template Haskell exists?

Yes. For a start you might need CPP to switch between Haskell
compilers that do and don't support Template Haskell! Both
technologies do different things, CPP is great for conditional
compilation based on compiler version/features - i.e. using either
deriving (Eq) or deriving (Data,Typeable,Eq) where the latter is
supported. Also for doing imports which have changed between versions,
i.e. import Data.Data or Data.Generics depending on version.

Using the CPP textual replacement/macro substitution facilities is
more debatable, and in many of these cases Template Haskell is a
better choice.



> 2009/2/11 Simon Peyton-Jones <simonpj at>:
>> | Perhaps CPP shouldn't be a pragma, just a command-line flag? It seems
>> | to be the only one that affects/involves preprocessor(s). AFAICT, the
>> | others all affect the haskell compiler stage.
>> Yes, it does seem anomalous.  I suppose the motivation is that some modules might need CPP and some not, and it's convenient for the module itself to announce that fact.
>> Simon
>> _______________________________________________
>> Glasgow-haskell-users mailing list
>> Glasgow-haskell-users at
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list