1 /* ----------------------------------------------------------------------------
2 * Macros to help make Typeable instances.
3 * -------------------------------------------------------------------------- */
5 #define INSTANCE_TYPEABLE0(tycon,tcname,str) \
6 tcname = mkTyCon str; \
7 instance Typeable tycon where { typeOf _ = mkAppTy tcname [] }
9 #ifdef __GLASGOW_HASKELL__
11 #define INSTANCE_TYPEABLE1(tycon,tcname,str) \
12 tcname = mkTyCon str; \
13 instance Typeable1 tycon where { typeOf1 _ = mkAppTy tcname [] }
15 #define INSTANCE_TYPEABLE2(tycon,tcname,str) \
16 tcname = mkTyCon str; \
17 instance Typeable2 tycon where { typeOf2 _ = mkAppTy tcname [] }
19 #define INSTANCE_TYPEABLE3(tycon,tcname,str) \
20 tcname = mkTyCon str; \
21 instance Typeable3 tycon where { typeOf3 _ = mkAppTy tcname [] }
23 #else /* !__GLASGOW_HASKELL__ */
25 #define INSTANCE_TYPEABLE1(tycon,tcname,str) \
26 tcname = mkTyCon str; \
27 instance Typeable1 tycon where { typeOf1 _ = mkAppTy tcname [] }; \
28 instance Typeable a => Typeable (tycon a) where { typeOf = typeOfDefault }
30 #define INSTANCE_TYPEABLE2(tycon,tcname,str) \
31 tcname = mkTyCon str; \
32 instance Typeable2 tycon where { typeOf2 _ = mkAppTy tcname [] }; \
33 instance Typeable a => Typeable1 (tycon a) where { \
34 typeOf1 = typeOf1Default }; \
35 instance (Typeable a, Typeable b) => Typeable (tycon a b) where { \
36 typeOf = typeOfDefault }
38 #define INSTANCE_TYPEABLE3(tycon,tcname,str) \
39 tcname = mkTyCon str; \
40 instance Typeable3 tycon where { typeOf3 _ = mkAppTy tcname [] }; \
41 instance Typeable a => Typeable2 (tycon a) where { \
42 typeOf2 = typeOf2Default }; \
43 instance (Typeable a, Typeable b) => Typeable1 (tycon a b) where { \
44 typeOf1 = typeOf1Default }; \
45 instance (Typeable a, Typeable b, Typeable c) => Typeable (tycon a b c) where { \
46 typeOf = typeOfDefault }
48 #endif /* !__GLASGOW_HASKELL__ */