70336d87e533bbb526cabd791b786dc53482a3c1
[ghc.git] / compiler / hsSyn / HsInstances.hs
1 {-# LANGUAGE TypeFamilies #-}
2 {-# LANGUAGE StandaloneDeriving #-}
3 {-# LANGUAGE DeriveDataTypeable #-}
4 {-# LANGUAGE FlexibleContexts #-}
5 {-# LANGUAGE FlexibleInstances #-}
6 {-# LANGUAGE UndecidableInstances #-}
7 {-# OPTIONS_GHC -fno-warn-orphans #-}
8 module HsInstances where
9
10 -- This module defines the Data instances for the hsSyn AST.
11
12 -- It happens here to avoid massive constraint types on the AST with concomitant
13 -- slow GHC bootstrap times.
14
15 -- UndecidableInstances ?
16
17 import Data.Data hiding ( Fixity )
18
19 import GhcPrelude
20 import HsExtension
21 import HsBinds
22 import HsDecls
23 import HsExpr
24 import HsLit
25 import HsTypes
26 import HsPat
27 import HsImpExp
28
29 -- ---------------------------------------------------------------------
30 -- Data derivations from HsSyn -----------------------------------------
31
32 -- ---------------------------------------------------------------------
33 -- Data derivations from HsBinds ---------------------------------------
34
35 -- deriving instance (DataIdLR pL pR) => Data (HsLocalBindsLR pL pR)
36 deriving instance Data (HsLocalBindsLR GhcPs GhcPs)
37 deriving instance Data (HsLocalBindsLR GhcPs GhcRn)
38 deriving instance Data (HsLocalBindsLR GhcRn GhcRn)
39 deriving instance Data (HsLocalBindsLR GhcTc GhcTc)
40
41 -- deriving instance (DataIdLR pL pR) => Data (HsValBindsLR pL pR)
42 deriving instance Data (HsValBindsLR GhcPs GhcPs)
43 deriving instance Data (HsValBindsLR GhcPs GhcRn)
44 deriving instance Data (HsValBindsLR GhcRn GhcRn)
45 deriving instance Data (HsValBindsLR GhcTc GhcTc)
46
47 -- deriving instance (DataIdLR pL pL) => Data (NHsValBindsLR pL)
48 deriving instance Data (NHsValBindsLR GhcPs)
49 deriving instance Data (NHsValBindsLR GhcRn)
50 deriving instance Data (NHsValBindsLR GhcTc)
51
52 -- deriving instance (DataIdLR pL pR) => Data (HsBindLR pL pR)
53 deriving instance Data (HsBindLR GhcPs GhcPs)
54 deriving instance Data (HsBindLR GhcPs GhcRn)
55 deriving instance Data (HsBindLR GhcRn GhcRn)
56 deriving instance Data (HsBindLR GhcTc GhcTc)
57
58 -- deriving instance (DataId p) => Data (ABExport p)
59 deriving instance Data (ABExport GhcPs)
60 deriving instance Data (ABExport GhcRn)
61 deriving instance Data (ABExport GhcTc)
62
63 -- deriving instance (DataIdLR pL pR) => Data (PatSynBind pL pR)
64 deriving instance Data (PatSynBind GhcPs GhcPs)
65 deriving instance Data (PatSynBind GhcPs GhcRn)
66 deriving instance Data (PatSynBind GhcRn GhcRn)
67 deriving instance Data (PatSynBind GhcTc GhcTc)
68
69 -- deriving instance (DataIdLR p p) => Data (HsIPBinds p)
70 deriving instance Data (HsIPBinds GhcPs)
71 deriving instance Data (HsIPBinds GhcRn)
72 deriving instance Data (HsIPBinds GhcTc)
73
74 -- deriving instance (DataIdLR p p) => Data (IPBind p)
75 deriving instance Data (IPBind GhcPs)
76 deriving instance Data (IPBind GhcRn)
77 deriving instance Data (IPBind GhcTc)
78
79 -- deriving instance (DataIdLR p p) => Data (Sig p)
80 deriving instance Data (Sig GhcPs)
81 deriving instance Data (Sig GhcRn)
82 deriving instance Data (Sig GhcTc)
83
84 -- deriving instance (DataId p) => Data (FixitySig p)
85 deriving instance Data (FixitySig GhcPs)
86 deriving instance Data (FixitySig GhcRn)
87 deriving instance Data (FixitySig GhcTc)
88
89 -- deriving instance (DataIdLR p p) => Data (HsPatSynDir p)
90 deriving instance Data (HsPatSynDir GhcPs)
91 deriving instance Data (HsPatSynDir GhcRn)
92 deriving instance Data (HsPatSynDir GhcTc)
93
94 -- ---------------------------------------------------------------------
95 -- Data derivations from HsDecls ---------------------------------------
96
97 -- deriving instance (DataIdLR p p) => Data (HsDecl p)
98 deriving instance Data (HsDecl GhcPs)
99 deriving instance Data (HsDecl GhcRn)
100 deriving instance Data (HsDecl GhcTc)
101
102 -- deriving instance (DataIdLR p p) => Data (HsGroup p)
103 deriving instance Data (HsGroup GhcPs)
104 deriving instance Data (HsGroup GhcRn)
105 deriving instance Data (HsGroup GhcTc)
106
107 -- deriving instance (DataIdLR p p) => Data (SpliceDecl p)
108 deriving instance Data (SpliceDecl GhcPs)
109 deriving instance Data (SpliceDecl GhcRn)
110 deriving instance Data (SpliceDecl GhcTc)
111
112 -- deriving instance (DataIdLR p p) => Data (TyClDecl p)
113 deriving instance Data (TyClDecl GhcPs)
114 deriving instance Data (TyClDecl GhcRn)
115 deriving instance Data (TyClDecl GhcTc)
116
117 -- deriving instance (DataIdLR p p) => Data (TyClGroup p)
118 deriving instance Data (TyClGroup GhcPs)
119 deriving instance Data (TyClGroup GhcRn)
120 deriving instance Data (TyClGroup GhcTc)
121
122 -- deriving instance (DataIdLR p p) => Data (FamilyResultSig p)
123 deriving instance Data (FamilyResultSig GhcPs)
124 deriving instance Data (FamilyResultSig GhcRn)
125 deriving instance Data (FamilyResultSig GhcTc)
126
127 -- deriving instance (DataIdLR p p) => Data (FamilyDecl p)
128 deriving instance Data (FamilyDecl GhcPs)
129 deriving instance Data (FamilyDecl GhcRn)
130 deriving instance Data (FamilyDecl GhcTc)
131
132 -- deriving instance (DataIdLR p p) => Data (InjectivityAnn p)
133 deriving instance Data (InjectivityAnn GhcPs)
134 deriving instance Data (InjectivityAnn GhcRn)
135 deriving instance Data (InjectivityAnn GhcTc)
136
137 -- deriving instance (DataIdLR p p) => Data (FamilyInfo p)
138 deriving instance Data (FamilyInfo GhcPs)
139 deriving instance Data (FamilyInfo GhcRn)
140 deriving instance Data (FamilyInfo GhcTc)
141
142 -- deriving instance (DataIdLR p p) => Data (HsDataDefn p)
143 deriving instance Data (HsDataDefn GhcPs)
144 deriving instance Data (HsDataDefn GhcRn)
145 deriving instance Data (HsDataDefn GhcTc)
146
147 -- deriving instance (DataIdLR p p) => Data (HsDerivingClause p)
148 deriving instance Data (HsDerivingClause GhcPs)
149 deriving instance Data (HsDerivingClause GhcRn)
150 deriving instance Data (HsDerivingClause GhcTc)
151
152 -- deriving instance (DataIdLR p p) => Data (ConDecl p)
153 deriving instance Data (ConDecl GhcPs)
154 deriving instance Data (ConDecl GhcRn)
155 deriving instance Data (ConDecl GhcTc)
156
157 -- deriving instance DataIdLR p p => Data (TyFamInstDecl p)
158 deriving instance Data (TyFamInstDecl GhcPs)
159 deriving instance Data (TyFamInstDecl GhcRn)
160 deriving instance Data (TyFamInstDecl GhcTc)
161
162 -- deriving instance DataIdLR p p => Data (DataFamInstDecl p)
163 deriving instance Data (DataFamInstDecl GhcPs)
164 deriving instance Data (DataFamInstDecl GhcRn)
165 deriving instance Data (DataFamInstDecl GhcTc)
166
167 -- deriving instance (DataIdLR p p,Data pats,Data rhs)=>Data (FamEqn p pats rhs)
168 deriving instance (Data pats,Data rhs) => Data (FamEqn GhcPs pats rhs)
169 deriving instance (Data pats,Data rhs) => Data (FamEqn GhcRn pats rhs)
170 deriving instance (Data pats,Data rhs) => Data (FamEqn GhcTc pats rhs)
171
172 -- deriving instance (DataIdLR p p) => Data (ClsInstDecl p)
173 deriving instance Data (ClsInstDecl GhcPs)
174 deriving instance Data (ClsInstDecl GhcRn)
175 deriving instance Data (ClsInstDecl GhcTc)
176
177 -- deriving instance (DataIdLR p p) => Data (InstDecl p)
178 deriving instance Data (InstDecl GhcPs)
179 deriving instance Data (InstDecl GhcRn)
180 deriving instance Data (InstDecl GhcTc)
181
182 -- deriving instance (DataIdLR p p) => Data (DerivDecl p)
183 deriving instance Data (DerivDecl GhcPs)
184 deriving instance Data (DerivDecl GhcRn)
185 deriving instance Data (DerivDecl GhcTc)
186
187 -- deriving instance (DataIdLR p p) => Data (DerivStrategy p)
188 deriving instance Data (DerivStrategy GhcPs)
189 deriving instance Data (DerivStrategy GhcRn)
190 deriving instance Data (DerivStrategy GhcTc)
191
192 -- deriving instance (DataIdLR p p) => Data (DefaultDecl p)
193 deriving instance Data (DefaultDecl GhcPs)
194 deriving instance Data (DefaultDecl GhcRn)
195 deriving instance Data (DefaultDecl GhcTc)
196
197 -- deriving instance (DataIdLR p p) => Data (ForeignDecl p)
198 deriving instance Data (ForeignDecl GhcPs)
199 deriving instance Data (ForeignDecl GhcRn)
200 deriving instance Data (ForeignDecl GhcTc)
201
202 -- deriving instance (DataIdLR p p) => Data (RuleDecls p)
203 deriving instance Data (RuleDecls GhcPs)
204 deriving instance Data (RuleDecls GhcRn)
205 deriving instance Data (RuleDecls GhcTc)
206
207 -- deriving instance (DataIdLR p p) => Data (RuleDecl p)
208 deriving instance Data (RuleDecl GhcPs)
209 deriving instance Data (RuleDecl GhcRn)
210 deriving instance Data (RuleDecl GhcTc)
211
212 -- deriving instance (DataIdLR p p) => Data (RuleBndr p)
213 deriving instance Data (RuleBndr GhcPs)
214 deriving instance Data (RuleBndr GhcRn)
215 deriving instance Data (RuleBndr GhcTc)
216
217 -- deriving instance (DataId p) => Data (WarnDecls p)
218 deriving instance Data (WarnDecls GhcPs)
219 deriving instance Data (WarnDecls GhcRn)
220 deriving instance Data (WarnDecls GhcTc)
221
222 -- deriving instance (DataId p) => Data (WarnDecl p)
223 deriving instance Data (WarnDecl GhcPs)
224 deriving instance Data (WarnDecl GhcRn)
225 deriving instance Data (WarnDecl GhcTc)
226
227 -- deriving instance (DataIdLR p p) => Data (AnnDecl p)
228 deriving instance Data (AnnDecl GhcPs)
229 deriving instance Data (AnnDecl GhcRn)
230 deriving instance Data (AnnDecl GhcTc)
231
232 -- deriving instance (DataId p) => Data (RoleAnnotDecl p)
233 deriving instance Data (RoleAnnotDecl GhcPs)
234 deriving instance Data (RoleAnnotDecl GhcRn)
235 deriving instance Data (RoleAnnotDecl GhcTc)
236
237 -- ---------------------------------------------------------------------
238 -- Data derivations from HsExpr ----------------------------------------
239
240 -- deriving instance (DataIdLR p p) => Data (SyntaxExpr p)
241 deriving instance Data (SyntaxExpr GhcPs)
242 deriving instance Data (SyntaxExpr GhcRn)
243 deriving instance Data (SyntaxExpr GhcTc)
244
245 -- deriving instance (DataIdLR p p) => Data (HsExpr p)
246 deriving instance Data (HsExpr GhcPs)
247 deriving instance Data (HsExpr GhcRn)
248 deriving instance Data (HsExpr GhcTc)
249
250 -- deriving instance (DataIdLR p p) => Data (HsTupArg p)
251 deriving instance Data (HsTupArg GhcPs)
252 deriving instance Data (HsTupArg GhcRn)
253 deriving instance Data (HsTupArg GhcTc)
254
255 -- deriving instance (DataIdLR p p) => Data (HsCmd p)
256 deriving instance Data (HsCmd GhcPs)
257 deriving instance Data (HsCmd GhcRn)
258 deriving instance Data (HsCmd GhcTc)
259
260 -- deriving instance (DataIdLR p p) => Data (HsCmdTop p)
261 deriving instance Data (HsCmdTop GhcPs)
262 deriving instance Data (HsCmdTop GhcRn)
263 deriving instance Data (HsCmdTop GhcTc)
264
265 -- deriving instance (DataIdLR p p,Data body) => Data (MatchGroup p body)
266 deriving instance (Data body) => Data (MatchGroup GhcPs body)
267 deriving instance (Data body) => Data (MatchGroup GhcRn body)
268 deriving instance (Data body) => Data (MatchGroup GhcTc body)
269
270 -- deriving instance (DataIdLR p p,Data body) => Data (Match p body)
271 deriving instance (Data body) => Data (Match GhcPs body)
272 deriving instance (Data body) => Data (Match GhcRn body)
273 deriving instance (Data body) => Data (Match GhcTc body)
274
275 -- deriving instance (DataIdLR p p,Data body) => Data (GRHSs p body)
276 deriving instance (Data body) => Data (GRHSs GhcPs body)
277 deriving instance (Data body) => Data (GRHSs GhcRn body)
278 deriving instance (Data body) => Data (GRHSs GhcTc body)
279
280 -- deriving instance (DataIdLR p p,Data body) => Data (GRHS p body)
281 deriving instance (Data body) => Data (GRHS GhcPs body)
282 deriving instance (Data body) => Data (GRHS GhcRn body)
283 deriving instance (Data body) => Data (GRHS GhcTc body)
284
285 -- deriving instance (DataIdLR p p,Data body) => Data (StmtLR p p body)
286 deriving instance (Data body) => Data (StmtLR GhcPs GhcPs body)
287 deriving instance (Data body) => Data (StmtLR GhcPs GhcRn body)
288 deriving instance (Data body) => Data (StmtLR GhcRn GhcRn body)
289 deriving instance (Data body) => Data (StmtLR GhcTc GhcTc body)
290
291 deriving instance Data RecStmtTc
292
293 -- deriving instance (DataIdLR p p) => Data (ParStmtBlock p p)
294 deriving instance Data (ParStmtBlock GhcPs GhcPs)
295 deriving instance Data (ParStmtBlock GhcPs GhcRn)
296 deriving instance Data (ParStmtBlock GhcRn GhcRn)
297 deriving instance Data (ParStmtBlock GhcTc GhcTc)
298
299 -- deriving instance (DataIdLR p p) => Data (ApplicativeArg p)
300 deriving instance Data (ApplicativeArg GhcPs)
301 deriving instance Data (ApplicativeArg GhcRn)
302 deriving instance Data (ApplicativeArg GhcTc)
303
304 -- deriving instance (DataIdLR p p) => Data (HsSplice p)
305 deriving instance Data (HsSplice GhcPs)
306 deriving instance Data (HsSplice GhcRn)
307 deriving instance Data (HsSplice GhcTc)
308
309 -- deriving instance (DataIdLR p p) => Data (HsSplicedThing p)
310 deriving instance Data (HsSplicedThing GhcPs)
311 deriving instance Data (HsSplicedThing GhcRn)
312 deriving instance Data (HsSplicedThing GhcTc)
313
314 -- deriving instance (DataIdLR p p) => Data (HsBracket p)
315 deriving instance Data (HsBracket GhcPs)
316 deriving instance Data (HsBracket GhcRn)
317 deriving instance Data (HsBracket GhcTc)
318
319 -- deriving instance (DataIdLR p p) => Data (ArithSeqInfo p)
320 deriving instance Data (ArithSeqInfo GhcPs)
321 deriving instance Data (ArithSeqInfo GhcRn)
322 deriving instance Data (ArithSeqInfo GhcTc)
323
324 deriving instance Data RecordConTc
325 deriving instance Data CmdTopTc
326 deriving instance Data PendingRnSplice
327 deriving instance Data PendingTcSplice
328
329 -- ---------------------------------------------------------------------
330 -- Data derivations from HsLit ----------------------------------------
331
332 -- deriving instance (DataId p) => Data (HsLit p)
333 deriving instance Data (HsLit GhcPs)
334 deriving instance Data (HsLit GhcRn)
335 deriving instance Data (HsLit GhcTc)
336
337 -- deriving instance (DataIdLR p p) => Data (HsOverLit p)
338 deriving instance Data (HsOverLit GhcPs)
339 deriving instance Data (HsOverLit GhcRn)
340 deriving instance Data (HsOverLit GhcTc)
341
342 -- ---------------------------------------------------------------------
343 -- Data derivations from HsPat -----------------------------------------
344
345 -- deriving instance (DataIdLR p p) => Data (Pat p)
346 deriving instance Data (Pat GhcPs)
347 deriving instance Data (Pat GhcRn)
348 deriving instance Data (Pat GhcTc)
349
350 deriving instance Data ListPatTc
351
352 -- deriving instance (DataIdLR p p, Data body) => Data (HsRecFields p body)
353 deriving instance (Data body) => Data (HsRecFields GhcPs body)
354 deriving instance (Data body) => Data (HsRecFields GhcRn body)
355 deriving instance (Data body) => Data (HsRecFields GhcTc body)
356
357 -- ---------------------------------------------------------------------
358 -- Data derivations from HsTypes ---------------------------------------
359
360 -- deriving instance (DataIdLR p p) => Data (LHsQTyVars p)
361 deriving instance Data (LHsQTyVars GhcPs)
362 deriving instance Data (LHsQTyVars GhcRn)
363 deriving instance Data (LHsQTyVars GhcTc)
364
365 -- deriving instance (DataIdLR p p, Data thing) =>Data (HsImplicitBndrs p thing)
366 deriving instance (Data thing) => Data (HsImplicitBndrs GhcPs thing)
367 deriving instance (Data thing) => Data (HsImplicitBndrs GhcRn thing)
368 deriving instance (Data thing) => Data (HsImplicitBndrs GhcTc thing)
369
370 -- deriving instance (DataIdLR p p, Data thing) =>Data (HsWildCardBndrs p thing)
371 deriving instance (Data thing) => Data (HsWildCardBndrs GhcPs thing)
372 deriving instance (Data thing) => Data (HsWildCardBndrs GhcRn thing)
373 deriving instance (Data thing) => Data (HsWildCardBndrs GhcTc thing)
374
375 -- deriving instance (DataIdLR p p) => Data (HsTyVarBndr p)
376 deriving instance Data (HsTyVarBndr GhcPs)
377 deriving instance Data (HsTyVarBndr GhcRn)
378 deriving instance Data (HsTyVarBndr GhcTc)
379
380 -- deriving instance (DataIdLR p p) => Data (HsType p)
381 deriving instance Data (HsType GhcPs)
382 deriving instance Data (HsType GhcRn)
383 deriving instance Data (HsType GhcTc)
384
385 -- deriving instance (DataIdLR p p) => Data (HsAppType p)
386 deriving instance Data (HsAppType GhcPs)
387 deriving instance Data (HsAppType GhcRn)
388 deriving instance Data (HsAppType GhcTc)
389
390 -- deriving instance (DataIdLR p p) => Data (ConDeclField p)
391 deriving instance Data (ConDeclField GhcPs)
392 deriving instance Data (ConDeclField GhcRn)
393 deriving instance Data (ConDeclField GhcTc)
394
395 -- deriving instance (DataId p) => Data (FieldOcc p)
396 deriving instance Data (FieldOcc GhcPs)
397 deriving instance Data (FieldOcc GhcRn)
398 deriving instance Data (FieldOcc GhcTc)
399
400 -- deriving instance DataId p => Data (AmbiguousFieldOcc p)
401 deriving instance Data (AmbiguousFieldOcc GhcPs)
402 deriving instance Data (AmbiguousFieldOcc GhcRn)
403 deriving instance Data (AmbiguousFieldOcc GhcTc)
404
405
406 -- deriving instance (DataId name) => Data (ImportDecl name)
407 deriving instance Data (ImportDecl GhcPs)
408 deriving instance Data (ImportDecl GhcRn)
409 deriving instance Data (ImportDecl GhcTc)
410
411 -- deriving instance (DataId name) => Data (IE name)
412 deriving instance Data (IE GhcPs)
413 deriving instance Data (IE GhcRn)
414 deriving instance Data (IE GhcTc)
415
416 -- deriving instance (Eq name, Eq (IdP name)) => Eq (IE name)
417 deriving instance Eq (IE GhcPs)
418 deriving instance Eq (IE GhcRn)
419 deriving instance Eq (IE GhcTc)
420
421 -- ---------------------------------------------------------------------