1 {- --------------------------------------------------------------------------
2 // Macros to help make Typeable instances.
4 // INSTANCE_TYPEABLEn(tc,tcname,"tc") defines
6 // instance Typeable/n/ tc
7 // instance Typeable a => Typeable/n-1/ (tc a)
8 // instance (Typeable a, Typeable b) => Typeable/n-2/ (tc a b)
10 // instance (Typeable a1, ..., Typeable an) => Typeable (tc a1 ... an)
11 // --------------------------------------------------------------------------
17 #define INSTANCE_TYPEABLE0(tycon,tcname,str) \
19 tcname = mkTyCon str; \
20 instance Typeable tycon where { typeOf _ = mkTyConApp tcname [] }
22 #ifdef __GLASGOW_HASKELL__
24 -- // For GHC, the extra instances follow from general instance declarations
25 -- // defined in Data.Typeable.
27 #define INSTANCE_TYPEABLE1(tycon,tcname,str) \
29 tcname = mkTyCon str; \
30 instance Typeable1 tycon where { typeOf1 _ = mkTyConApp tcname [] }
32 #define INSTANCE_TYPEABLE2(tycon,tcname,str) \
34 tcname = mkTyCon str; \
35 instance Typeable2 tycon where { typeOf2 _ = mkTyConApp tcname [] }
37 #define INSTANCE_TYPEABLE3(tycon,tcname,str) \
39 tcname = mkTyCon str; \
40 instance Typeable3 tycon where { typeOf3 _ = mkTyConApp tcname [] }
42 #define INSTANCE_TYPEABLE4(tycon,tcname,str) \
44 tcname = mkTyCon str; \
45 instance Typeable4 tycon where { typeOf4 _ = mkTyConApp tcname [] }
47 #define INSTANCE_TYPEABLE5(tycon,tcname,str) \
49 tcname = mkTyCon str; \
50 instance Typeable5 tycon where { typeOf5 _ = mkTyConApp tcname [] }
52 #define INSTANCE_TYPEABLE6(tycon,tcname,str) \
54 tcname = mkTyCon str; \
55 instance Typeable6 tycon where { typeOf6 _ = mkTyConApp tcname [] }
57 #define INSTANCE_TYPEABLE7(tycon,tcname,str) \
59 tcname = mkTyCon str; \
60 instance Typeable7 tycon where { typeOf7 _ = mkTyConApp tcname [] }
62 #else /* !__GLASGOW_HASKELL__ */
64 #define INSTANCE_TYPEABLE1(tycon,tcname,str) \
65 tcname = mkTyCon str; \
66 instance Typeable1 tycon where { typeOf1 _ = mkTyConApp tcname [] }; \
67 instance Typeable a => Typeable (tycon a) where { typeOf = typeOfDefault }
69 #define INSTANCE_TYPEABLE2(tycon,tcname,str) \
70 tcname = mkTyCon str; \
71 instance Typeable2 tycon where { typeOf2 _ = mkTyConApp tcname [] }; \
72 instance Typeable a => Typeable1 (tycon a) where { \
73 typeOf1 = typeOf1Default }; \
74 instance (Typeable a, Typeable b) => Typeable (tycon a b) where { \
75 typeOf = typeOfDefault }
77 #define INSTANCE_TYPEABLE3(tycon,tcname,str) \
78 tcname = mkTyCon str; \
79 instance Typeable3 tycon where { typeOf3 _ = mkTyConApp tcname [] }; \
80 instance Typeable a => Typeable2 (tycon a) where { \
81 typeOf2 = typeOf2Default }; \
82 instance (Typeable a, Typeable b) => Typeable1 (tycon a b) where { \
83 typeOf1 = typeOf1Default }; \
84 instance (Typeable a, Typeable b, Typeable c) => Typeable (tycon a b c) where { \
85 typeOf = typeOfDefault }
87 #define INSTANCE_TYPEABLE4(tycon,tcname,str) \
88 tcname = mkTyCon str; \
89 instance Typeable4 tycon where { typeOf4 _ = mkTyConApp tcname [] }; \
90 instance Typeable a => Typeable3 (tycon a) where { \
91 typeOf3 = typeOf3Default }; \
92 instance (Typeable a, Typeable b) => Typeable2 (tycon a b) where { \
93 typeOf2 = typeOf2Default }; \
94 instance (Typeable a, Typeable b, Typeable c) => Typeable1 (tycon a b c) where { \
95 typeOf1 = typeOf1Default }; \
96 instance (Typeable a, Typeable b, Typeable c, Typeable d) => Typeable (tycon a b c d) where { \
97 typeOf = typeOfDefault }
99 #define INSTANCE_TYPEABLE5(tycon,tcname,str) \
100 tcname = mkTyCon str; \
101 instance Typeable5 tycon where { typeOf5 _ = mkTyConApp tcname [] }; \
102 instance Typeable a => Typeable4 (tycon a) where { \
103 typeOf4 = typeOf4Default }; \
104 instance (Typeable a, Typeable b) => Typeable3 (tycon a b) where { \
105 typeOf3 = typeOf3Default }; \
106 instance (Typeable a, Typeable b, Typeable c) => Typeable2 (tycon a b c) where { \
107 typeOf2 = typeOf2Default }; \
108 instance (Typeable a, Typeable b, Typeable c, Typeable d) => Typeable1 (tycon a b c d) where { \
109 typeOf1 = typeOf1Default }; \
110 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e) => Typeable (tycon a b c d e) where { \
111 typeOf = typeOfDefault }
113 #define INSTANCE_TYPEABLE6(tycon,tcname,str) \
114 tcname = mkTyCon str; \
115 instance Typeable6 tycon where { typeOf6 _ = mkTyConApp tcname [] }; \
116 instance Typeable a => Typeable5 (tycon a) where { \
117 typeOf5 = typeOf5Default }; \
118 instance (Typeable a, Typeable b) => Typeable4 (tycon a b) where { \
119 typeOf4 = typeOf4Default }; \
120 instance (Typeable a, Typeable b, Typeable c) => Typeable3 (tycon a b c) where { \
121 typeOf3 = typeOf3Default }; \
122 instance (Typeable a, Typeable b, Typeable c, Typeable d) => Typeable2 (tycon a b c d) where { \
123 typeOf2 = typeOf2Default }; \
124 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e) => Typeable1 (tycon a b c d e) where { \
125 typeOf1 = typeOf1Default }; \
126 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable f) => Typeable (tycon a b c d e f) where { \
127 typeOf = typeOfDefault }
129 #define INSTANCE_TYPEABLE7(tycon,tcname,str) \
130 tcname = mkTyCon str; \
131 instance Typeable7 tycon where { typeOf7 _ = mkTyConApp tcname [] }; \
132 instance Typeable a => Typeable6 (tycon a) where { \
133 typeOf6 = typeOf6Default }; \
134 instance (Typeable a, Typeable b) => Typeable5 (tycon a b) where { \
135 typeOf5 = typeOf5Default }; \
136 instance (Typeable a, Typeable b, Typeable c) => Typeable4 (tycon a b c) where { \
137 typeOf4 = typeOf4Default }; \
138 instance (Typeable a, Typeable b, Typeable c, Typeable d) => Typeable3 (tycon a b c d) where { \
139 typeOf3 = typeOf3Default }; \
140 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e) => Typeable2 (tycon a b c d e) where { \
141 typeOf2 = typeOf2Default }; \
142 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable f) => Typeable1 (tycon a b c d e f) where { \
143 typeOf1 = typeOf1Default }; \
144 instance (Typeable a, Typeable b, Typeable c, Typeable d, Typeable e, Typeable f, Typeable g) => Typeable (tycon a b c d e f g) where { \
145 typeOf = typeOfDefault }
147 #endif /* !__GLASGOW_HASKELL__ */