@fncts/schema 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/AST.d.ts +19 -6
  2. package/ASTAnnotation.d.ts +10 -2
  3. package/ParseError/ParseError.d.ts +231 -0
  4. package/ParseError/ParseErrorFormatter.d.ts +2 -0
  5. package/ParseError/PathFormatter.d.ts +13 -0
  6. package/ParseError/TreeFormatter.d.ts +14 -0
  7. package/ParseError.d.ts +4 -144
  8. package/ParseResult.d.ts +1 -8
  9. package/Parser/interpreter.d.ts +0 -1
  10. package/Schema/api/conc.d.ts +0 -2
  11. package/Schema/api/hashMap.d.ts +0 -1
  12. package/Schema/api/hashSet.d.ts +0 -1
  13. package/Schema/api/immutableArray.d.ts +0 -1
  14. package/Schema/api/list.d.ts +1 -2
  15. package/Schema/api/map.d.ts +19 -0
  16. package/Schema/api/set.d.ts +19 -0
  17. package/Schema/api.d.ts +11 -1
  18. package/Schema.d.ts +2 -0
  19. package/Show.d.ts +7 -3
  20. package/_cjs/AST.cjs +181 -114
  21. package/_cjs/AST.cjs.map +1 -1
  22. package/_cjs/ASTAnnotation.cjs +7 -2
  23. package/_cjs/ASTAnnotation.cjs.map +1 -1
  24. package/_cjs/ASTAnnotationMap.cjs +1 -1
  25. package/_cjs/ASTAnnotationMap.cjs.map +1 -1
  26. package/_cjs/Gen.cjs +25 -25
  27. package/_cjs/Gen.cjs.map +1 -1
  28. package/_cjs/Guard.cjs +1 -1
  29. package/_cjs/Guard.cjs.map +1 -1
  30. package/_cjs/InvalidInterpretationError.cjs.map +1 -1
  31. package/_cjs/ParseError/ParseError.cjs +260 -0
  32. package/_cjs/ParseError/ParseError.cjs.map +1 -0
  33. package/_cjs/ParseError/ParseErrorFormatter.cjs +6 -0
  34. package/_cjs/ParseError/ParseErrorFormatter.cjs.map +1 -0
  35. package/_cjs/ParseError/PathFormatter.cjs +94 -0
  36. package/_cjs/ParseError/PathFormatter.cjs.map +1 -0
  37. package/_cjs/ParseError/TreeFormatter.cjs +123 -0
  38. package/_cjs/ParseError/TreeFormatter.cjs.map +1 -0
  39. package/_cjs/ParseError.cjs +43 -289
  40. package/_cjs/ParseError.cjs.map +1 -1
  41. package/_cjs/ParseResult.cjs +2 -11
  42. package/_cjs/ParseResult.cjs.map +1 -1
  43. package/_cjs/Parser/api.cjs +3 -3
  44. package/_cjs/Parser/api.cjs.map +1 -1
  45. package/_cjs/Parser/definition.cjs +2 -2
  46. package/_cjs/Parser/definition.cjs.map +1 -1
  47. package/_cjs/Parser/interpreter.cjs +122 -118
  48. package/_cjs/Parser/interpreter.cjs.map +1 -1
  49. package/_cjs/Parser.cjs.map +1 -1
  50. package/_cjs/Schema/api/conc.cjs +36 -46
  51. package/_cjs/Schema/api/conc.cjs.map +1 -1
  52. package/_cjs/Schema/api/either.cjs +25 -31
  53. package/_cjs/Schema/api/either.cjs.map +1 -1
  54. package/_cjs/Schema/api/hashMap.cjs +42 -102
  55. package/_cjs/Schema/api/hashMap.cjs.map +1 -1
  56. package/_cjs/Schema/api/hashSet.cjs +47 -107
  57. package/_cjs/Schema/api/hashSet.cjs.map +1 -1
  58. package/_cjs/Schema/api/immutableArray.cjs +23 -49
  59. package/_cjs/Schema/api/immutableArray.cjs.map +1 -1
  60. package/_cjs/Schema/api/list.cjs +36 -53
  61. package/_cjs/Schema/api/list.cjs.map +1 -1
  62. package/_cjs/Schema/api/map.cjs +97 -0
  63. package/_cjs/Schema/api/map.cjs.map +1 -0
  64. package/_cjs/Schema/api/maybe.cjs +25 -36
  65. package/_cjs/Schema/api/maybe.cjs.map +1 -1
  66. package/_cjs/Schema/api/set.cjs +76 -0
  67. package/_cjs/Schema/api/set.cjs.map +1 -0
  68. package/_cjs/Schema/api.cjs +21 -3
  69. package/_cjs/Schema/api.cjs.map +1 -1
  70. package/_cjs/Schema/definition.cjs +1 -1
  71. package/_cjs/Schema/definition.cjs.map +1 -1
  72. package/_cjs/Schema/derivations.cjs +1 -1
  73. package/_cjs/Schema/derivations.cjs.map +1 -1
  74. package/_cjs/Schema.cjs +22 -0
  75. package/_cjs/Schema.cjs.map +1 -1
  76. package/_cjs/Show.cjs +107 -90
  77. package/_cjs/Show.cjs.map +1 -1
  78. package/_cjs/global.cjs.map +1 -1
  79. package/_cjs/index.cjs.map +1 -1
  80. package/_cjs/utils.cjs +6 -1
  81. package/_cjs/utils.cjs.map +1 -1
  82. package/_mjs/AST.mjs +177 -112
  83. package/_mjs/AST.mjs.map +1 -1
  84. package/_mjs/ASTAnnotation.mjs +5 -0
  85. package/_mjs/ASTAnnotation.mjs.map +1 -1
  86. package/_mjs/ASTAnnotationMap.mjs.map +1 -1
  87. package/_mjs/Gen.mjs +24 -24
  88. package/_mjs/Gen.mjs.map +1 -1
  89. package/_mjs/Guard.mjs.map +1 -1
  90. package/_mjs/InvalidInterpretationError.mjs.map +1 -1
  91. package/_mjs/ParseError/ParseError.mjs +228 -0
  92. package/_mjs/ParseError/ParseError.mjs.map +1 -0
  93. package/_mjs/ParseError/ParseErrorFormatter.mjs +2 -0
  94. package/_mjs/ParseError/ParseErrorFormatter.mjs.map +1 -0
  95. package/_mjs/ParseError/PathFormatter.mjs +86 -0
  96. package/_mjs/ParseError/PathFormatter.mjs.map +1 -0
  97. package/_mjs/ParseError/TreeFormatter.mjs +113 -0
  98. package/_mjs/ParseError/TreeFormatter.mjs.map +1 -0
  99. package/_mjs/ParseError.mjs +6 -270
  100. package/_mjs/ParseError.mjs.map +1 -1
  101. package/_mjs/ParseResult.mjs +1 -9
  102. package/_mjs/ParseResult.mjs.map +1 -1
  103. package/_mjs/Parser/api.mjs +2 -2
  104. package/_mjs/Parser/api.mjs.map +1 -1
  105. package/_mjs/Parser/definition.mjs +1 -1
  106. package/_mjs/Parser/definition.mjs.map +1 -1
  107. package/_mjs/Parser/interpreter.mjs +121 -117
  108. package/_mjs/Parser/interpreter.mjs.map +1 -1
  109. package/_mjs/Parser.mjs.map +1 -1
  110. package/_mjs/Schema/api/conc.mjs +35 -44
  111. package/_mjs/Schema/api/conc.mjs.map +1 -1
  112. package/_mjs/Schema/api/either.mjs +24 -30
  113. package/_mjs/Schema/api/either.mjs.map +1 -1
  114. package/_mjs/Schema/api/hashMap.mjs +41 -101
  115. package/_mjs/Schema/api/hashMap.mjs.map +1 -1
  116. package/_mjs/Schema/api/hashSet.mjs +46 -106
  117. package/_mjs/Schema/api/hashSet.mjs.map +1 -1
  118. package/_mjs/Schema/api/immutableArray.mjs +23 -49
  119. package/_mjs/Schema/api/immutableArray.mjs.map +1 -1
  120. package/_mjs/Schema/api/list.mjs +35 -52
  121. package/_mjs/Schema/api/list.mjs.map +1 -1
  122. package/_mjs/Schema/api/map.mjs +88 -0
  123. package/_mjs/Schema/api/map.mjs.map +1 -0
  124. package/_mjs/Schema/api/maybe.mjs +24 -35
  125. package/_mjs/Schema/api/maybe.mjs.map +1 -1
  126. package/_mjs/Schema/api/set.mjs +67 -0
  127. package/_mjs/Schema/api/set.mjs.map +1 -0
  128. package/_mjs/Schema/api.mjs +18 -2
  129. package/_mjs/Schema/api.mjs.map +1 -1
  130. package/_mjs/Schema/definition.mjs.map +1 -1
  131. package/_mjs/Schema/derivations.mjs.map +1 -1
  132. package/_mjs/Schema.mjs +2 -0
  133. package/_mjs/Schema.mjs.map +1 -1
  134. package/_mjs/Show.mjs +106 -90
  135. package/_mjs/Show.mjs.map +1 -1
  136. package/_mjs/global.mjs.map +1 -1
  137. package/_mjs/index.mjs.map +1 -1
  138. package/_mjs/utils.mjs +4 -0
  139. package/_mjs/utils.mjs.map +1 -1
  140. package/_src/AST.ts +139 -38
  141. package/_src/ASTAnnotation.ts +8 -1
  142. package/_src/Gen.ts +4 -1
  143. package/_src/ParseError/ParseError.ts +304 -0
  144. package/_src/ParseError/ParseErrorFormatter.ts +1 -0
  145. package/_src/ParseError/PathFormatter.ts +117 -0
  146. package/_src/ParseError/TreeFormatter.ts +127 -0
  147. package/_src/ParseError.ts +7 -331
  148. package/_src/ParseResult.ts +2 -9
  149. package/_src/Parser/api.ts +1 -1
  150. package/_src/Parser/interpreter.ts +98 -75
  151. package/_src/Schema/api/conc.ts +33 -42
  152. package/_src/Schema/api/either.ts +20 -30
  153. package/_src/Schema/api/hashMap.ts +40 -124
  154. package/_src/Schema/api/hashSet.ts +31 -117
  155. package/_src/Schema/api/immutableArray.ts +15 -45
  156. package/_src/Schema/api/list.ts +32 -55
  157. package/_src/Schema/api/map.ts +93 -0
  158. package/_src/Schema/api/maybe.ts +19 -34
  159. package/_src/Schema/api/set.ts +74 -0
  160. package/_src/Schema/api.ts +20 -2
  161. package/_src/Schema.ts +2 -0
  162. package/_src/Show.ts +156 -128
  163. package/_src/global.ts +0 -4
  164. package/_src/utils.ts +6 -0
  165. package/global.d.ts +0 -4
  166. package/package.json +3 -3
  167. package/utils.d.ts +1 -0
  168. package/ParseFailure.d.ts +0 -18
  169. package/_cjs/ParseFailure.cjs +0 -28
  170. package/_cjs/ParseFailure.cjs.map +0 -1
  171. package/_mjs/ParseFailure.mjs +0 -20
  172. package/_mjs/ParseFailure.mjs.map +0 -1
  173. package/_src/ParseFailure.ts +0 -18
package/_mjs/AST.mjs CHANGED
@@ -1,17 +1,20 @@
1
1
  var _a;
2
2
  const fileName_1 = "(@fncts/schema) src/AST.ts";
3
- import * as tsplus_module_1 from "@fncts/schema/ASTAnnotation";
4
- import * as tsplus_module_2 from "@fncts/base/collection/immutable/Vector/api";
5
- import * as tsplus_module_3 from "@fncts/base/data/Maybe/constructors";
6
- import * as tsplus_module_4 from "@fncts/schema/ParseResult";
7
- import * as tsplus_module_5 from "@fncts/schema/ParseError";
8
- import * as tsplus_module_6 from "@fncts/base/data/number/instances";
9
- import * as tsplus_module_7 from "@fncts/base/data/Ord/api/contramap";
10
- import * as tsplus_module_8 from "@fncts/base/data/Maybe/definition";
11
- import * as tsplus_module_9 from "@fncts/base/data/Maybe/destructors";
12
- import * as tsplus_module_10 from "@fncts/base/collection/immutable/Vector/internal";
13
- import * as tsplus_module_11 from "@fncts/base/data/Maybe/api";
14
- export const createDeclaration = createDeclaration_1;
3
+ import * as tsplus_module_1 from "@fncts/schema/Show";
4
+ import * as tsplus_module_2 from "@fncts/schema/ASTAnnotation";
5
+ import * as tsplus_module_3 from "@fncts/base/collection/immutable/Vector/api";
6
+ import * as tsplus_module_4 from "@fncts/base/data/Maybe/constructors";
7
+ import * as tsplus_module_5 from "@fncts/schema/ParseResult";
8
+ import * as tsplus_module_6 from "@fncts/schema/ParseError/ParseError";
9
+ import * as tsplus_module_7 from "@fncts/base/data/number/instances";
10
+ import * as tsplus_module_8 from "@fncts/base/data/Ord/api/contramap";
11
+ import * as tsplus_module_9 from "@fncts/base/data/Ord/api";
12
+ import * as tsplus_module_10 from "@fncts/base/data/Ord/api/max";
13
+ import * as tsplus_module_11 from "@fncts/base/collection/Iterable/api";
14
+ import * as tsplus_module_12 from "@fncts/base/data/Maybe/destructors";
15
+ import * as tsplus_module_13 from "@fncts/base/data/Maybe/definition";
16
+ import * as tsplus_module_14 from "@fncts/base/collection/immutable/Vector/internal";
17
+ import * as tsplus_module_15 from "@fncts/base/data/Maybe/api";
15
18
  export const createLiteral = createLiteral_1;
16
19
  export const isLiteral = isLiteral_1;
17
20
  export const createUniqueSymbol = createUniqueSymbol_1;
@@ -51,6 +54,9 @@ export class AST extends Annotated {
51
54
  super(...arguments);
52
55
  this[_a] = ASTTypeId;
53
56
  }
57
+ toString(verbose = false) {
58
+ return tsplus_module_1.showAST(verbose)(this);
59
+ }
54
60
  }
55
61
  _a = ASTTypeId;
56
62
  /**
@@ -68,24 +74,27 @@ export function getAnnotations(key) {
68
74
  /*
69
75
  * Declaration
70
76
  */
77
+ /**
78
+ * @tsplus type fncts.schema.AST.Declaration
79
+ */
71
80
  export class Declaration extends AST {
72
- constructor(typeParameters, type, decode, annotations = ASTAnnotationMap.empty) {
81
+ constructor(typeParameters, decode, encode, annotations = ASTAnnotationMap.empty) {
73
82
  super();
74
83
  this.typeParameters = typeParameters;
75
- this.type = type;
76
84
  this.decode = decode;
85
+ this.encode = encode;
77
86
  this.annotations = annotations;
78
87
  this._tag = 0 /* ASTTag.Declaration */;
79
88
  }
80
89
  clone(newProperties) {
81
- return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.type ?? this.type, newProperties.decode ?? this.decode, newProperties.annotations ?? this.annotations);
90
+ return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.annotations ?? this.annotations);
82
91
  }
83
92
  }
84
93
  /**
85
94
  * @tsplus static fncts.schema.ASTOps createDeclaration
86
95
  */
87
- function createDeclaration_1(typeParameters, type, decode, annotations = ASTAnnotationMap.empty) {
88
- return new Declaration(typeParameters, type, decode, annotations);
96
+ export function createDeclaration(typeParameters, decode, encode, annotations = ASTAnnotationMap.empty) {
97
+ return new Declaration(typeParameters, decode, encode, annotations);
89
98
  }
90
99
  /**
91
100
  * @tsplus fluent fncts.schema.AST isDeclaration
@@ -161,7 +170,7 @@ export class UndefinedKeyword extends AST {
161
170
  /**
162
171
  * @tsplus static fncts.schema.ASTOps undefinedKeyword
163
172
  */
164
- const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "undefined"));
173
+ const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "undefined"));
165
174
  export const undefinedKeyword = undefinedKeyword_1;
166
175
  /*
167
176
  * VoidKeyword
@@ -179,7 +188,7 @@ export class VoidKeyword extends AST {
179
188
  /**
180
189
  * @tsplus static fncts.schema.ASTOps voidKeyword
181
190
  */
182
- export const voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "void"));
191
+ export const voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "void"));
183
192
  /*
184
193
  * NeverKeyword
185
194
  */
@@ -196,7 +205,7 @@ export class NeverKeyword extends AST {
196
205
  /**
197
206
  * @tsplus static fncts.schema.ASTOps neverKeyword
198
207
  */
199
- const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "never"));
208
+ const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "never"));
200
209
  export const neverKeyword = neverKeyword_1;
201
210
  /*
202
211
  * UnknownKeyword
@@ -214,7 +223,7 @@ export class UnknownKeyword extends AST {
214
223
  /**
215
224
  * @tsplus static fncts.schema.ASTOps unknownKeyword
216
225
  */
217
- const unknownKeyword_1 = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "unknown"));
226
+ const unknownKeyword_1 = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "unknown"));
218
227
  export const unknownKeyword = unknownKeyword_1;
219
228
  /*
220
229
  * AnyKeyword
@@ -232,7 +241,7 @@ export class AnyKeyword extends AST {
232
241
  /**
233
242
  * @tsplus static fncts.schema.ASTOps anyKeyword
234
243
  */
235
- export const anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "any"));
244
+ export const anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "any"));
236
245
  /*
237
246
  * StringKeyword
238
247
  */
@@ -249,7 +258,7 @@ export class StringKeyword extends AST {
249
258
  /**
250
259
  * @tsplus static fncts.schema.ASTOps stringKeyword
251
260
  */
252
- const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "string"));
261
+ const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "string"));
253
262
  export const stringKeyword = stringKeyword_1;
254
263
  /**
255
264
  * @tsplus fluent fncts.schema.AST isStringKeyword
@@ -274,7 +283,7 @@ export class NumberKeyword extends AST {
274
283
  /**
275
284
  * @tsplus static fncts.schema.ASTOps numberKeyword
276
285
  */
277
- const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "number"));
286
+ const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "number"));
278
287
  export const numberKeyword = numberKeyword_1;
279
288
  /**
280
289
  * @tsplus fluent fncts.schema.AST isNumberKeyword
@@ -299,7 +308,7 @@ export class BooleanKeyword extends AST {
299
308
  /**
300
309
  * @tsplus static fncts.schema.ASTOps booleanKeyword
301
310
  */
302
- export const booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "boolean"));
311
+ export const booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "boolean"));
303
312
  /**
304
313
  * @tsplus fluent fncts.schema.AST isBooleanKeyword
305
314
  */
@@ -323,7 +332,7 @@ export class BigIntKeyword extends AST {
323
332
  /**
324
333
  * @tsplus static fncts.schema.ASTOps bigIntKeyword
325
334
  */
326
- export const bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "bigint"));
335
+ export const bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "bigint"));
327
336
  /**
328
337
  * @tsplus fluent fncts.schema.AST isBigIntKeyword
329
338
  */
@@ -347,7 +356,7 @@ export class SymbolKeyword extends AST {
347
356
  /**
348
357
  * @tsplus static fncts.schema.ASTOps symbolKeyword
349
358
  */
350
- const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "symbol"));
359
+ const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "symbol"));
351
360
  export const symbolKeyword = symbolKeyword_1;
352
361
  /**
353
362
  * @tsplus fluent fncts.schema.AST isSymbolKeyword
@@ -372,7 +381,7 @@ export class ObjectKeyword extends AST {
372
381
  /**
373
382
  * @tsplus static fncts.schema.ASTOps objectKeyword
374
383
  */
375
- export const objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "object"));
384
+ export const objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "object"));
376
385
  /*
377
386
  * Enum
378
387
  */
@@ -398,6 +407,14 @@ export class TemplateLiteralSpan {
398
407
  this.type = type;
399
408
  this.literal = literal;
400
409
  }
410
+ toString() {
411
+ switch (this.type._tag) {
412
+ case 8 /* ASTTag.StringKeyword */:
413
+ return "${string}";
414
+ case 9 /* ASTTag.NumberKeyword */:
415
+ return "${number}";
416
+ }
417
+ }
401
418
  }
402
419
  /*
403
420
  * TemplateLiteral
@@ -418,7 +435,7 @@ export class TemplateLiteral extends AST {
418
435
  * @tsplus static fncts.schema.ASTOps createTemplateLiteral
419
436
  */
420
437
  function createTemplateLiteral_1(head, spans, annotations = ASTAnnotationMap.empty) {
421
- if (tsplus_module_2.isNonEmpty(spans)) {
438
+ if (tsplus_module_3.isNonEmpty(spans)) {
422
439
  return new TemplateLiteral(head, spans, annotations);
423
440
  } else {
424
441
  return createLiteral_1(head, annotations);
@@ -432,6 +449,9 @@ export class Element {
432
449
  this.type = type;
433
450
  this.isOptional = isOptional;
434
451
  }
452
+ toString() {
453
+ return String(this.type) + (this.isOptional ? "?" : "");
454
+ }
435
455
  }
436
456
  /**
437
457
  * @tsplus static fncts.schema.ASTOps createElement
@@ -464,13 +484,12 @@ function createTuple_1(elements, rest, isReadonly, annotations = ASTAnnotationMa
464
484
  /**
465
485
  * @tsplus static fncts.schema.ASTOps unknownArray
466
486
  */
467
- export const unknownArray = /*#__PURE__*/createTuple_1( /*#__PURE__*/tsplus_module_2.empty(), /*#__PURE__*/tsplus_module_3.just( /*#__PURE__*/tsplus_module_2.vector(unknownKeyword_1), fileName_1 + ":629:65"), true);
487
+ export const unknownArray = /*#__PURE__*/createTuple_1( /*#__PURE__*/tsplus_module_3.empty(), /*#__PURE__*/tsplus_module_4.just( /*#__PURE__*/tsplus_module_3.vector(unknownKeyword_1), fileName_1 + ":651:65"), true);
468
488
  /*
469
489
  * PropertySignature
470
490
  */
471
- export class PropertySignature extends AST {
491
+ export class PropertySignature {
472
492
  constructor(name, type, isOptional, isReadonly, annotations = ASTAnnotationMap.empty) {
473
- super();
474
493
  this.name = name;
475
494
  this.type = type;
476
495
  this.isOptional = isOptional;
@@ -535,7 +554,7 @@ function createTypeLiteral_1(propertySignatures, indexSignatures, annotations) {
535
554
  /**
536
555
  * @tsplus static fncts.schema.ASTOps unknownRecord
537
556
  */
538
- export const unknownRecord = /*#__PURE__*/createTypeLiteral_1( /*#__PURE__*/tsplus_module_2.empty(), /*#__PURE__*/tsplus_module_2.vector( /*#__PURE__*/createIndexSignature_1(stringKeyword_1, unknownKeyword_1, true), /*#__PURE__*/createIndexSignature_1(symbolKeyword_1, unknownKeyword_1, true)));
557
+ export const unknownRecord = /*#__PURE__*/createTypeLiteral_1( /*#__PURE__*/tsplus_module_3.empty(), /*#__PURE__*/tsplus_module_3.vector( /*#__PURE__*/createIndexSignature_1(stringKeyword_1, unknownKeyword_1, true), /*#__PURE__*/createIndexSignature_1(symbolKeyword_1, unknownKeyword_1, true)));
539
558
  /*
540
559
  * Union
541
560
  */
@@ -566,7 +585,7 @@ function createUnion_1(candidates, annotations = ASTAnnotationMap.empty) {
566
585
  case 0:
567
586
  return neverKeyword_1;
568
587
  case 1:
569
- return tsplus_module_2.unsafeGet(0)(types);
588
+ return tsplus_module_3.unsafeGet(0)(types);
570
589
  default:
571
590
  return new Union(sortByDescendingWeight(types), annotations);
572
591
  }
@@ -610,7 +629,7 @@ export class Refinement extends AST {
610
629
  this._tag = 20 /* ASTTag.Refinement */;
611
630
  }
612
631
  decode(input, options) {
613
- return this.predicate(input) ? tsplus_module_4.succeed(input) : tsplus_module_4.fail(tsplus_module_5.typeError(this, input));
632
+ return this.predicate(input) ? tsplus_module_5.succeed(input) : tsplus_module_5.fail(tsplus_module_6.typeError(this, input));
614
633
  }
615
634
  clone(newProperties) {
616
635
  return new Refinement(newProperties.from ?? this.from, newProperties.predicate ?? this.predicate, newProperties.annotations ?? this.annotations);
@@ -679,10 +698,6 @@ export function getCardinality(ast) {
679
698
  while (1) {
680
699
  void 0;
681
700
  switch (ast_1._tag) {
682
- case 0 /* ASTTag.Declaration */:
683
- ast_2 = ast_1.type;
684
- ast_1 = ast_2;
685
- continue;
686
701
  case 5 /* ASTTag.NeverKeyword */:
687
702
  return 0;
688
703
  case 1 /* ASTTag.Literal */:
@@ -698,7 +713,7 @@ export function getCardinality(ast) {
698
713
  case 12 /* ASTTag.SymbolKeyword */:
699
714
  return 3;
700
715
  case 13 /* ASTTag.ObjectKeyword */:
701
- return 4;
716
+ return 5;
702
717
  case 6 /* ASTTag.UnknownKeyword */:
703
718
  case 7 /* ASTTag.AnyKeyword */:
704
719
  return 6;
@@ -711,59 +726,78 @@ export function getCardinality(ast) {
711
726
  ast_1 = ast_2;
712
727
  continue;
713
728
  default:
714
- return 5;
729
+ return 4;
715
730
  }
716
731
  }
717
732
  }
718
733
  function sortByAscendingCardinality(types) {
719
- return tsplus_module_2.sort(tsplus_module_7.contramap(({
734
+ return tsplus_module_3.sort(tsplus_module_8.contramap(({
720
735
  type
721
- }) => getCardinality(type))(tsplus_module_6.Ord))(types);
736
+ }) => getCardinality(type))(tsplus_module_7.Ord))(types);
737
+ }
738
+ const OrdWeight = /*#__PURE__*/tsplus_module_9.tuple(tsplus_module_7.Ord, tsplus_module_7.Ord, tsplus_module_7.Ord);
739
+ const maxWeight = /*#__PURE__*/tsplus_module_10.max(OrdWeight);
740
+ function maxWeightAll(weights) {
741
+ return tsplus_module_11.foldLeft(emptyWeight, (b, a) => maxWeight(b)(a))(weights);
722
742
  }
743
+ const emptyWeight = [0, 0, 0];
723
744
  export function getWeight(ast) {
724
745
  void 0;
725
746
  switch (ast._tag) {
726
747
  case 0 /* ASTTag.Declaration */:
727
- return getWeight(ast.type);
748
+ return tsplus_module_12.match(() => [6, 0, 0], ast => {
749
+ const [_, y, z] = getWeight(ast);
750
+ return [6, y, z];
751
+ })(ast.annotations.get(tsplus_module_2.Surrogate));
728
752
  case 16 /* ASTTag.Tuple */:
729
- return ast.elements.length + (tsplus_module_8.isJust(ast.rest) ? ast.rest.value.length : 0);
753
+ return [2, ast.elements.length, tsplus_module_12.match(() => 0, rest => rest.length)(ast.rest)];
730
754
  case 17 /* ASTTag.TypeLiteral */:
731
- return ast.propertySignatures.length + ast.indexSignatures.length;
755
+ {
756
+ const y = ast.propertySignatures.length;
757
+ const z = ast.indexSignatures.length;
758
+ return y + z === 0 ? [-4, 0, 0] : [4, y, z];
759
+ }
732
760
  case 18 /* ASTTag.Union */:
733
- return tsplus_module_2.foldLeft(0, (n, member) => n + getWeight(member))(ast.types);
761
+ return maxWeightAll(tsplus_module_3.map(getWeight)(ast.types));
734
762
  case 19 /* ASTTag.Lazy */:
735
- return 10;
763
+ return [8, 0, 0];
736
764
  case 20 /* ASTTag.Refinement */:
737
- return getWeight(ast.from);
765
+ const [x, y, z] = getWeight(ast.from);
766
+ return [x + 1, y, z];
738
767
  case 21 /* ASTTag.Transform */:
739
- return getWeight(ast.to);
768
+ return getWeight(ast.from);
769
+ case 13 /* ASTTag.ObjectKeyword */:
770
+ return [-2, 0, 0];
771
+ case 6 /* ASTTag.UnknownKeyword */:
772
+ case 7 /* ASTTag.AnyKeyword */:
773
+ return [-4, 0, 0];
740
774
  default:
741
- return 0;
775
+ return emptyWeight;
742
776
  }
743
777
  }
744
778
  function sortByDescendingWeight(types) {
745
- return tsplus_module_2.sort(tsplus_module_7.contramap(getWeight)(tsplus_module_6.Ord))(types);
779
+ return tsplus_module_3.sort(tsplus_module_8.contramap(getWeight)(OrdWeight))(types);
746
780
  }
747
781
  function unify(candidates) {
748
- let out = tsplus_module_2.flatMap(ast => {
782
+ let out = tsplus_module_3.flatMap(ast => {
749
783
  void 0;
750
784
  switch (ast._tag) {
751
785
  case 5 /* ASTTag.NeverKeyword */:
752
- return tsplus_module_2.empty();
786
+ return tsplus_module_3.empty();
753
787
  case 18 /* ASTTag.Union */:
754
788
  return ast.types;
755
789
  default:
756
- return tsplus_module_2.vector(ast);
790
+ return tsplus_module_3.vector(ast);
757
791
  }
758
792
  })(candidates);
759
- if (tsplus_module_2.some(isStringKeyword_1)(out)) {
760
- out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "string"))(out);
793
+ if (tsplus_module_3.some(isStringKeyword_1)(out)) {
794
+ out = tsplus_module_3.filter(m => !(isLiteral_1(m) && typeof m.literal === "string"))(out);
761
795
  }
762
- if (tsplus_module_2.some(isNumberKeyword_1)(out)) {
763
- out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "number"))(out);
796
+ if (tsplus_module_3.some(isNumberKeyword_1)(out)) {
797
+ out = tsplus_module_3.filter(m => !(isLiteral_1(m) && typeof m.literal === "number"))(out);
764
798
  }
765
- if (tsplus_module_2.some(isSymbolKeyword_1)(out)) {
766
- out = tsplus_module_2.filter(m => !isUniqueSymbol_1(m))(out);
799
+ if (tsplus_module_3.some(isSymbolKeyword_1)(out)) {
800
+ out = tsplus_module_3.filter(m => !isUniqueSymbol_1(m))(out);
767
801
  }
768
802
  return out;
769
803
  }
@@ -792,10 +826,10 @@ export function setAnnotation(annotation, value) {
792
826
  */
793
827
  export function appendRestElement(restElement) {
794
828
  return self => {
795
- if (tsplus_module_8.isJust(self.rest)) {
829
+ if (tsplus_module_13.isJust(self.rest)) {
796
830
  throw new Error("A rest element cannot follow another rest element. ts(1265)");
797
831
  }
798
- return createTuple_1(self.elements, tsplus_module_3.just(tsplus_module_2.vector(restElement), fileName_1 + ":1062:43"), self.isReadonly, self.annotations);
832
+ return createTuple_1(self.elements, tsplus_module_4.just(tsplus_module_3.vector(restElement), fileName_1 + ":1115:43"), self.isReadonly, self.annotations);
799
833
  };
800
834
  }
801
835
  /**
@@ -803,14 +837,14 @@ export function appendRestElement(restElement) {
803
837
  */
804
838
  export function appendElement(element) {
805
839
  return self => {
806
- if (tsplus_module_2.some(e => e.isOptional)(self.elements) && !element.isOptional) {
840
+ if (tsplus_module_3.some(e => e.isOptional)(self.elements) && !element.isOptional) {
807
841
  throw new Error("A required element cannot follow an optional element. ts(1257)");
808
842
  }
809
- return tsplus_module_9.match(() => createTuple_1(tsplus_module_2.append(element)(self.elements), tsplus_module_3.nothing(fileName_1 + ":1075:63"), self.isReadonly, self.annotations), rest => {
843
+ return tsplus_module_12.match(() => createTuple_1(tsplus_module_3.append(element)(self.elements), tsplus_module_4.nothing(fileName_1 + ":1128:63"), self.isReadonly, self.annotations), rest => {
810
844
  if (element.isOptional) {
811
845
  throw new Error("A required element cannot follow an optional element. ts(1257)");
812
846
  }
813
- return createTuple_1(self.elements, tsplus_module_3.just(tsplus_module_2.append(element.type)(rest), fileName_1 + ":1080:47"), self.isReadonly, self.annotations);
847
+ return createTuple_1(self.elements, tsplus_module_4.just(tsplus_module_3.append(element.type)(rest), fileName_1 + ":1133:47"), self.isReadonly, self.annotations);
814
848
  })(self.rest);
815
849
  };
816
850
  }
@@ -824,22 +858,24 @@ function getPropertySignatures_1(self) {
824
858
  void 0;
825
859
  switch (self._tag) {
826
860
  case 0 /* ASTTag.Declaration */:
827
- return getPropertySignatures_1(self.type);
861
+ return tsplus_module_12.match(() => tsplus_module_3.empty(), surrogate => getPropertySignatures_1(surrogate))(self.annotations.get(tsplus_module_2.Surrogate));
828
862
  case 16 /* ASTTag.Tuple */:
829
- return tsplus_module_2.mapWithIndex((i, element) => createPropertySignature_1(i, element.type, element.isOptional, self.isReadonly))(self.elements);
863
+ return tsplus_module_3.mapWithIndex((i, element) => createPropertySignature_1(i, element.type, element.isOptional, self.isReadonly))(self.elements);
830
864
  case 18 /* ASTTag.Union */:
831
865
  {
832
- const propertySignatures = tsplus_module_2.map(getPropertySignatures_1)(self.types);
833
- return tsplus_module_2.filterMap(({
866
+ const propertySignatures = tsplus_module_3.map(getPropertySignatures_1)(self.types);
867
+ return tsplus_module_3.filterMap(({
834
868
  name
835
869
  }) => {
836
- if (tsplus_module_2.every(ps => tsplus_module_2.some(p => p.name === name)(ps))(propertySignatures)) {
837
- const members = tsplus_module_2.flatMap(ps => tsplus_module_2.filter(p => p.name === name)(ps))(propertySignatures);
838
- return tsplus_module_3.just(createPropertySignature_1(name, createUnion_1(tsplus_module_2.map(p => p.type)(members)), tsplus_module_2.some(p => p.isOptional)(members), tsplus_module_2.some(p => p.isReadonly)(members)), fileName_1 + ":1107:22");
870
+ if (tsplus_module_3.every(ps => tsplus_module_3.some(p => p.name === name)(ps))(propertySignatures)) {
871
+ const members = tsplus_module_3.flatMap(ps => tsplus_module_3.filter(p => p.name === name)(ps))(propertySignatures);
872
+ return tsplus_module_4.just(createPropertySignature_1(name, createUnion_1(tsplus_module_3.map(p => p.type)(members)), tsplus_module_3.some(p => p.isOptional)(members), tsplus_module_3.some(p => p.isReadonly)(members)), fileName_1 + ":1163:22");
839
873
  }
840
- return tsplus_module_3.nothing(fileName_1 + ":1116:23");
841
- })(tsplus_module_2.unsafeGet(0)(propertySignatures));
874
+ return tsplus_module_4.nothing(fileName_1 + ":1172:23");
875
+ })(tsplus_module_3.unsafeGet(0)(propertySignatures));
842
876
  }
877
+ case 17 /* ASTTag.TypeLiteral */:
878
+ return self.propertySignatures;
843
879
  case 19 /* ASTTag.Lazy */:
844
880
  return getPropertySignatures_1(self.getAST());
845
881
  case 20 /* ASTTag.Refinement */:
@@ -847,7 +883,7 @@ function getPropertySignatures_1(self) {
847
883
  case 21 /* ASTTag.Transform */:
848
884
  return getPropertySignatures_1(self.to);
849
885
  default:
850
- return tsplus_module_2.empty();
886
+ return tsplus_module_3.empty();
851
887
  }
852
888
  }
853
889
  /**
@@ -857,16 +893,16 @@ function keysOf_1(ast) {
857
893
  void 0;
858
894
  switch (ast._tag) {
859
895
  case 0 /* ASTTag.Declaration */:
860
- return keysOf_1(ast.type);
896
+ return tsplus_module_12.match(() => tsplus_module_3.empty(), surrogate => keysOf_1(surrogate))(ast.annotations.get(tsplus_module_2.Surrogate));
861
897
  case 5 /* ASTTag.NeverKeyword */:
862
898
  case 7 /* ASTTag.AnyKeyword */:
863
- return tsplus_module_2.vector(stringKeyword_1, numberKeyword_1, symbolKeyword_1);
899
+ return tsplus_module_3.vector(stringKeyword_1, numberKeyword_1, symbolKeyword_1);
864
900
  case 8 /* ASTTag.StringKeyword */:
865
- return tsplus_module_2.vector(createLiteral_1("length"));
901
+ return tsplus_module_3.vector(createLiteral_1("length"));
866
902
  case 17 /* ASTTag.TypeLiteral */:
867
- return tsplus_module_2.concat(tsplus_module_2.map(is => getParameter(is.parameter))(ast.indexSignatures))(tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(ast.propertySignatures));
903
+ return tsplus_module_3.concat(tsplus_module_3.map(is => getParameter(is.parameter))(ast.indexSignatures))(tsplus_module_3.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(ast.propertySignatures));
868
904
  case 18 /* ASTTag.Union */:
869
- return tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(getPropertySignatures_1(ast));
905
+ return tsplus_module_3.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(getPropertySignatures_1(ast));
870
906
  case 19 /* ASTTag.Lazy */:
871
907
  return keysOf_1(ast.getAST());
872
908
  case 20 /* ASTTag.Refinement */:
@@ -874,7 +910,7 @@ function keysOf_1(ast) {
874
910
  case 21 /* ASTTag.Transform */:
875
911
  return keysOf_1(ast.to);
876
912
  default:
877
- return tsplus_module_2.empty();
913
+ return tsplus_module_3.empty();
878
914
  }
879
915
  }
880
916
  /**
@@ -887,32 +923,29 @@ export function keyof(self) {
887
923
  * @tsplus static fncts.schema.ASTOps createRecord
888
924
  */
889
925
  export function createRecord(key, value, isReadonly) {
890
- const propertySignatures = tsplus_module_2.emptyPushable();
891
- const indexSignatures = tsplus_module_2.emptyPushable();
926
+ const propertySignatures = tsplus_module_3.emptyPushable();
927
+ const indexSignatures = tsplus_module_3.emptyPushable();
892
928
  function go(key) {
893
929
  void 0;
894
930
  switch (key._tag) {
895
- case 0 /* ASTTag.Declaration */:
896
- go(key.type);
897
- break;
898
931
  case 5 /* ASTTag.NeverKeyword */:
899
932
  break;
900
933
  case 8 /* ASTTag.StringKeyword */:
901
934
  case 12 /* ASTTag.SymbolKeyword */:
902
935
  case 15 /* ASTTag.TemplateLiteral */:
903
936
  case 20 /* ASTTag.Refinement */:
904
- tsplus_module_10.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
937
+ tsplus_module_14.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
905
938
  break;
906
939
  case 1 /* ASTTag.Literal */:
907
940
  if (typeof key.literal === "string" || typeof key.literal === "number") {
908
- tsplus_module_10.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
941
+ tsplus_module_14.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
909
942
  }
910
943
  break;
911
944
  case 2 /* ASTTag.UniqueSymbol */:
912
- tsplus_module_10.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
945
+ tsplus_module_14.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
913
946
  break;
914
947
  case 18 /* ASTTag.Union */:
915
- tsplus_module_2.forEach(go)(key.types);
948
+ tsplus_module_3.forEach(go)(key.types);
916
949
  break;
917
950
  default:
918
951
  throw new Error(`createRecord: Unsupported key\n${show(key)}`);
@@ -926,7 +959,7 @@ export function createRecord(key, value, isReadonly) {
926
959
  */
927
960
  export function pick(keys) {
928
961
  return self => {
929
- return createTypeLiteral_1(tsplus_module_2.filter(ps => tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
962
+ return createTypeLiteral_1(tsplus_module_3.filter(ps => tsplus_module_3.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_3.empty());
930
963
  };
931
964
  }
932
965
  /**
@@ -934,7 +967,7 @@ export function pick(keys) {
934
967
  */
935
968
  export function omit(keys) {
936
969
  return self => {
937
- return createTypeLiteral_1(tsplus_module_2.filter(ps => !tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
970
+ return createTypeLiteral_1(tsplus_module_3.filter(ps => !tsplus_module_3.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_3.empty());
938
971
  };
939
972
  }
940
973
  /**
@@ -943,14 +976,12 @@ export function omit(keys) {
943
976
  function partial_1(self) {
944
977
  void 0;
945
978
  switch (self._tag) {
946
- case 0 /* ASTTag.Declaration */:
947
- return partial_1(self.type);
948
979
  case 16 /* ASTTag.Tuple */:
949
- return createTuple_1(tsplus_module_2.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_11.map(rest => tsplus_module_2.vector(createUnion_1(tsplus_module_2.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
980
+ return createTuple_1(tsplus_module_3.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_15.map(rest => tsplus_module_3.vector(createUnion_1(tsplus_module_3.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
950
981
  case 17 /* ASTTag.TypeLiteral */:
951
- return createTypeLiteral_1(tsplus_module_2.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
982
+ return createTypeLiteral_1(tsplus_module_3.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
952
983
  case 18 /* ASTTag.Union */:
953
- return createUnion_1(tsplus_module_2.map(partial_1)(self.types));
984
+ return createUnion_1(tsplus_module_3.map(partial_1)(self.types));
954
985
  case 19 /* ASTTag.Lazy */:
955
986
  return createLazy_1(() => partial_1(self.getAST()));
956
987
  case 20 /* ASTTag.Refinement */:
@@ -974,13 +1005,19 @@ function getFrom_1(ast) {
974
1005
  void 0;
975
1006
  switch (ast._tag) {
976
1007
  case 0 /* ASTTag.Declaration */:
977
- return createDeclaration_1(tsplus_module_2.map(getFrom_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1008
+ {
1009
+ const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
1010
+ if (tsplus_module_13.isJust(surrogate)) {
1011
+ return getFrom_1(surrogate.value);
1012
+ }
1013
+ break;
1014
+ }
978
1015
  case 16 /* ASTTag.Tuple */:
979
- return createTuple_1(tsplus_module_2.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_11.map(restElement => tsplus_module_2.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1016
+ return createTuple_1(tsplus_module_3.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_15.map(restElement => tsplus_module_3.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
980
1017
  case 17 /* ASTTag.TypeLiteral */:
981
- return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getFrom_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getFrom_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1018
+ return createTypeLiteral_1(tsplus_module_3.map(ps => createPropertySignature_1(ps.name, getFrom_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_3.map(is => createIndexSignature_1(is.parameter, getFrom_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
982
1019
  case 18 /* ASTTag.Union */:
983
- return createUnion_1(tsplus_module_2.map(getFrom_1)(ast.types), ast.annotations);
1020
+ return createUnion_1(tsplus_module_3.map(getFrom_1)(ast.types), ast.annotations);
984
1021
  case 19 /* ASTTag.Lazy */:
985
1022
  return createLazy_1(() => getFrom_1(ast.getAST()), ast.annotations);
986
1023
  case 20 /* ASTTag.Refinement */:
@@ -996,13 +1033,19 @@ function getTo_1(ast) {
996
1033
  void 0;
997
1034
  switch (ast._tag) {
998
1035
  case 0 /* ASTTag.Declaration */:
999
- return createDeclaration_1(tsplus_module_2.map(getTo_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1036
+ {
1037
+ const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
1038
+ if (tsplus_module_13.isJust(surrogate)) {
1039
+ return getTo_1(surrogate.value);
1040
+ }
1041
+ break;
1042
+ }
1000
1043
  case 16 /* ASTTag.Tuple */:
1001
- return createTuple_1(tsplus_module_2.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_11.map(restElement => tsplus_module_2.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1044
+ return createTuple_1(tsplus_module_3.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_15.map(restElement => tsplus_module_3.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1002
1045
  case 17 /* ASTTag.TypeLiteral */:
1003
- return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getTo_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getTo_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1046
+ return createTypeLiteral_1(tsplus_module_3.map(ps => createPropertySignature_1(ps.name, getTo_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_3.map(is => createIndexSignature_1(is.parameter, getTo_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1004
1047
  case 18 /* ASTTag.Union */:
1005
- return createUnion_1(tsplus_module_2.map(getTo_1)(ast.types), ast.annotations);
1048
+ return createUnion_1(tsplus_module_3.map(getTo_1)(ast.types), ast.annotations);
1006
1049
  case 19 /* ASTTag.Lazy */:
1007
1050
  return createLazy_1(() => getTo_1(ast.getAST()), ast.annotations);
1008
1051
  case 20 /* ASTTag.Refinement */:
@@ -1026,12 +1069,18 @@ export function getLiterals(ast, isDecoding) {
1026
1069
  void 0;
1027
1070
  switch (ast._tag) {
1028
1071
  case 0 /* ASTTag.Declaration */:
1029
- return getLiterals(ast.type, isDecoding);
1072
+ {
1073
+ const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
1074
+ if (tsplus_module_13.isJust(surrogate)) {
1075
+ return getLiterals(surrogate.value, isDecoding);
1076
+ }
1077
+ break;
1078
+ }
1030
1079
  case 17 /* ASTTag.TypeLiteral */:
1031
1080
  {
1032
1081
  const out = [];
1033
1082
  for (let i = 0; i < ast.propertySignatures.length; i++) {
1034
- const propertySignature = tsplus_module_2.unsafeGet(i)(ast.propertySignatures);
1083
+ const propertySignature = tsplus_module_3.unsafeGet(i)(ast.propertySignatures);
1035
1084
  if (isLiteral_1(propertySignature.type) && !propertySignature.isOptional) {
1036
1085
  out.push([propertySignature.name, propertySignature.type]);
1037
1086
  }
@@ -1049,7 +1098,7 @@ export function getSearchTree(members, isDecoding) {
1049
1098
  const keys = {};
1050
1099
  const otherwise = [];
1051
1100
  for (let i = 0; i < members.length; i++) {
1052
- const member = tsplus_module_2.unsafeGet(i)(members);
1101
+ const member = tsplus_module_3.unsafeGet(i)(members);
1053
1102
  const tags = getLiterals(member, isDecoding);
1054
1103
  if (tags.length > 0) {
1055
1104
  for (let j = 0; j < tags.length; j++) {
@@ -1057,7 +1106,8 @@ export function getSearchTree(members, isDecoding) {
1057
1106
  const hash = String(literal.literal);
1058
1107
  keys[key] || (keys[key] = {
1059
1108
  buckets: {},
1060
- ast: neverKeyword_1
1109
+ ast: neverKeyword_1,
1110
+ literals: []
1061
1111
  });
1062
1112
  const buckets = keys[key].buckets;
1063
1113
  if (Object.prototype.hasOwnProperty.call(buckets, hash)) {
@@ -1065,10 +1115,12 @@ export function getSearchTree(members, isDecoding) {
1065
1115
  continue;
1066
1116
  }
1067
1117
  buckets[hash].push(member);
1068
- keys[key].ast = createUnion_1(tsplus_module_2.vector(keys[key].ast, literal));
1118
+ keys[key].ast = createUnion_1(tsplus_module_3.vector(keys[key].ast, literal));
1119
+ keys[key].literals.push(literal);
1069
1120
  } else {
1070
1121
  buckets[hash] = [member];
1071
- keys[key].ast = createUnion_1(tsplus_module_2.vector(keys[key].ast, literal));
1122
+ keys[key].ast = createUnion_1(tsplus_module_3.vector(keys[key].ast, literal));
1123
+ keys[key].literals.push(literal);
1072
1124
  break;
1073
1125
  }
1074
1126
  }
@@ -1081,4 +1133,17 @@ export function getSearchTree(members, isDecoding) {
1081
1133
  otherwise
1082
1134
  };
1083
1135
  }
1136
+ /**
1137
+ * @tsplus pipeable fncts.schema.AST getFormattedExpected
1138
+ */
1139
+ export function getFormattedExpected(verbose = false) {
1140
+ return self => {
1141
+ if (verbose) {
1142
+ const description = tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Title))(self.annotations.get(tsplus_module_2.Description));
1143
+ return tsplus_module_12.match(() => description, identifier => tsplus_module_12.match(() => tsplus_module_4.just(identifier, fileName_1 + ":1510:23"), description => tsplus_module_4.just(`${identifier} (${description})`, fileName_1 + ":1511:34"))(description))(self.annotations.get(tsplus_module_2.Identifier));
1144
+ } else {
1145
+ return tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Description))(tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Title))(self.annotations.get(tsplus_module_2.Identifier)));
1146
+ }
1147
+ };
1148
+ }
1084
1149
  //# sourceMappingURL=AST.mjs.map