Pragma not recognised when wrapped in #ifdef

Alistair Bayley alistair at abayley.org
Fri Feb 6 04:02:40 EST 2009


I have this little test program:

{-# LANGUAGE CPP #-}
#ifdef PRAGMA_DERIVE_TYPEABLE
{-# LANGUAGE DeriveDataTypeable #-}
#else
{-# OPTIONS -fglasgow-exts #-}
#endif
-- This file is Test/Fail.hs.
-- ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
module Test.Fail where
import Data.Generics
data Fail = Fail deriving Typeable

If compile this wih the command
  ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
then I get this error from ghc-6.10.1:

[1 of 1] Compiling Test.Fail        ( Test\Fail.hs, Test\Fail.o )

Test\Fail.hs:11:26:
    Can't make a derived instance of `Typeable Fail'
      (You need -XDeriveDataTypeable to derive an instance for this class)
    In the data type declaration for `Fail'

I've checked the preprocessor output with -E, and that looks fine. I
can compile the preprocessor output with ghc without errors.

Alistair


More information about the Glasgow-haskell-users mailing list