PrintAs.hs revision da245da15da78363c896e44ea97a14ab1f83eb50
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder Authors: Christian Maeder
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder printing As data types
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maederimport qualified Common.Lib.Set as Set
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maederimport Common.GlobalAnnotations(GlobalAnnos)
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maedercommas, semis :: PrettyPrint a => GlobalAnnos -> [a] -> Doc
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maedercommas = commaT printText0
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maedersemis = semiT printText0
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint TypePattern where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypePattern name args _) = printText0 ga name
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> fcat (map (parens . printText0 ga) args)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypePatternToken t) = printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (MixfixTypePattern ts) = fsep (map (printText0 ga) ts)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (BracketTypePattern k l _) = bracket k $ commas ga l
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (TypePatternArg t _) = parens $ printText0 ga t
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maederbracket :: BracketKind -> Doc -> Doc
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederbracket Parens t = parens t
30203b61afb4393c8e459470b3a16d1fe26acc7fChristian Maederbracket Squares t = brackets t
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederbracket Braces t = braces t
024621f43239cfe9629e35d35a8669fad7acbba2Christian MaederprintKind :: GlobalAnnos -> Kind -> Doc
024621f43239cfe9629e35d35a8669fad7acbba2Christian MaederprintKind ga kind = case kind of
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder ExtClass (Intersection s _) InVar _ ->
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder if Set.isEmpty s then empty else erg
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder where erg = space <> colon <> printText0 ga kind
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Type where
cde8e3d436089010ac1218ae57b8215203116a49Christian Maeder printText0 ga (TypeName name _k _i) = printText0 ga name
b49276c9f50038e0bd499ad49f7bd6444566a834Christian Maeder-- <> printKind ga k
cde8e3d436089010ac1218ae57b8215203116a49Christian Maeder-- <> if i == 0 then empty
cde8e3d436089010ac1218ae57b8215203116a49Christian Maeder-- else parens (int i)
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder printText0 ga (TypeAppl t1 t2) = parens (printText0 ga t1)
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder <> parens (printText0 ga t2)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypeToken t) = printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (BracketType k l _) = bracket k $ commas ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (KindedType t kind _) = printText0 ga t
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder <> space <> colon <> printText0 ga kind
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (MixfixType ts) = fsep (map (printText0 ga) ts)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (LazyType t _) = text quMark <+> printText0 ga (t)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (ProductType ts _) = fsep (punctuate (space <> text timesS)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (map (printText0 ga) ts))
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (FunType t1 arr t2 _) = printText0 ga t1
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga arr
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t2
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maederinstance PrettyPrint Pred where
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder printText0 ga (IsIn c ts) = if null ts then printText0 ga c
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder else if null $ tail ts then
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder printText0 ga (head ts) <+>
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder colon <+> printText0 ga c
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder else printText0 ga c <+>
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder fsep (punctuate space
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder (map (printText0 ga) ts))
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maederinstance PrettyPrint t => PrettyPrint (Qual t) where
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder printText0 ga (ps :=> t) = (if null ps then empty
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder else parens $ commas ga ps <+>
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder ptext implS <+> space) <>
a05bca7a10260c19581dff325389de3f8edefa5eChristian Maeder printText0 ga t
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder-- no curried notation for bound variables
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint TypeScheme where
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (TypeScheme vs t _) = noPrint (null vs) (text forallS
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maeder <+> semis ga vs
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maeder <+> text dotS <+> space)
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maeder <> printText0 ga t
fe883661c9d1a5a8b42ac4e8673ec133d9dad354Christian Maederinstance PrettyPrint Partiality where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Partial = text quMark
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Total = text exMark
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Arrow where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ FunArr = text funS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ PFunArr = text pFun
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ ContFunArr = text contFun
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ PContFunArr = text pContFun
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Quantifier where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Universal = text forallS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Existential = text existsS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Unique = text $ existsS ++ exMark
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint TypeQual where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ OfType = colon
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ AsType = text asS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ InType = text inS
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maederinstance PrettyPrint LogOp where
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ NotOp = text notS
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ AndOp = text lAnd
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ OrOp = text lOr
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ ImplOp = text implS
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ EquivOp = text equivS
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maederinstance PrettyPrint EqOp where
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ EqualOp = text equalS
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 _ ExEqualOp = text exEqual
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Formula where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TermFormula t) = printText0 ga t
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga (ConnectFormula o fs _) = parens $
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder fsep (punctuate (space <> printText0 ga o) (map (printText0 ga) fs))
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga (EqFormula o t1 t2 _) = printText0 ga t1
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder <+> printText0 ga o
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder <+> printText0 ga t2
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga (DefFormula t _) = text defS <+> printText0 ga t
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga (QuantifiedFormula q vs f _) =
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga q <+> semis ga vs <+> text dotS <+> printText0 ga f
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder printText0 ga (PolyFormula ts f _) =
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder text forallS <+> semis ga ts <+> text dotS <+> printText0 ga f
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Term where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (CondTerm t1 f t2 _) = printText0 ga t1
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> text whenS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga f
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> text elseS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t2
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (QualVar v t _) = parens $ text varS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga v
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (QualOp n t _) = parens $
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga n
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (ApplTerm t1 t2 _) = printText0 ga t1
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> parens (printText0 ga t2)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TupleTerm ts _) = parens $ commas ga ts
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypedTerm term q typ _) = printText0 ga term
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga q
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga typ
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (QuantifiedTerm q vs t _) = printText0 ga q
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> semis ga vs
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> text dotS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (LambdaTerm ps q t _) = text lamS
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> (if length ps == 1 then
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga $ head ps
c0467970183fa3dc894edea3caf9ca05d3a09fa8Christian Maeder else fcat $ map
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> (case q of
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder Partial -> text dotS
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder Total -> text $ dotS ++ exMark)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (CaseTerm t es _ ) = text caseS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> vcat (punctuate (text " | ")
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (map (printEq0 ga funS) es))
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (LetTerm es t _) = text letS
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <+> vcat (punctuate semi
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (map (printEq0 ga equalS) es))
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TermToken t) = printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (MixfixTerm ts) = fsep $ map (printText0 ga) ts
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (BracketTerm k l _) = bracket k $ commas ga l
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Pattern where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PatternVars vs _) = semis ga vs
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PatternConstr n t args _) = printText0 ga n
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> fcat (map (parens.printText0 ga) args)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PatternToken t) = printText0 ga t
dc808c58c91f82311454b4b66d206cd813d0aa70Christian Maeder printText0 ga (BracketPattern k l _) =
dc808c58c91f82311454b4b66d206cd813d0aa70Christian Maeder [TuplePattern _ _] -> printText0 ga $ head l
dc808c58c91f82311454b4b66d206cd813d0aa70Christian Maeder _ -> bracket k $ commas ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TuplePattern ps _) = parens $ commas ga ps
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (MixfixPattern ps) = fsep (map (printText0 ga) ps)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypedPattern p t _) = printText0 ga p
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (AsPattern v p _) = printText0 ga v
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga p
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian MaederprintEq0 :: GlobalAnnos -> String -> ProgEq -> Doc
86c119e3e74ba4b1b4ca728531282e9100789939Christian MaederprintEq0 ga s (ProgEq p t _) = fsep [printText0 ga p
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder , printText0 ga t]
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint VarDecl where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (VarDecl v t _ _) = printText0 ga v <+> colon
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint GenVarDecl where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (GenVarDecl v) = printText0 ga v
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (GenTypeVarDecl tv) = printText0 ga tv
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint TypeArg where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypeArg v c _ _) = printText0 ga v <> colon
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> printText0 ga c
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Variance where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ CoVar = text plusS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ ContraVar = text minusS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ InVar = empty
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maederinstance PrettyPrint Kind where
5d2f1a7947dde4ff340f8d4908ae0f22c74fdedaChristian Maeder printText0 ga (ExtClass k v _) = printText0 ga k
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder <> printText0 ga v
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder printText0 ga (KindAppl k1 k2 _) =
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder KindAppl _ _ _ -> parens
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder _ -> id) (printText0 ga k1)
e289294500ad68fa0706b09521af340bbb356a69Christian Maeder <+> text funS
a64a0692ffff29e0846ca325b1811266a9f105e0Christian Maeder <> printText0 ga k2
da245da15da78363c896e44ea97a14ab1f83eb50Christian MaederprintList0 :: (PrettyPrint a) => GlobalAnnos -> [a] -> Doc
da245da15da78363c896e44ea97a14ab1f83eb50Christian MaederprintList0 ga l = noPrint (null l)
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder (if null $ tail l then printText0 ga $ head l
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder else parens $ commas ga l)
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maederinstance PrettyPrint Class where
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder printText0 ga (Downset t) = braces $
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder text "_" <+> text lessS <+> printText0 ga t
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder printText0 ga (Intersection c _) = if Set.isEmpty c then ptext "Type"
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder else printList0 ga $ Set.toList c
7c57322afb6342e5cc8b1fdc96050b707407fc61Christian Maederinstance PrettyPrint InstOpId where
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (InstOpId n l _) = printText0 ga n
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <> noPrint (null l)
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder (brackets $ semis ga l)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder------------------------------------------------------------------------
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder------------------------------------------------------------------------
51281dddda866c0cda9fca22bf6bc4eea7128112Christian MaederprintPseudoType :: GlobalAnnos -> TypeScheme -> Doc
51281dddda866c0cda9fca22bf6bc4eea7128112Christian MaederprintPseudoType ga (TypeScheme l t _) = noPrint (null l) (text lamS
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder <+> (if null $ tail l then
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder printText0 ga $ head l
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder else fcat(map (parens . printText0 ga) l))
42da000066c803fbbbe9e13bf6326888de3bbdc7Christian Maeder <+> text dotS <+> space) <> printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint BasicSpec where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (BasicSpec l) = vcat (map (printText0 ga) l)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint ProgEq where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga = printEq0 ga equalS
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint BasicItem where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (SigItems s) = printText0 ga s
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (ProgItems l _) = text programS <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (ClassItems i l _) = text classS <+> printText0 ga i
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (GenVarItems l _) = text varS <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (FreeDatatype l _) = text freeS <+> text typeS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (GenItems l _) = text generatedS <+> braces (semis ga l)
d24cb84dba35006c81c22c0fc4215f63c22858efChristian Maeder printText0 ga (AxiomItems vs fs _) = (if null vs then empty
d24cb84dba35006c81c22c0fc4215f63c22858efChristian Maeder else text forallS <+> semis ga vs)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (\x -> text dotS <+> printText0 ga x)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint SigItems where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypeItems i l _) = text typeS <+> printText0 ga i
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (OpItems l _) = text opS <+> semis ga l
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PredItems l _) = text predS <+> semis ga l
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint Instance where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Instance = text instanceS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ _ = empty
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint ClassItem where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (ClassItem d l _) = printText0 ga d $$
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder if null l then empty
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder else braces (semis ga l)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint ClassDecl where
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (ClassDecl l k _) = commas ga l <> printKind ga k
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (SubclassDecl l k s _) = commas ga l
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <> printKind ga k
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <+> text lessS
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <+> printText0 ga s
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (ClassDefn n k c _) = printText0 ga n
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <> printKind ga k
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <+> text equalS
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <+> printText0 ga c
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder printText0 ga (DownsetDefn c v t _) =
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder let pv = printText0 ga v in
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder printText0 ga c
ae464ac109d82566feab1acbc98eab3bf1f10bb3Christian Maeder <> text equalS
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder <> braces (pv <> text dotS <> pv
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder <> text lessS
078dd2f6a402c8d9804616dc9616b27ce380a2eaChristian Maeder <+> printText0 ga t)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint TypeItem where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (TypeDecl l k _) = commas ga l <>
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maeder printKind ga k
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (SubtypeDecl l t _) = commas ga l <+> text lessS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (IsoDecl l _) = cat(punctuate (text " = ")
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (map (printText0 ga) l))
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (SubtypeDefn p v t f _) = printText0 ga p
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text equalS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> braces (printText0 ga v
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text dotS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga f)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (AliasType p k t _) = (printText0 ga p <>
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder Nothing -> empty
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder Just j -> space <> colon <>
715a002611e0c503c11cc3aa80835763215e689dChristian Maeder printText ga j)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text assignS
51281dddda866c0cda9fca22bf6bc4eea7128112Christian Maeder <+> printPseudoType ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (Datatype t) = printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint OpItem where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (OpDecl l t as _) = commas ga l <+> colon
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> (printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <> (if null as then empty else comma)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> commas ga as)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (OpDefn n ps s p t _) = (printText0 ga n
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> fcat (map (printText0 ga) ps))
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> (colon <> if p == Partial
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder then text quMark else empty)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga s
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text equalS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint PredItem where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PredDecl l t _) = commas ga l <+> colon <+> printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (PredDefn n ps f _) = (printText0 ga n
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> fcat (map (printText0 ga) ps))
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text equivS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga f
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint BinOpAttr where
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Assoc = text assocS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Comm = text commS
4e1eee47e914d754644cc396647b6997a28d3704Christian Maeder printText0 _ Idem = text idemS
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint OpAttr where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (BinOpAttr a _) = printText0 ga a
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (UnitOpAttr t _) = text unitS <+> printText0 ga t
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint DatatypeDecl where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (DatatypeDecl p k as d _) = (printText0 ga p <>
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maeder printKind ga k)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> text defnS
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> vcat(punctuate (text " | ")
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder (map (printText0 ga) as))
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <+> case d of { Nothing -> empty
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder ; Just c -> text derivingS
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga c
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint Alternative where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (Constructor n cs p _) = printText0 ga n
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <> fcat (map (printText0 ga) cs)
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder <> (case p of {Partial -> text quMark;
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (Subtype l _) = text typeS <+> commas ga l
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maederinstance PrettyPrint Components where
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (Selector n p t _ _) = printText0 ga n
c0467970183fa3dc894edea3caf9ca05d3a09fa8Christian Maeder <> colon <> (case p of { Partial ->text quMark;
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder <+> printText0 ga t)
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (NoSelector t) = printText0 ga t
86c119e3e74ba4b1b4ca728531282e9100789939Christian Maeder printText0 ga (NestedComponents l _) = parens $ semis ga l
7c57322afb6342e5cc8b1fdc96050b707407fc61Christian Maederinstance PrettyPrint OpId where
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder printText0 ga (OpId n ts _) = printText0 ga n
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder <+> noPrint (null ts)
49a475aee8bae6c05798d65fddf13ec6da66f0beChristian Maeder (brackets $ commas ga ts)