Skip to content
Snippets Groups Projects
Commit a2e657fb authored by Ian Lynagh's avatar Ian Lynagh
Browse files

For GHC, implement the Typeable.hs macros using standalone deriving

As well as being more pleasant, this fixes #1841:
    Data.Typeable: Instances of basic types don't provide qualified
    strings to mkTyCon
parent 95442c47
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,8 @@ library
TypeSynonymInstances
if impl(ghc)
extensions:
DeriveDataTypeable,
StandaloneDeriving,
Rank2Types,
MagicHash,
UnboxedTuples,
......
......@@ -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; \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment