diff --git a/array.cabal b/array.cabal index 8352b0e04d1a7b94f574225ec612df6b6d16743f..e3fb91d319d5f3ea1c6335a25747bd0a52a12d7e 100644 --- a/array.cabal +++ b/array.cabal @@ -40,6 +40,8 @@ library TypeSynonymInstances if impl(ghc) extensions: + DeriveDataTypeable, + StandaloneDeriving, Rank2Types, MagicHash, UnboxedTuples, diff --git a/include/Typeable.h b/include/Typeable.h index 649d6f367da7da72e9c9c84213be6fef980a2da9..91fbcdd2089dd808cb48852658b7c462fec5e872 100644 --- a/include/Typeable.h +++ b/include/Typeable.h @@ -14,32 +14,22 @@ #ifndef TYPEABLE_H #define TYPEABLE_H -#define INSTANCE_TYPEABLE0(tycon,tcname,str) \ -tcname :: TyCon; \ -tcname = mkTyCon str; \ -instance Typeable tycon where { typeOf _ = mkTyConApp tcname [] } - #ifdef __GLASGOW_HASKELL__ --- // For GHC, the extra instances follow from general instance declarations --- // defined in Data.Typeable. +-- // For GHC, we can use DeriveDataTypeable + StandaloneDeriving to +-- // generate the instances. -#define INSTANCE_TYPEABLE1(tycon,tcname,str) \ -tcname :: TyCon; \ -tcname = mkTyCon str; \ -instance Typeable1 tycon where { typeOf1 _ = mkTyConApp tcname [] } +#define INSTANCE_TYPEABLE0(tycon,tcname,str) deriving instance Typeable tycon +#define INSTANCE_TYPEABLE1(tycon,tcname,str) deriving instance Typeable1 tycon +#define INSTANCE_TYPEABLE2(tycon,tcname,str) deriving instance Typeable2 tycon +#define INSTANCE_TYPEABLE3(tycon,tcname,str) deriving instance Typeable3 tycon -#define INSTANCE_TYPEABLE2(tycon,tcname,str) \ -tcname :: TyCon; \ -tcname = mkTyCon str; \ -instance Typeable2 tycon where { typeOf2 _ = mkTyConApp tcname [] } +#else /* !__GLASGOW_HASKELL__ */ -#define INSTANCE_TYPEABLE3(tycon,tcname,str) \ +#define INSTANCE_TYPEABLE0(tycon,tcname,str) \ tcname :: TyCon; \ tcname = mkTyCon str; \ -instance Typeable3 tycon where { typeOf3 _ = mkTyConApp tcname [] } - -#else /* !__GLASGOW_HASKELL__ */ +instance Typeable tycon where { typeOf _ = mkTyConApp tcname [] } #define INSTANCE_TYPEABLE1(tycon,tcname,str) \ tcname = mkTyCon str; \