-
Notifications
You must be signed in to change notification settings - Fork 1
/
HsDecls.hs
352 lines (304 loc) · 10.6 KB
/
HsDecls.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE TypeFamilies #-}
module HsDecls where
import Dependencies
import HsExtension
import {-# SOURCE #-} HsExpr
import HsDoc
import HsTypes
import HsBinds
import ForeignCall
type LHsDecl p = Located (HsDecl p)
data HsDecl p
= TyClD (XTyClD p) (TyClDecl p)
| InstD (XInstD p) (InstDecl p)
| DerivD (XDerivD p) (DerivDecl p)
| ValD (XValD p) (HsBind p)
| SigD (XSigD p) (Sig p)
| DefD (XDefD p) (DefaultDecl p)
| ForD (XForD p) (ForeignDecl p)
| WarningD (XWarningD p) (WarnDecls p)
| AnnD (XAnnD p) (AnnDecl p)
| RuleD (XRuleD p) (RuleDecls p)
| SpliceD (XSpliceD p) (SpliceDecl p)
| DocD (XDocD p) (DocDecl)
| RoleAnnotD (XRoleAnnotD p) (RoleAnnotDecl p)
| XHsDecl (XXHsDecl p)
data HsGroup p
= HsGroup {
hs_ext :: XCHsGroup p,
hs_valds :: HsValBinds p,
hs_splcds :: [LSpliceDecl p],
hs_tyclds :: [TyClGroup p],
hs_derivds :: [LDerivDecl p],
hs_fixds :: [LFixitySig p],
hs_defds :: [LDefaultDecl p],
hs_fords :: [LForeignDecl p],
hs_warnds :: [LWarnDecls p],
hs_annds :: [LAnnDecl p],
hs_ruleds :: [LRuleDecls p],
hs_docs :: [LDocDecl]
}
| XHsGroup (XXHsGroup p)
type LSpliceDecl p = Located (SpliceDecl p)
data SpliceDecl p
= SpliceDecl
(XSpliceDecl p)
(LHsSplice p)
SpliceExplicitFlag
| XSpliceDecl (XXSpliceDecl p)
type LTyClDecl p = Located (TyClDecl p)
data TyClDecl p
= FamDecl { tcdFExt :: XFamDecl p
, tcdFam :: FamilyDecl p }
| SynDecl { tcdSExt :: XSynDecl p
, tcdLName :: LIdP p
, tcdTyVars :: LHsQTyVars p
, tcdFixity :: LexicalFixity
, tcdRhs :: LHsType p }
| DataDecl { tcdDExt :: XDataDecl p
, tcdLName :: LIdP p
, tcdTyVars :: LHsQTyVars p
, tcdFixity :: LexicalFixity
, tcdDataDefn :: HsDataDefn p }
| ClassDecl { tcdCExt :: XClassDecl p,
tcdCtxt :: LHsContext p,
tcdLName :: LIdP p,
tcdTyVars :: LHsQTyVars p,
tcdFixity :: LexicalFixity,
tcdFDs :: [LFunDep (LIdP p)], --TTG: todo: fix parameter
tcdSigs :: [LSig p],
tcdMeths :: LHsBinds p,
tcdATs :: [LFamilyDecl p],
tcdATDefs :: [LTyFamDefltEqn p],
tcdDocs :: [LDocDecl] }
| XTyClDecl (XXTyClDecl p)
data TyClGroup p
= TyClGroup { group_ext :: XCTyClGroup p
, group_tyclds :: [LTyClDecl p]
, group_roles :: [LRoleAnnotDecl p]
, group_instds :: [LInstDecl p] }
| XTyClGroup (XXTyClGroup p)
type LFamilyResultSig p = Located (FamilyResultSig p)
data FamilyResultSig p
= NoSig (XNoSig p)
| KindSig (XCKindSig p) (LHsKind p)
| TyVarSig (XTyVarSig p) (LHsTyVarBndr p)
| XFamilyResultSig (XXFamilyResultSig p)
type LFamilyDecl p = Located (FamilyDecl p)
data FamilyDecl p
= FamilyDecl { fdExt :: XCFamilyDecl p
, fdInfo :: FamilyInfo p
, fdLName :: LIdP p
, fdTyVars :: LHsQTyVars p
, fdFixity :: LexicalFixity
, fdResultSig :: LFamilyResultSig p
, fdInjectivityAnn :: Maybe (LInjectivityAnn p) }
| XFamilyDecl (XXFamilyDecl p)
type LInjectivityAnn p = Located (InjectivityAnn p)
data InjectivityAnn p
= InjectivityAnn (LIdP p) [LIdP p]
data FamilyInfo p
= DataFamily
| OpenTypeFamily
| ClosedTypeFamily (Maybe [LTyFamInstEqn p])
data HsDataDefn p
= HsDataDefn { dd_ext :: XCHsDataDefn p,
dd_ND :: NewOrData,
dd_ctxt :: LHsContext p,
dd_cType :: Maybe (Located CType), -- TTG: todo: SrcLocs
dd_kindSig:: Maybe (LHsKind p),
dd_cons :: [LConDecl p],
dd_derivs :: HsDeriving p
}
| XHsDataDefn (XXHsDataDefn p)
type HsDeriving p = Located [LHsDerivingClause p]
type LHsDerivingClause p = Located (HsDerivingClause p)
data HsDerivingClause p
= HsDerivingClause
{ deriv_clause_ext :: XCHsDerivingClause p
, deriv_clause_strategy :: Maybe (LDerivStrategy p)
, deriv_clause_tys :: Located [LHsSigType p] -- TTG: todo: SrcLocs
}
| XHsDerivingClause (XXHsDerivingClause p)
data NewOrData
= NewType
| DataType
type LConDecl p = Located (ConDecl p)
data ConDecl p
= ConDeclGADT
{ con_g_ext :: XConDeclGADT p
, con_names :: [LIdP p]
, con_forall :: Located Bool -- TTG: todo: SrcLocs
, con_qvars :: LHsQTyVars p
, con_mb_cxt :: Maybe (LHsContext p)
, con_args :: HsConDeclDetails p
, con_res_ty :: LHsType p
, con_doc :: Maybe LHsDocString
}
| ConDeclH98
{ con_ext :: XConDeclH98 p
, con_name :: LIdP p
, con_forall :: Located Bool -- TTG: todo: SrcLocs
, con_ex_tvs :: [LHsTyVarBndr p]
, con_mb_cxt :: Maybe (LHsContext p)
, con_args :: HsConDeclDetails p
, con_doc :: Maybe LHsDocString
}
| XConDecl (XXConDecl p)
type HsConDeclDetails p
= HsConDetails (LBangType p) (Located [LConDeclField p]) -- TTG: todo: SrcLocs
type LTyFamInstEqn p = Located (TyFamInstEqn p)
type TyFamInstEqn p = FamInstEqn p (LHsType p)
type HsTyPats p = [LHsType p]
type LTyFamDefltEqn p = Located (TyFamDefltEqn p)
type TyFamDefltEqn p = FamEqn p (LHsQTyVars p) (LHsType p)
type LTyFamInstDecl p = Located (TyFamInstDecl p)
newtype TyFamInstDecl p = TyFamInstDecl { tfid_eqn :: TyFamInstEqn p }
type LDataFamInstDecl p = Located (DataFamInstDecl p)
newtype DataFamInstDecl p
= DataFamInstDecl { dfid_eqn :: FamInstEqn p (HsDataDefn p) }
type LFamInstEqn p rhs = Located (FamInstEqn p rhs)
type FamInstEqn p rhs
= HsImplicitBndrs p (FamEqn p (HsTyPats p) rhs)
data FamEqn p pats rhs
= FamEqn
{ feqn_ext :: XCFamEqn p pats rhs
, feqn_tycon :: LIdP p
, feqn_pats :: pats
, feqn_fixity :: LexicalFixity
, feqn_rhs :: rhs
}
| XFamEqn (XXFamEqn p pats rhs)
type LClsInstDecl p = Located (ClsInstDecl p)
data ClsInstDecl p
= ClsInstDecl
{ cid_ext :: XCClsInstDecl p
, cid_poly_ty :: LHsSigType p
, cid_binds :: LHsBinds p
, cid_sigs :: [LSig p]
, cid_tyfam_insts :: [LTyFamInstDecl p]
, cid_datafam_insts :: [LDataFamInstDecl p]
, cid_overlap_mode :: Maybe (Located OverlapMode) -- TTG: todo: SrcLocs
}
| XClsInstDecl (XXClsInstDecl p)
type LInstDecl p = Located (InstDecl p)
data InstDecl p
= ClsInstD
{ cid_d_ext :: XClsInstD p
, cid_inst :: ClsInstDecl p }
| DataFamInstD
{ dfid_ext :: XDataFamInstD p
, dfid_inst :: DataFamInstDecl p }
| TyFamInstD
{ tfid_ext :: XTyFamInstD p
, tfid_inst :: TyFamInstDecl p }
| XInstDecl (XXInstDecl p)
type LDerivDecl p = Located (DerivDecl p)
data DerivDecl p = DerivDecl
{ deriv_ext :: XCDerivDecl p
, deriv_type :: LHsSigWcType p
, deriv_strategy :: Maybe (LDerivStrategy p)
, deriv_overlap_mode :: Maybe (Located OverlapMode) -- TTG: todo: SrcLocs
}
| XDerivDecl (XXDerivDecl p)
type LDerivStrategy p = Located (DerivStrategy p)
data DerivStrategy p
= StockStrategy
| AnyclassStrategy
| NewtypeStrategy
| ViaStrategy (XViaStrategy p)
type LDefaultDecl p = Located (DefaultDecl p)
data DefaultDecl p
= DefaultDecl (XCDefaultDecl p) [LHsType p]
| XDefaultDecl (XXDefaultDecl p)
type LForeignDecl p = Located (ForeignDecl p)
data ForeignDecl p
= ForeignImport
{ fd_i_ext :: XForeignImport p
, fd_name :: LIdP p
, fd_sig_ty :: LHsSigType p
, fd_fi :: ForeignImport }
| ForeignExport
{ fd_e_ext :: XForeignExport p
, fd_name :: LIdP p
, fd_sig_ty :: LHsSigType p
, fd_fe :: ForeignExport }
| XForeignDecl (XXForeignDecl p)
data ForeignImport
= CImport (Located CCallConv) -- TTG: todo: SrcLocs
(Located Safety) -- TTG: todo: SrcLocs
(Maybe Header)
CImportSpec
{- TTG-Todo
(Located SourceText)
-}
data CImportSpec = CLabel CLabelString
| CFunction CCallTarget
| CWrapper
data ForeignExport = CExport (Located CExportSpec) -- TTG: todo: SrcLocs
{- TTG-Todo
(Located SourceText)
-}
type LRuleDecls p = Located (RuleDecls p)
data RuleDecls p = HsRules { rds_ext :: XCRuleDecls p
{- TTG-Todo
, rds_src :: SourceText
-}
, rds_rules :: [LRuleDecl p] }
| XRuleDecls (XXRuleDecls p)
type LRuleDecl p = Located (RuleDecl p)
data RuleDecl p
= HsRule
(XHsRule p)
{- TTG-Todo
(Located (SourceText,RuleName))
-}
(Located RuleName) -- TTG-Todo new
-- TTG: todo: SrcLocs
Activation
[LRuleBndr p]
(LHsExpr p)
(LHsExpr p)
| XRuleDecl (XXRuleDecl p)
type LRuleBndr p = Located (RuleBndr p)
data RuleBndr p
= RuleBndr (XCRuleBndr p) (LIdP p)
| RuleBndrSig (XRuleBndrSig p) (LIdP p) (LHsSigWcType p)
| XRuleBndr (XXRuleBndr p)
type LDocDecl = Located (DocDecl)
data DocDecl
= DocCommentNext HsDocString
| DocCommentPrev HsDocString
| DocCommentNamed String HsDocString
| DocGroup Int HsDocString
type LWarnDecls p = Located (WarnDecls p)
data WarnDecls p
= Warnings { wd_ext :: XWarnings p
{- TTG-Todo
, wd_src :: SourceText
-}
, wd_warnings :: [LWarnDecl p] }
| XWarnDecls (XXWarnDecls p)
type LWarnDecl p = Located (WarnDecl p)
data WarnDecl p
= Warning (XWarning p) [LIdP p] WarningTxt
| XWarnDecl (XXWarnDecl p)
type LAnnDecl p = Located (AnnDecl p)
data AnnDecl p
= HsAnnotation (XHsAnnotation p)
{- TTG-Todo
SourceText
-}
(AnnProvenance (IdP p)) (LHsExpr p)
| XAnnDecl (XXAnnDecl p)
data AnnProvenance name
= ValueAnnProvenance (Located name)
| TypeAnnProvenance (Located name)
| ModuleAnnProvenance
type LRoleAnnotDecl p = Located (RoleAnnotDecl p)
data RoleAnnotDecl p
= RoleAnnotDecl (XCRoleAnnotDecl p)
(LIdP p)
[Located (Maybe Role)] -- TTG: todo: SrcLocs
| XRoleAnnotDecl (XXRoleAnnotDecl p)