@magnusopera/fscript 0.92.5 → 0.93.0

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.
@@ -1,22 +1,23 @@
1
1
 
2
2
  import { class_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
3
3
  import { item } from "../fable_modules/fable-library-js.5.27.0/Array.js";
4
- import { compare, safeHash, curry2, equals } from "../fable_modules/fable-library-js.5.27.0/Util.js";
4
+ import { compare, safeHash, comparePrimitives, curry2, equals } from "../fable_modules/fable-library-js.5.27.0/Util.js";
5
5
  import { ParseException, ParseError } from "./Error.js";
6
6
  import { TokenKind } from "./Token.js";
7
7
  import { Span, SpanModule_merge } from "./Span.js";
8
- import { substring, isNullOrWhiteSpace, concat, join, getCharAtIndex, isNullOrEmpty } from "../fable_modules/fable-library-js.5.27.0/String.js";
8
+ import { substring, isNullOrWhiteSpace, join, concat, getCharAtIndex, isNullOrEmpty } from "../fable_modules/fable-library-js.5.27.0/String.js";
9
9
  import { isUpper } from "../fable_modules/fable-library-js.5.27.0/Char.js";
10
10
  import { Ast_spanOfStmt, Attribute, MapEntry, Ast_spanOfExpr, InterpolatedPart, Expr, Ast_spanOfPattern, Pattern, Stmt, TypeDef, BackendImport, Param, TypeRef, Literal } from "./Ast.js";
11
11
  import { tokenizeArrayWithSourceNameAndOrigin } from "./Lexer.js";
12
12
  import { map } from "../fable_modules/fable-library-js.5.27.0/Option.js";
13
- import { singleton, foldBack, head as head_1, tail as tail_1, isEmpty, empty, ofSeq } from "../fable_modules/fable-library-js.5.27.0/List.js";
13
+ import { length, singleton, foldBack, head as head_1, tail as tail_1, isEmpty, empty, ofSeq } from "../fable_modules/fable-library-js.5.27.0/List.js";
14
+ import { FSharpSet__Contains, ofSeq as ofSeq_1 } from "../fable_modules/fable-library-js.5.27.0/Set.js";
14
15
  import { addToSet } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
15
16
  import { map as map_1, foldBack as foldBack_1, toList } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
16
17
  import { StringBuilder__Append_244C7CD6, StringBuilder__Clear, StringBuilder__get_Length, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.27.0/System.Text.js";
17
18
  import { toString } from "../fable_modules/fable-library-js.5.27.0/Types.js";
18
19
  import { Dictionary } from "../fable_modules/fable-library-js.5.27.0/MutableMap.js";
19
- import { ofSeq as ofSeq_1 } from "../fable_modules/fable-library-js.5.27.0/Map.js";
20
+ import { ofSeq as ofSeq_2 } from "../fable_modules/fable-library-js.5.27.0/Map.js";
20
21
 
21
22
  class TokenStream {
22
23
  constructor(tokens) {
@@ -112,22 +113,22 @@ function mkSpanFrom(a, b) {
112
113
  function isStartAtom(k) {
113
114
  switch (k.tag) {
114
115
  case 4:
115
- case 5:
116
116
  case 6:
117
117
  case 7:
118
118
  case 8:
119
119
  case 9:
120
- case 27:
121
- case 29:
122
- case 43:
123
120
  case 10:
124
- case 13:
125
- case 17:
126
- case 21:
127
- case 22:
121
+ case 28:
122
+ case 30:
123
+ case 44:
124
+ case 11:
128
125
  case 14:
129
- case 46:
126
+ case 18:
127
+ case 22:
128
+ case 23:
129
+ case 15:
130
130
  case 47:
131
+ case 48:
131
132
  return true;
132
133
  default:
133
134
  return false;
@@ -146,13 +147,13 @@ function isUpperIdent(name) {
146
147
  function isStartPatternAtom(k) {
147
148
  switch (k.tag) {
148
149
  case 4:
149
- case 5:
150
150
  case 6:
151
151
  case 7:
152
- case 9:
153
- case 29:
154
- case 27:
155
- case 43:
152
+ case 8:
153
+ case 10:
154
+ case 30:
155
+ case 28:
156
+ case 44:
156
157
  return true;
157
158
  default:
158
159
  return false;
@@ -162,13 +163,13 @@ function isStartPatternAtom(k) {
162
163
  function parseLiteral(t) {
163
164
  const matchValue = t.Kind;
164
165
  switch (matchValue.tag) {
165
- case 5:
166
- return new Literal(/* LInt */ 0, [matchValue.fields[0]]);
167
166
  case 6:
168
- return new Literal(/* LFloat */ 1, [matchValue.fields[0]]);
167
+ return new Literal(/* LInt */ 0, [matchValue.fields[0]]);
169
168
  case 7:
169
+ return new Literal(/* LFloat */ 1, [matchValue.fields[0]]);
170
+ case 8:
170
171
  return new Literal(/* LString */ 3, [matchValue.fields[0]]);
171
- case 9:
172
+ case 10:
172
173
  return new Literal(/* LBool */ 2, [matchValue.fields[0]]);
173
174
  default:
174
175
  throw new ParseException(new ParseError("Expected literal", t.Span));
@@ -289,32 +290,93 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
289
290
  };
290
291
  let allowIndentedApplication = true;
291
292
  let allowBinaryNewlineSkipping = true;
293
+ const builtInTypeNames = ofSeq_1(["unit", "int", "float", "numeric", "bool", "string", "type", "list", "List", "option", "Option", "task", "Task", "map", "Map"], {
294
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
295
+ });
296
+ const parseTypeParameters = () => {
297
+ if (TokenStream__Match_5CEB78CD(stream, TokenKind.Less)) {
298
+ const seen = new Set([]);
299
+ const parameter = () => {
300
+ const token_1 = TokenStream__Peek(stream);
301
+ const matchValue_6 = token_1.Kind;
302
+ if (matchValue_6.tag === 5) {
303
+ if (addToSet(matchValue_6.fields[0], seen)) {
304
+ TokenStream__Next(stream);
305
+ return matchValue_6.fields[0];
306
+ }
307
+ else {
308
+ throw new ParseException(new ParseError(concat("Duplicate type parameter \'", matchValue_6.fields[0]), token_1.Span));
309
+ }
310
+ }
311
+ else {
312
+ throw new ParseException(new ParseError("Expected a type parameter such as \'a", token_1.Span));
313
+ }
314
+ };
315
+ const parameters = [parameter()];
316
+ while (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
317
+ void (parameters.push(parameter()));
318
+ }
319
+ TokenStream__Expect_77B9EE56(stream, TokenKind.Greater, "Expected \'>\' after type parameters");
320
+ return ofSeq(parameters);
321
+ }
322
+ else {
323
+ return empty();
324
+ }
325
+ };
326
+ const quantify = (parameters_1, result) => {
327
+ if (isEmpty(parameters_1)) {
328
+ return result;
329
+ }
330
+ else {
331
+ return new TypeRef(/* TRForall */ 3, [parameters_1, result]);
332
+ }
333
+ };
292
334
  const parseTypeRefAtom = () => {
293
- let firstName, matchValue_4, parts_1, keepGoing;
294
335
  TokenStream__SkipNewlines(stream);
295
- const matchValue_6 = TokenStream__Peek(stream).Kind;
296
- switch (matchValue_6.tag) {
297
- case 4:
298
- return new TypeRef(/* TRName */ 0, [(firstName = ((matchValue_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind, (matchValue_4.tag === 4) ? matchValue_4.fields[0] : "")), (parts_1 = [], (void (parts_1.push(firstName)), (keepGoing = true, ((() => {
299
- while (keepGoing && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
300
- const matchValue_5 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'.\' in qualified type name").Kind;
301
- if (matchValue_5.tag === 4) {
302
- void (parts_1.push(matchValue_5.fields[0]));
303
- }
304
- keepGoing = true;
305
- }
306
- })(), join(".", parts_1))))))]);
307
- case 43: {
336
+ const matchValue_7 = TokenStream__Peek(stream).Kind;
337
+ switch (matchValue_7.tag) {
338
+ case 4: {
339
+ const nameToken = TokenStream__Peek(stream);
340
+ let qualified;
341
+ let firstName;
342
+ const matchValue_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind;
343
+ firstName = ((matchValue_4.tag === 4) ? matchValue_4.fields[0] : "");
344
+ const parts_1 = [];
345
+ void (parts_1.push(firstName));
346
+ let keepGoing = true;
347
+ while (keepGoing && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
348
+ const matchValue_5 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'.\' in qualified type name").Kind;
349
+ if (matchValue_5.tag === 4) {
350
+ void (parts_1.push(matchValue_5.fields[0]));
351
+ }
352
+ keepGoing = true;
353
+ }
354
+ qualified = join(".", parts_1);
355
+ if (TokenStream__Match_5CEB78CD(stream, TokenKind.Less)) {
356
+ if (FSharpSet__Contains(builtInTypeNames, qualified)) {
357
+ throw new ParseException(new ParseError(concat("Built-in type \'", qualified, "\' uses its existing type syntax"), nameToken.Span));
358
+ }
359
+ return new TypeRef(/* TRApplied */ 2, [qualified, parseTypeArguments()[0]]);
360
+ }
361
+ else {
362
+ return new TypeRef(/* TRName */ 0, [qualified]);
363
+ }
364
+ }
365
+ case 5: {
366
+ TokenStream__Next(stream);
367
+ return new TypeRef(/* TRVariable */ 1, [matchValue_7.fields[0]]);
368
+ }
369
+ case 44: {
308
370
  TokenStream__Next(stream);
309
371
  const isStructural = TokenStream__Match_5CEB78CD(stream, TokenKind.Bar);
310
372
  const fields = [];
311
- const seen = new Set([]);
373
+ const seen_1 = new Set([]);
312
374
  const parseField = () => {
313
375
  const nameTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in inline record type");
314
376
  let fieldName;
315
- const matchValue_7 = nameTok.Kind;
316
- fieldName = ((matchValue_7.tag === 4) ? matchValue_7.fields[0] : "");
317
- if (!addToSet(fieldName, seen)) {
377
+ const matchValue_8 = nameTok.Kind;
378
+ fieldName = ((matchValue_8.tag === 4) ? matchValue_8.fields[0] : "");
379
+ if (!addToSet(fieldName, seen_1)) {
318
380
  throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName, "\' in inline record type"), nameTok.Span));
319
381
  }
320
382
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' after inline record type field name");
@@ -335,13 +397,13 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
335
397
  }
336
398
  TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in inline record type");
337
399
  if (isStructural) {
338
- return new TypeRef(/* TRStructuralRecord */ 6, [toList(fields)]);
400
+ return new TypeRef(/* TRStructuralRecord */ 9, [toList(fields)]);
339
401
  }
340
402
  else {
341
- return new TypeRef(/* TRRecord */ 5, [toList(fields)]);
403
+ return new TypeRef(/* TRRecord */ 8, [toList(fields)]);
342
404
  }
343
405
  }
344
- case 27: {
406
+ case 28: {
345
407
  TokenStream__Next(stream);
346
408
  const first_1 = parseTypeRef();
347
409
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Star)) {
@@ -352,7 +414,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
352
414
  void (items_2.push(parseTypeRef()));
353
415
  }
354
416
  TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in tuple type");
355
- return new TypeRef(/* TRTuple */ 1, [toList(items_2)]);
417
+ return new TypeRef(/* TRTuple */ 4, [toList(items_2)]);
356
418
  }
357
419
  else {
358
420
  TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in type expression");
@@ -363,14 +425,22 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
363
425
  throw new ParseException(new ParseError("Expected type expression", TokenStream__Peek(stream).Span));
364
426
  }
365
427
  };
428
+ const parseTypeArguments = () => {
429
+ const arguments$_1 = [parseTypeRef()];
430
+ while (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
431
+ void (arguments$_1.push(parseTypeRef()));
432
+ }
433
+ const closing = TokenStream__Expect_77B9EE56(stream, TokenKind.Greater, "Expected \'>\' after type arguments");
434
+ return [ofSeq(arguments$_1), closing];
435
+ };
366
436
  const parseTypeRefPostfix = () => {
367
437
  let t = parseTypeRefAtom();
368
438
  let loop = true;
369
439
  while (loop) {
370
- const matchValue_8 = TokenStream__Peek(stream).Kind;
440
+ const matchValue_9 = TokenStream__Peek(stream).Kind;
371
441
  let matchResult_1;
372
- if (matchValue_8.tag === 4) {
373
- switch (matchValue_8.fields[0]) {
442
+ if (matchValue_9.tag === 4) {
443
+ switch (matchValue_9.fields[0]) {
374
444
  case "list": {
375
445
  matchResult_1 = 0;
376
446
  break;
@@ -397,12 +467,12 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
397
467
  switch (matchResult_1) {
398
468
  case 0: {
399
469
  TokenStream__Next(stream);
400
- t = (new TypeRef(/* TRPostfix */ 3, [t, "list"]));
470
+ t = (new TypeRef(/* TRPostfix */ 6, [t, "list"]));
401
471
  break;
402
472
  }
403
473
  case 1: {
404
474
  TokenStream__Next(stream);
405
- t = (new TypeRef(/* TRPostfix */ 3, [t, "option"]));
475
+ t = (new TypeRef(/* TRPostfix */ 6, [t, "option"]));
406
476
  break;
407
477
  }
408
478
  case 2: {
@@ -410,16 +480,16 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
410
480
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.LBracket)) {
411
481
  const keyType = parseTypeRef();
412
482
  TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' after map key type");
413
- t = (new TypeRef(/* TRMap */ 4, [keyType, t]));
483
+ t = (new TypeRef(/* TRMap */ 7, [keyType, t]));
414
484
  }
415
485
  else {
416
- t = (new TypeRef(/* TRPostfix */ 3, [t, "map"]));
486
+ t = (new TypeRef(/* TRPostfix */ 6, [t, "map"]));
417
487
  }
418
488
  break;
419
489
  }
420
490
  case 3: {
421
491
  TokenStream__Next(stream);
422
- t = (new TypeRef(/* TRPostfix */ 3, [t, "task"]));
492
+ t = (new TypeRef(/* TRPostfix */ 6, [t, "task"]));
423
493
  break;
424
494
  }
425
495
  case 4: {
@@ -433,7 +503,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
433
503
  const parseTypeRef = () => {
434
504
  const left = parseTypeRefPostfix();
435
505
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Arrow)) {
436
- return new TypeRef(/* TRFun */ 2, [left, parseTypeRef()]);
506
+ return new TypeRef(/* TRFun */ 5, [left, parseTypeRef()]);
437
507
  }
438
508
  else {
439
509
  return left;
@@ -441,23 +511,23 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
441
511
  };
442
512
  const parseParam = () => {
443
513
  TokenStream__SkipNewlines(stream);
444
- const matchValue_9 = TokenStream__Peek(stream).Kind;
445
- switch (matchValue_9.tag) {
514
+ const matchValue_10 = TokenStream__Peek(stream).Kind;
515
+ switch (matchValue_10.tag) {
446
516
  case 4:
447
- return new Param(matchValue_9.fields[0], undefined, TokenStream__Next(stream).Span);
448
- case 27: {
517
+ return new Param(matchValue_10.fields[0], undefined, TokenStream__Next(stream).Span);
518
+ case 28: {
449
519
  const lp = TokenStream__Next(stream);
450
520
  TokenStream__SkipNewlines(stream);
451
521
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.RParen)) {
452
522
  return new Param("()", new TypeRef(/* TRName */ 0, ["unit"]), mkSpanFrom(lp.Span, TokenStream__TokenAt_Z524259A4(stream, TokenStream__get_Index(stream) - 1).Span));
453
523
  }
454
524
  else {
455
- let name;
456
- const matchValue_10 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected parameter name in annotated parameter").Kind;
457
- name = ((matchValue_10.tag === 4) ? matchValue_10.fields[0] : "");
525
+ let name_4;
526
+ const matchValue_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected parameter name in annotated parameter").Kind;
527
+ name_4 = ((matchValue_11.tag === 4) ? matchValue_11.fields[0] : "");
458
528
  TokenStream__SkipNewlines(stream);
459
529
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in annotated parameter");
460
- return new Param(name, parseTypeRef(), mkSpanFrom(lp.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after annotated parameter").Span));
530
+ return new Param(name_4, parseTypeRef(), mkSpanFrom(lp.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after annotated parameter").Span));
461
531
  }
462
532
  }
463
533
  default:
@@ -477,10 +547,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
477
547
  }
478
548
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
479
549
  }
480
- const matchValue_11 = TokenStream__Peek(stream).Kind;
481
- switch (matchValue_11.tag) {
550
+ const matchValue_12 = TokenStream__Peek(stream).Kind;
551
+ switch (matchValue_12.tag) {
482
552
  case 4:
483
- case 27: {
553
+ case 28: {
484
554
  const param = parseParam();
485
555
  if (firstParamColumn != null) {
486
556
  const firstCol = firstParamColumn | 0;
@@ -501,12 +571,20 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
501
571
  return args;
502
572
  };
503
573
  const parseTypeDecl = (backendImport) => {
504
- let attribute, matchValue_17;
574
+ let attribute, matchValue_18;
505
575
  const typeTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Type, "Expected \'type\'");
506
576
  const isRec = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
507
- let name_1;
508
- const matchValue_12 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'type\'").Kind;
509
- name_1 = ((matchValue_12.tag === 4) ? matchValue_12.fields[0] : "");
577
+ const nameTok_2 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'type\'");
578
+ let name_5;
579
+ const matchValue_13 = nameTok_2.Kind;
580
+ name_5 = ((matchValue_13.tag === 4) ? matchValue_13.fields[0] : "");
581
+ const typeParameters = parseTypeParameters();
582
+ if (!isEmpty(typeParameters) && FSharpSet__Contains(builtInTypeNames, name_5)) {
583
+ throw new ParseException(new ParseError(concat("Built-in type name \'", name_5, "\' is reserved"), nameTok_2.Span));
584
+ }
585
+ if (!isEmpty(typeParameters) && (backendImport != null)) {
586
+ throw new ParseException(new ParseError("Imported type definitions require a concrete representation", nameTok_2.Span));
587
+ }
510
588
  TokenStream__SkipNewlines(stream);
511
589
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in type declaration");
512
590
  let hasOuterIndent = false;
@@ -518,10 +596,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
518
596
  }
519
597
  }
520
598
  const labels_2 = fieldLabels();
521
- let patternInput_1;
522
- const matchValue_16 = TokenStream__Peek(stream).Kind;
523
- switch (matchValue_16.tag) {
524
- case 43: {
599
+ let patternInput_2;
600
+ const matchValue_17 = TokenStream__Peek(stream).Kind;
601
+ switch (matchValue_17.tag) {
602
+ case 44: {
525
603
  const lbIndex = TokenStream__get_Index(stream) | 0;
526
604
  const lb = TokenStream__Expect_77B9EE56(stream, TokenKind.LBrace, "Expected \'{\' in record type declaration");
527
605
  if (!hasNonLayoutTokenAfterOnSameLine(lbIndex, lb.Span.Start.Line)) {
@@ -532,8 +610,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
532
610
  TokenStream__SkipNewlines(stream);
533
611
  const fieldTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in type declaration");
534
612
  let fieldName_1;
535
- const matchValue_13 = fieldTok.Kind;
536
- fieldName_1 = ((matchValue_13.tag === 4) ? matchValue_13.fields[0] : "");
613
+ const matchValue_14 = fieldTok.Kind;
614
+ fieldName_1 = ((matchValue_14.tag === 4) ? matchValue_14.fields[0] : "");
537
615
  TokenStream__SkipNewlines(stream);
538
616
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' after field name");
539
617
  const fieldType_1 = parseTypeRef();
@@ -562,9 +640,9 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
562
640
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
563
641
  }
564
642
  if (sawNewline_1) {
565
- const matchValue_14 = TokenStream__Peek(stream).Kind;
566
- switch (matchValue_14.tag) {
567
- case 44: {
643
+ const matchValue_15 = TokenStream__Peek(stream).Kind;
644
+ switch (matchValue_15.tag) {
645
+ case 45: {
568
646
  doneFields = true;
569
647
  break;
570
648
  }
@@ -588,10 +666,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
588
666
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex, rb.Span.Start.Line)) {
589
667
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb.Span));
590
668
  }
591
- patternInput_1 = [toList(fields_1), empty(), rb.Span];
669
+ patternInput_2 = [toList(fields_1), empty(), rb.Span];
592
670
  break;
593
671
  }
594
- case 26:
672
+ case 27:
595
673
  case 4: {
596
674
  const cases = [];
597
675
  const parseCase = () => {
@@ -599,8 +677,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
599
677
  TokenStream__Match_5CEB78CD(stream, TokenKind.Bar);
600
678
  const caseTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name");
601
679
  let caseName;
602
- const matchValue_15 = caseTok.Kind;
603
- caseName = ((matchValue_15.tag === 4) ? matchValue_15.fields[0] : "");
680
+ const matchValue_16 = caseTok.Kind;
681
+ caseName = ((matchValue_16.tag === 4) ? matchValue_16.fields[0] : "");
604
682
  if (!isUpperIdent(caseName)) {
605
683
  throw new ParseException(new ParseError("Union case name must start with uppercase letter", caseTok.Span));
606
684
  }
@@ -629,7 +707,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
629
707
  doneCases = true;
630
708
  }
631
709
  }
632
- patternInput_1 = [empty(), toList(cases), new Span(lastSpan, lastSpan)];
710
+ patternInput_2 = [empty(), toList(cases), new Span(lastSpan, lastSpan)];
633
711
  break;
634
712
  }
635
713
  default:
@@ -645,7 +723,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
645
723
  }
646
724
  let import$;
647
725
  const option_5 = backendImport;
648
- import$ = ((option_5 != null) ? ((attribute = option_5, (matchValue_17 = attribute.Arguments, !isEmpty(matchValue_17) ? (!isEmpty(tail_1(matchValue_17)) ? (isEmpty(tail_1(tail_1(matchValue_17))) ? ((!isNullOrWhiteSpace(head_1(matchValue_17)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_17)))) ? (new BackendImport(head_1(matchValue_17), head_1(tail_1(matchValue_17)), attribute.Span)) : (() => {
726
+ import$ = ((option_5 != null) ? ((attribute = option_5, (matchValue_18 = attribute.Arguments, !isEmpty(matchValue_18) ? (!isEmpty(tail_1(matchValue_18)) ? (isEmpty(tail_1(tail_1(matchValue_18))) ? ((!isNullOrWhiteSpace(head_1(matchValue_18)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_18)))) ? (new BackendImport(head_1(matchValue_18), head_1(tail_1(matchValue_18)), attribute.Span)) : (() => {
649
727
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
650
728
  })()) : (() => {
651
729
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
@@ -654,43 +732,43 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
654
732
  })()) : (() => {
655
733
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
656
734
  })()))) : undefined);
657
- const span_2 = mkSpanFrom(typeTok.Span, patternInput_1[2]);
735
+ const span_2 = mkSpanFrom(typeTok.Span, patternInput_2[2]);
658
736
  recordFieldLabels(span_2, labels_2);
659
- return new Stmt(/* SType */ 0, [new TypeDef(name_1, isRec, patternInput_1[0], patternInput_1[1], import$, span_2)]);
737
+ return new Stmt(/* SType */ 0, [new TypeDef(name_5, typeParameters, isRec, patternInput_2[0], patternInput_2[1], import$, span_2)]);
660
738
  };
661
739
  const parsePattern = () => {
662
740
  TokenStream__SkipNewlines(stream);
663
741
  const t_1 = TokenStream__Peek(stream);
664
- const matchValue_18 = t_1.Kind;
665
- let matchResult_2, name_3, name_4;
666
- switch (matchValue_18.tag) {
667
- case 5:
742
+ const matchValue_19 = t_1.Kind;
743
+ let matchResult_2, name_7, name_8;
744
+ switch (matchValue_19.tag) {
668
745
  case 6:
669
746
  case 7:
670
- case 9: {
747
+ case 8:
748
+ case 10: {
671
749
  matchResult_2 = 2;
672
750
  break;
673
751
  }
674
- case 29: {
752
+ case 30: {
675
753
  matchResult_2 = 3;
676
754
  break;
677
755
  }
678
- case 27: {
756
+ case 28: {
679
757
  matchResult_2 = 4;
680
758
  break;
681
759
  }
682
- case 43: {
760
+ case 44: {
683
761
  matchResult_2 = 5;
684
762
  break;
685
763
  }
686
764
  case 4: {
687
- if (matchValue_18.fields[0] === "_") {
765
+ if (matchValue_19.fields[0] === "_") {
688
766
  matchResult_2 = 0;
689
- name_3 = matchValue_18.fields[0];
767
+ name_7 = matchValue_19.fields[0];
690
768
  }
691
769
  else {
692
770
  matchResult_2 = 1;
693
- name_4 = matchValue_18.fields[0];
771
+ name_8 = matchValue_19.fields[0];
694
772
  }
695
773
  break;
696
774
  }
@@ -702,24 +780,24 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
702
780
  return new Pattern(/* PWildcard */ 0, [TokenStream__Next(stream).Span]);
703
781
  case 1: {
704
782
  const t_3 = TokenStream__Next(stream);
705
- if (isUpperIdent(name_4) && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
783
+ if (isUpperIdent(name_8) && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
706
784
  const caseTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name after \'.\'");
707
785
  let caseName_1;
708
- const matchValue_19 = caseTok_1.Kind;
709
- caseName_1 = ((matchValue_19.tag === 4) ? matchValue_19.fields[0] : "");
786
+ const matchValue_20 = caseTok_1.Kind;
787
+ caseName_1 = ((matchValue_20.tag === 4) ? matchValue_20.fields[0] : "");
710
788
  if (!isUpperIdent(caseName_1)) {
711
789
  throw new ParseException(new ParseError("Union case name must start with uppercase letter", caseTok_1.Span));
712
790
  }
713
791
  if (isStartPatternAtom(TokenStream__Peek(stream).Kind)) {
714
792
  const p = parsePattern();
715
- return new Pattern(/* PUnionCase */ 10, [name_4, caseName_1, p, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p))]);
793
+ return new Pattern(/* PUnionCase */ 10, [name_8, caseName_1, p, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p))]);
716
794
  }
717
795
  else {
718
- return new Pattern(/* PUnionCase */ 10, [name_4, caseName_1, undefined, mkSpanFrom(t_3.Span, caseTok_1.Span)]);
796
+ return new Pattern(/* PUnionCase */ 10, [name_8, caseName_1, undefined, mkSpanFrom(t_3.Span, caseTok_1.Span)]);
719
797
  }
720
798
  }
721
799
  else {
722
- switch (name_4) {
800
+ switch (name_8) {
723
801
  case "None":
724
802
  return new Pattern(/* PNone */ 9, [t_3.Span]);
725
803
  case "Some": {
@@ -727,17 +805,17 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
727
805
  return new Pattern(/* PSome */ 8, [p_1, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_1))]);
728
806
  }
729
807
  default:
730
- if (isUpperIdent(name_4)) {
808
+ if (isUpperIdent(name_8)) {
731
809
  if (isStartPatternAtom(TokenStream__Peek(stream).Kind)) {
732
810
  const p_2 = parsePattern();
733
- return new Pattern(/* PUnionCase */ 10, [undefined, name_4, p_2, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_2))]);
811
+ return new Pattern(/* PUnionCase */ 10, [undefined, name_8, p_2, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_2))]);
734
812
  }
735
813
  else {
736
- return new Pattern(/* PUnionCase */ 10, [undefined, name_4, undefined, t_3.Span]);
814
+ return new Pattern(/* PUnionCase */ 10, [undefined, name_8, undefined, t_3.Span]);
737
815
  }
738
816
  }
739
817
  else {
740
- return new Pattern(/* PVar */ 1, [name_4, t_3.Span]);
818
+ return new Pattern(/* PVar */ 1, [name_8, t_3.Span]);
741
819
  }
742
820
  }
743
821
  }
@@ -803,13 +881,13 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
803
881
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
804
882
  TokenStream__Next(stream);
805
883
  const fields_3 = [];
806
- const seen_1 = new Set([]);
884
+ const seen_2 = new Set([]);
807
885
  const parseTypeField = () => {
808
886
  const nameTok_3 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record type pattern");
809
887
  let fieldName_2;
810
- const matchValue_20 = nameTok_3.Kind;
811
- fieldName_2 = ((matchValue_20.tag === 4) ? matchValue_20.fields[0] : "");
812
- if (!addToSet(fieldName_2, seen_1)) {
888
+ const matchValue_21 = nameTok_3.Kind;
889
+ fieldName_2 = ((matchValue_21.tag === 4) ? matchValue_21.fields[0] : "");
890
+ if (!addToSet(fieldName_2, seen_2)) {
813
891
  throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName_2, "\' in structural record type pattern"), nameTok_3.Span));
814
892
  }
815
893
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in structural record type pattern");
@@ -828,7 +906,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
828
906
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_2, rb_2.Span.Start.Line)) {
829
907
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_2.Span));
830
908
  }
831
- return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRStructuralRecord */ 6, [toList(fields_3)]), mkSpanFrom(lb_2.Span, rb_2.Span)]);
909
+ return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRStructuralRecord */ 9, [toList(fields_3)]), mkSpanFrom(lb_2.Span, rb_2.Span)]);
832
910
  }
833
911
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
834
912
  const clauses = [];
@@ -894,26 +972,26 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
894
972
  TokenStream__SkipNewlines(stream);
895
973
  isTypeRefPattern = TokenStream__Match_5CEB78CD(stream, TokenKind.Colon);
896
974
  }
897
- catch (matchValue_21) {
975
+ catch (matchValue_22) {
898
976
  isTypeRefPattern = false;
899
977
  }
900
978
  TokenStream__Restore_Z524259A4(stream, mark);
901
979
  if (isTypeRefPattern) {
902
980
  const fields_4 = [];
903
- const seen_2 = new Set([]);
981
+ const seen_3 = new Set([]);
904
982
  const parseTypeField_1 = () => {
905
983
  TokenStream__SkipNewlines(stream);
906
984
  const nameTok_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record type pattern");
907
- let name_5;
908
- const matchValue_22 = nameTok_4.Kind;
909
- name_5 = ((matchValue_22.tag === 4) ? matchValue_22.fields[0] : "");
910
- if (!addToSet(name_5, seen_2)) {
911
- throw new ParseException(new ParseError(concat("Duplicate field \'", name_5, "\' in record type pattern"), nameTok_4.Span));
985
+ let name_9;
986
+ const matchValue_23 = nameTok_4.Kind;
987
+ name_9 = ((matchValue_23.tag === 4) ? matchValue_23.fields[0] : "");
988
+ if (!addToSet(name_9, seen_3)) {
989
+ throw new ParseException(new ParseError(concat("Duplicate field \'", name_9, "\' in record type pattern"), nameTok_4.Span));
912
990
  }
913
991
  TokenStream__SkipNewlines(stream);
914
992
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in record type pattern field");
915
993
  const t_5 = parseTypeRef();
916
- void (fields_4.push([name_5, t_5]));
994
+ void (fields_4.push([name_9, t_5]));
917
995
  };
918
996
  parseTypeField_1();
919
997
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
@@ -926,24 +1004,24 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
926
1004
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_4, rb_4.Span.Start.Line)) {
927
1005
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb_4.Span));
928
1006
  }
929
- return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRRecord */ 5, [toList(fields_4)]), mkSpanFrom(lb_2.Span, rb_4.Span)]);
1007
+ return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRRecord */ 8, [toList(fields_4)]), mkSpanFrom(lb_2.Span, rb_4.Span)]);
930
1008
  }
931
1009
  else {
932
1010
  const fields_5 = [];
933
- const seen_3 = new Set([]);
1011
+ const seen_4 = new Set([]);
934
1012
  const parseField_2 = () => {
935
1013
  TokenStream__SkipNewlines(stream);
936
1014
  const nameTok_5 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record pattern");
937
- let name_6;
938
- const matchValue_23 = nameTok_5.Kind;
939
- name_6 = ((matchValue_23.tag === 4) ? matchValue_23.fields[0] : "");
940
- if (!addToSet(name_6, seen_3)) {
941
- throw new ParseException(new ParseError(concat("Duplicate field \'", name_6, "\' in record pattern"), nameTok_5.Span));
1015
+ let name_10;
1016
+ const matchValue_24 = nameTok_5.Kind;
1017
+ name_10 = ((matchValue_24.tag === 4) ? matchValue_24.fields[0] : "");
1018
+ if (!addToSet(name_10, seen_4)) {
1019
+ throw new ParseException(new ParseError(concat("Duplicate field \'", name_10, "\' in record pattern"), nameTok_5.Span));
942
1020
  }
943
1021
  TokenStream__SkipNewlines(stream);
944
1022
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record pattern field");
945
1023
  const p_3 = parsePatternCons();
946
- void (fields_5.push([name_6, p_3]));
1024
+ void (fields_5.push([name_10, p_3]));
947
1025
  };
948
1026
  parseField_2();
949
1027
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
@@ -998,60 +1076,60 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
998
1076
  }
999
1077
  };
1000
1078
  const parsePrimary = () => {
1001
- let matchValue_31, matchValue_32;
1079
+ let matchValue_32, matchValue_33;
1002
1080
  TokenStream__SkipNewlines(stream);
1003
1081
  const t_6 = TokenStream__Peek(stream);
1004
- const matchValue_24 = t_6.Kind;
1005
- let matchResult_3, raw_1, name_7;
1006
- switch (matchValue_24.tag) {
1007
- case 5:
1082
+ const matchValue_25 = t_6.Kind;
1083
+ let matchResult_3, raw_1, name_11;
1084
+ switch (matchValue_25.tag) {
1008
1085
  case 6:
1009
1086
  case 7:
1010
- case 9: {
1087
+ case 8:
1088
+ case 10: {
1011
1089
  matchResult_3 = 0;
1012
1090
  break;
1013
1091
  }
1014
- case 27: {
1092
+ case 28: {
1015
1093
  matchResult_3 = 4;
1016
1094
  break;
1017
1095
  }
1018
- case 29: {
1096
+ case 30: {
1019
1097
  matchResult_3 = 5;
1020
1098
  break;
1021
1099
  }
1022
- case 43: {
1100
+ case 44: {
1023
1101
  matchResult_3 = 6;
1024
1102
  break;
1025
1103
  }
1026
- case 10: {
1104
+ case 11: {
1027
1105
  matchResult_3 = 7;
1028
1106
  break;
1029
1107
  }
1030
- case 13: {
1108
+ case 14: {
1031
1109
  matchResult_3 = 8;
1032
1110
  break;
1033
1111
  }
1034
- case 17: {
1112
+ case 18: {
1035
1113
  matchResult_3 = 9;
1036
1114
  break;
1037
1115
  }
1038
- case 21: {
1116
+ case 22: {
1039
1117
  matchResult_3 = 10;
1040
1118
  break;
1041
1119
  }
1042
- case 22: {
1120
+ case 23: {
1043
1121
  matchResult_3 = 11;
1044
1122
  break;
1045
1123
  }
1046
- case 14: {
1124
+ case 15: {
1047
1125
  matchResult_3 = 12;
1048
1126
  break;
1049
1127
  }
1050
- case 46: {
1128
+ case 47: {
1051
1129
  matchResult_3 = 13;
1052
1130
  break;
1053
1131
  }
1054
- case 47: {
1132
+ case 48: {
1055
1133
  matchResult_3 = 14;
1056
1134
  break;
1057
1135
  }
@@ -1063,24 +1141,24 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1063
1141
  matchResult_3 = 16;
1064
1142
  break;
1065
1143
  }
1066
- case 8: {
1144
+ case 9: {
1067
1145
  matchResult_3 = 1;
1068
- raw_1 = matchValue_24.fields[0];
1146
+ raw_1 = matchValue_25.fields[0];
1069
1147
  break;
1070
1148
  }
1071
1149
  case 4: {
1072
- if (matchValue_24.fields[0] === "export") {
1150
+ if (matchValue_25.fields[0] === "export") {
1073
1151
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Let)) {
1074
1152
  matchResult_3 = 2;
1075
1153
  }
1076
1154
  else {
1077
1155
  matchResult_3 = 3;
1078
- name_7 = matchValue_24.fields[0];
1156
+ name_11 = matchValue_25.fields[0];
1079
1157
  }
1080
1158
  }
1081
1159
  else {
1082
1160
  matchResult_3 = 3;
1083
- name_7 = matchValue_24.fields[0];
1161
+ name_11 = matchValue_25.fields[0];
1084
1162
  }
1085
1163
  break;
1086
1164
  }
@@ -1274,21 +1352,21 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1274
1352
  }
1275
1353
  }
1276
1354
  flushText();
1277
- return new Expr(/* EInterpolatedString */ 30, [(parts.length === 0) ? singleton(new InterpolatedPart(/* IPText */ 0, [""])) : toList(parts), span_1]);
1355
+ return new Expr(/* EInterpolatedString */ 31, [(parts.length === 0) ? singleton(new InterpolatedPart(/* IPText */ 0, [""])) : toList(parts), span_1]);
1278
1356
  }
1279
1357
  case 2:
1280
1358
  throw new ParseException(new ParseError("\'export let\' is only supported at top level", t_6.Span));
1281
1359
  case 3: {
1282
1360
  const t_9 = TokenStream__Next(stream);
1283
- switch (name_7) {
1361
+ switch (name_11) {
1284
1362
  case "None":
1285
- return new Expr(/* ENone */ 27, [t_9.Span]);
1363
+ return new Expr(/* ENone */ 28, [t_9.Span]);
1286
1364
  case "Some": {
1287
1365
  const arg = parsePrimary();
1288
- return new Expr(/* ESome */ 26, [arg, mkSpanFrom(t_9.Span, Ast_spanOfExpr(arg))]);
1366
+ return new Expr(/* ESome */ 27, [arg, mkSpanFrom(t_9.Span, Ast_spanOfExpr(arg))]);
1289
1367
  }
1290
1368
  default:
1291
- return new Expr(/* EVar */ 2, [name_7, t_9.Span]);
1369
+ return new Expr(/* EVar */ 2, [name_11, t_9.Span]);
1292
1370
  }
1293
1371
  }
1294
1372
  case 4: {
@@ -1306,10 +1384,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1306
1384
  void (elements_2.push(parseExpr()));
1307
1385
  }
1308
1386
  const rp_4 = TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after tuple expression");
1309
- return new Expr(/* ETuple */ 15, [toList(elements_2), mkSpanFrom(lp_2.Span, rp_4.Span)]);
1387
+ return new Expr(/* ETuple */ 16, [toList(elements_2), mkSpanFrom(lp_2.Span, rp_4.Span)]);
1310
1388
  }
1311
1389
  else {
1312
- return new Expr(/* EParen */ 3, [first_4, mkSpanFrom(lp_2.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after expression").Span)]);
1390
+ return new Expr(/* EParen */ 4, [first_4, mkSpanFrom(lp_2.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after expression").Span)]);
1313
1391
  }
1314
1392
  }
1315
1393
  }
@@ -1321,7 +1399,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1321
1399
  }
1322
1400
  consumeLayoutSeparators();
1323
1401
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBracket)) {
1324
- return new Expr(/* EList */ 13, [empty(), mkSpanFrom(lb_3.Span, lb_3.Span)]);
1402
+ return new Expr(/* EList */ 14, [empty(), mkSpanFrom(lb_3.Span, lb_3.Span)]);
1325
1403
  }
1326
1404
  else {
1327
1405
  const first_5 = parseEntryExpr();
@@ -1330,7 +1408,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1330
1408
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? true : TokenStream__Match_5CEB78CD(stream, TokenKind.RangeDots)) {
1331
1409
  throw new ParseException(new ParseError("Invalid range syntax", TokenStream__Peek(stream).Span));
1332
1410
  }
1333
- return new Expr(/* ERange */ 14, [first_5, second, mkSpanFrom(lb_3.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in range expression").Span)]);
1411
+ return new Expr(/* ERange */ 15, [first_5, second, mkSpanFrom(lb_3.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in range expression").Span)]);
1334
1412
  }
1335
1413
  else {
1336
1414
  const elements_3 = [];
@@ -1349,7 +1427,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1349
1427
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_6, rb_7.Span.Start.Line)) {
1350
1428
  throw new ParseException(new ParseError("Closing \']\' cannot be on its own line; keep it with the last element", rb_7.Span));
1351
1429
  }
1352
- return new Expr(/* EList */ 13, [toList(elements_3), mkSpanFrom(lb_3.Span, rb_7.Span)]);
1430
+ return new Expr(/* EList */ 14, [toList(elements_3), mkSpanFrom(lb_3.Span, rb_7.Span)]);
1353
1431
  }
1354
1432
  }
1355
1433
  }
@@ -1361,30 +1439,30 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1361
1439
  }
1362
1440
  consumeLayoutSeparators();
1363
1441
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBrace)) {
1364
- return new Expr(/* EMap */ 18, [empty(), mkSpanFrom(lb_4.Span, lb_4.Span)]);
1442
+ return new Expr(/* EMap */ 19, [empty(), mkSpanFrom(lb_4.Span, lb_4.Span)]);
1365
1443
  }
1366
1444
  else if (TokenStream__Match_5CEB78CD(stream, TokenKind.Bar)) {
1367
1445
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
1368
1446
  throw new ParseException(new ParseError("Structural record literal must define at least one field", TokenStream__Peek(stream).Span));
1369
1447
  }
1370
1448
  const mark_1 = TokenStream__Mark(stream) | 0;
1371
- let matchValue_26;
1449
+ let matchValue_27;
1372
1450
  const baseExpr = parseExpr();
1373
1451
  TokenStream__SkipNewlines(stream);
1374
1452
  if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
1375
1453
  TokenStream__Restore_Z524259A4(stream, mark_1);
1376
- matchValue_26 = undefined;
1454
+ matchValue_27 = undefined;
1377
1455
  }
1378
1456
  else {
1379
1457
  const updates = [];
1380
1458
  const parseUpdateField = () => {
1381
- let name_8;
1382
- const matchValue_25 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record update").Kind;
1383
- name_8 = ((matchValue_25.tag === 4) ? matchValue_25.fields[0] : "");
1459
+ let name_12;
1460
+ const matchValue_26 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record update").Kind;
1461
+ name_12 = ((matchValue_26.tag === 4) ? matchValue_26.fields[0] : "");
1384
1462
  TokenStream__SkipNewlines(stream);
1385
1463
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record update field");
1386
- const value_41 = parseEntryExpr();
1387
- void (updates.push([name_8, value_41]));
1464
+ const value_44 = parseEntryExpr();
1465
+ void (updates.push([name_12, value_44]));
1388
1466
  };
1389
1467
  parseUpdateField();
1390
1468
  let keepParsing_1 = true;
@@ -1402,18 +1480,18 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1402
1480
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_7, rb_8.Span.Start.Line)) {
1403
1481
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_8.Span));
1404
1482
  }
1405
- matchValue_26 = (new Expr(/* EStructuralRecordUpdate */ 20, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
1483
+ matchValue_27 = (new Expr(/* EStructuralRecordUpdate */ 21, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
1406
1484
  }
1407
- if (matchValue_26 == null) {
1485
+ if (matchValue_27 == null) {
1408
1486
  const fields_6 = [];
1409
1487
  const parseField_3 = () => {
1410
- let name_9;
1411
- const matchValue_27 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record literal").Kind;
1412
- name_9 = ((matchValue_27.tag === 4) ? matchValue_27.fields[0] : "");
1488
+ let name_13;
1489
+ const matchValue_28 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record literal").Kind;
1490
+ name_13 = ((matchValue_28.tag === 4) ? matchValue_28.fields[0] : "");
1413
1491
  TokenStream__SkipNewlines(stream);
1414
1492
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record field");
1415
- const value_45 = parseEntryExpr();
1416
- void (fields_6.push([name_9, value_45]));
1493
+ const value_48 = parseEntryExpr();
1494
+ void (fields_6.push([name_13, value_48]));
1417
1495
  };
1418
1496
  parseField_3();
1419
1497
  let keepParsing_2 = true;
@@ -1431,10 +1509,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1431
1509
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_8, rb_9.Span.Start.Line)) {
1432
1510
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_9.Span));
1433
1511
  }
1434
- return new Expr(/* EStructuralRecord */ 17, [toList(fields_6), mkSpanFrom(lb_4.Span, rb_9.Span)]);
1512
+ return new Expr(/* EStructuralRecord */ 18, [toList(fields_6), mkSpanFrom(lb_4.Span, rb_9.Span)]);
1435
1513
  }
1436
1514
  else {
1437
- return matchValue_26;
1515
+ return matchValue_27;
1438
1516
  }
1439
1517
  }
1440
1518
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) ? true : equals(TokenStream__Peek(stream).Kind, TokenKind.RangeDots)) {
@@ -1475,27 +1553,27 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1475
1553
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_9, rb_10.Span.Start.Line)) {
1476
1554
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_10.Span));
1477
1555
  }
1478
- return new Expr(/* EMap */ 18, [toList(entries), mkSpanFrom(lb_4.Span, rb_10.Span)]);
1556
+ return new Expr(/* EMap */ 19, [toList(entries), mkSpanFrom(lb_4.Span, rb_10.Span)]);
1479
1557
  }
1480
1558
  else {
1481
1559
  const mark_2 = TokenStream__Mark(stream) | 0;
1482
- let matchValue_29;
1560
+ let matchValue_30;
1483
1561
  const baseExpr_1 = parseExpr();
1484
1562
  TokenStream__SkipNewlines(stream);
1485
1563
  if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
1486
1564
  TokenStream__Restore_Z524259A4(stream, mark_2);
1487
- matchValue_29 = undefined;
1565
+ matchValue_30 = undefined;
1488
1566
  }
1489
1567
  else {
1490
1568
  const updates_1 = [];
1491
1569
  const parseUpdateField_1 = () => {
1492
- let name_10;
1493
- const matchValue_28 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record update").Kind;
1494
- name_10 = ((matchValue_28.tag === 4) ? matchValue_28.fields[0] : "");
1570
+ let name_14;
1571
+ const matchValue_29 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record update").Kind;
1572
+ name_14 = ((matchValue_29.tag === 4) ? matchValue_29.fields[0] : "");
1495
1573
  TokenStream__SkipNewlines(stream);
1496
1574
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record update field");
1497
- const value_54 = parseEntryExpr();
1498
- void (updates_1.push([name_10, value_54]));
1575
+ const value_57 = parseEntryExpr();
1576
+ void (updates_1.push([name_14, value_57]));
1499
1577
  };
1500
1578
  parseUpdateField_1();
1501
1579
  let keepParsing_4 = true;
@@ -1512,21 +1590,21 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1512
1590
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_10, rb_11.Span.Start.Line)) {
1513
1591
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_11.Span));
1514
1592
  }
1515
- matchValue_29 = (new Expr(/* ERecordUpdate */ 19, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
1593
+ matchValue_30 = (new Expr(/* ERecordUpdate */ 20, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
1516
1594
  }
1517
- if (matchValue_29 == null) {
1595
+ if (matchValue_30 == null) {
1518
1596
  const fields_7 = [];
1519
1597
  const labels_3 = fieldLabels();
1520
1598
  const parseField_4 = () => {
1521
1599
  const nameTok_9 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record literal");
1522
1600
  addFieldLabel(labels_3, nameTok_9);
1523
- let name_11;
1524
- const matchValue_30 = nameTok_9.Kind;
1525
- name_11 = ((matchValue_30.tag === 4) ? matchValue_30.fields[0] : "");
1601
+ let name_15;
1602
+ const matchValue_31 = nameTok_9.Kind;
1603
+ name_15 = ((matchValue_31.tag === 4) ? matchValue_31.fields[0] : "");
1526
1604
  TokenStream__SkipNewlines(stream);
1527
1605
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record field");
1528
- const value_57 = parseEntryExpr();
1529
- void (fields_7.push([name_11, value_57]));
1606
+ const value_60 = parseEntryExpr();
1607
+ void (fields_7.push([name_15, value_60]));
1530
1608
  };
1531
1609
  parseField_4();
1532
1610
  let keepParsing_5 = true;
@@ -1545,10 +1623,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1545
1623
  }
1546
1624
  const span_3 = mkSpanFrom(lb_4.Span, rb_12.Span);
1547
1625
  recordFieldLabels(span_3, labels_3);
1548
- return new Expr(/* ERecord */ 16, [toList(fields_7), span_3]);
1626
+ return new Expr(/* ERecord */ 17, [toList(fields_7), span_3]);
1549
1627
  }
1550
1628
  else {
1551
- return matchValue_29;
1629
+ return matchValue_30;
1552
1630
  }
1553
1631
  }
1554
1632
  }
@@ -1560,8 +1638,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1560
1638
  return parseIf();
1561
1639
  case 10: {
1562
1640
  const raiseTok = TokenStream__Next(stream);
1563
- const value_59 = parsePrimary();
1564
- return new Expr(/* ERaise */ 7, [value_59, mkSpanFrom(raiseTok.Span, Ast_spanOfExpr(value_59))]);
1641
+ const value_62 = parsePrimary();
1642
+ return new Expr(/* ERaise */ 8, [value_62, mkSpanFrom(raiseTok.Span, Ast_spanOfExpr(value_62))]);
1565
1643
  }
1566
1644
  case 11:
1567
1645
  return parseFor();
@@ -1570,12 +1648,12 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1570
1648
  case 13: {
1571
1649
  const t_10 = TokenStream__Next(stream);
1572
1650
  const nameTok_10 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name after \'typeof\'");
1573
- return new Expr(/* ETypeOf */ 28, [(matchValue_31 = nameTok_10.Kind, (matchValue_31.tag === 4) ? matchValue_31.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
1651
+ return new Expr(/* ETypeOf */ 29, [(matchValue_32 = nameTok_10.Kind, (matchValue_32.tag === 4) ? matchValue_32.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
1574
1652
  }
1575
1653
  case 14: {
1576
1654
  const t_11 = TokenStream__Next(stream);
1577
1655
  const nameTok_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'nameof\'");
1578
- return new Expr(/* ENameOf */ 29, [(matchValue_32 = nameTok_11.Kind, (matchValue_32.tag === 4) ? matchValue_32.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
1656
+ return new Expr(/* ENameOf */ 30, [(matchValue_33 = nameTok_11.Kind, (matchValue_33.tag === 4) ? matchValue_33.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
1579
1657
  }
1580
1658
  case 15:
1581
1659
  throw new ParseException(new ParseError("Indentation error: unexpected indent in expression", t_6.Span));
@@ -1592,9 +1670,57 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1592
1670
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
1593
1671
  const fieldTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name after \'.\'");
1594
1672
  let fieldName_3;
1595
- const matchValue_33 = fieldTok_1.Kind;
1596
- fieldName_3 = ((matchValue_33.tag === 4) ? matchValue_33.fields[0] : "");
1597
- expr_3 = (new Expr(/* EFieldGet */ 21, [expr_3, fieldName_3, mkSpanFrom(Ast_spanOfExpr(expr_3), fieldTok_1.Span)]));
1673
+ const matchValue_34 = fieldTok_1.Kind;
1674
+ fieldName_3 = ((matchValue_34.tag === 4) ? matchValue_34.fields[0] : "");
1675
+ expr_3 = (new Expr(/* EFieldGet */ 22, [expr_3, fieldName_3, mkSpanFrom(Ast_spanOfExpr(expr_3), fieldTok_1.Span)]));
1676
+ }
1677
+ else if ((equals(TokenStream__Peek(stream).Kind, TokenKind.Less) && equals(TokenStream__Peek(stream).Span.Start, Ast_spanOfExpr(expr_3).End)) && ((expr_3.tag === 2) ? true : (expr_3.tag === 22))) {
1678
+ const mark_3 = TokenStream__Mark(stream) | 0;
1679
+ TokenStream__Next(stream);
1680
+ let application;
1681
+ try {
1682
+ application = parseTypeArguments();
1683
+ }
1684
+ catch (matchValue_35) {
1685
+ if (matchValue_35 instanceof ParseException) {
1686
+ application = undefined;
1687
+ }
1688
+ else {
1689
+ throw matchValue_35;
1690
+ }
1691
+ }
1692
+ if (application == null) {
1693
+ TokenStream__Restore_Z524259A4(stream, mark_3);
1694
+ keepGoing_1 = false;
1695
+ }
1696
+ else {
1697
+ const closing_1 = application[1];
1698
+ const arguments$_2 = application[0];
1699
+ let matchResult_5, name_19, span_5;
1700
+ if (expr_3.tag === 2) {
1701
+ if ((expr_3.fields[1], FSharpSet__Contains(builtInTypeNames, expr_3.fields[0]))) {
1702
+ matchResult_5 = 0;
1703
+ name_19 = expr_3.fields[0];
1704
+ span_5 = expr_3.fields[1];
1705
+ }
1706
+ else {
1707
+ matchResult_5 = 1;
1708
+ }
1709
+ }
1710
+ else {
1711
+ matchResult_5 = 1;
1712
+ }
1713
+ switch (matchResult_5) {
1714
+ case 0: {
1715
+ throw new ParseException(new ParseError(concat("Built-in type \'", name_19, "\' uses its existing type syntax"), span_5));
1716
+ break;
1717
+ }
1718
+ case 1: {
1719
+ expr_3 = (new Expr(/* ETypeApply */ 3, [expr_3, arguments$_2, mkSpanFrom(Ast_spanOfExpr(expr_3), closing_1.Span)]));
1720
+ break;
1721
+ }
1722
+ }
1723
+ }
1598
1724
  }
1599
1725
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
1600
1726
  const lb_5 = TokenStream__Peek(stream);
@@ -1605,7 +1731,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1605
1731
  TokenStream__Next(stream);
1606
1732
  const keyExpr_1 = parseExpr();
1607
1733
  const rb_13 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' after index expression");
1608
- expr_3 = (new Expr(/* EIndexGet */ 22, [expr_3, keyExpr_1, mkSpanFrom(targetSpan, rb_13.Span)]));
1734
+ expr_3 = (new Expr(/* EIndexGet */ 23, [expr_3, keyExpr_1, mkSpanFrom(targetSpan, rb_13.Span)]));
1609
1735
  }
1610
1736
  else {
1611
1737
  keepGoing_1 = false;
@@ -1625,10 +1751,10 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1625
1751
  const next_2 = TokenStream__Peek(stream);
1626
1752
  if ((next_2.Span.Start.Line === Ast_spanOfExpr(expr_4).End.Line) && isStartAtom(next_2.Kind)) {
1627
1753
  const arg_1 = parsePostfix();
1628
- expr_4 = (new Expr(/* EApply */ 5, [expr_4, arg_1, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_1))]));
1754
+ expr_4 = (new Expr(/* EApply */ 6, [expr_4, arg_1, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_1))]));
1629
1755
  }
1630
1756
  else {
1631
- const mark_3 = TokenStream__Mark(stream) | 0;
1757
+ const mark_4 = TokenStream__Mark(stream) | 0;
1632
1758
  let sawNewline_3 = false;
1633
1759
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
1634
1760
  sawNewline_3 = true;
@@ -1640,7 +1766,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1640
1766
  const candidate = TokenStream__Peek(stream);
1641
1767
  if ((candidate.Span.Start.Column > Ast_spanOfExpr(expr_4).Start.Column) && isStartAtom(candidate.Kind)) {
1642
1768
  const arg_2 = parsePostfix();
1643
- expr_4 = (new Expr(/* EApply */ 5, [expr_4, arg_2, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_2))]));
1769
+ expr_4 = (new Expr(/* EApply */ 6, [expr_4, arg_2, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_2))]));
1644
1770
  }
1645
1771
  else if (hasMultilineArgBlock && equals(candidate.Kind, TokenKind.Dedent)) {
1646
1772
  TokenStream__Next(stream);
@@ -1648,12 +1774,12 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1648
1774
  keepGoing_2 = false;
1649
1775
  }
1650
1776
  else {
1651
- TokenStream__Restore_Z524259A4(stream, mark_3);
1777
+ TokenStream__Restore_Z524259A4(stream, mark_4);
1652
1778
  keepGoing_2 = false;
1653
1779
  }
1654
1780
  }
1655
1781
  else {
1656
- TokenStream__Restore_Z524259A4(stream, mark_3);
1782
+ TokenStream__Restore_Z524259A4(stream, mark_4);
1657
1783
  keepGoing_2 = false;
1658
1784
  }
1659
1785
  }
@@ -1664,28 +1790,28 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1664
1790
  let left_2 = parseApplication();
1665
1791
  const precedence = (op) => {
1666
1792
  switch (op.tag) {
1667
- case 51:
1668
1793
  case 52:
1669
1794
  case 53:
1795
+ case 54:
1670
1796
  return 7;
1671
- case 49:
1672
1797
  case 50:
1798
+ case 51:
1673
1799
  return 6;
1674
- case 62:
1800
+ case 63:
1675
1801
  return 5;
1676
- case 61:
1802
+ case 62:
1677
1803
  return 4;
1678
- case 25:
1679
- case 54:
1804
+ case 26:
1680
1805
  case 55:
1681
1806
  case 56:
1682
1807
  case 57:
1683
- return 3;
1684
1808
  case 58:
1685
- return 2;
1809
+ return 3;
1686
1810
  case 59:
1687
- return 1;
1811
+ return 2;
1688
1812
  case 60:
1813
+ return 1;
1814
+ case 61:
1689
1815
  return 0;
1690
1816
  default:
1691
1817
  return -1;
@@ -1698,17 +1824,17 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1698
1824
  let continueLoop = true;
1699
1825
  while (continueLoop) {
1700
1826
  TokenStream__SkipNewlines(stream);
1701
- const mark_4 = TokenStream__Mark(stream) | 0;
1827
+ const mark_5 = TokenStream__Mark(stream) | 0;
1702
1828
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
1703
1829
  if (precedence(TokenStream__Peek(stream).Kind) >= minPrec) {
1704
1830
  }
1705
1831
  else {
1706
- TokenStream__Restore_Z524259A4(stream, mark_4);
1832
+ TokenStream__Restore_Z524259A4(stream, mark_5);
1707
1833
  continueLoop = false;
1708
1834
  }
1709
1835
  }
1710
1836
  else {
1711
- TokenStream__Restore_Z524259A4(stream, mark_4);
1837
+ TokenStream__Restore_Z524259A4(stream, mark_5);
1712
1838
  continueLoop = false;
1713
1839
  }
1714
1840
  }
@@ -1717,7 +1843,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1717
1843
  if (prec >= minPrec) {
1718
1844
  const opTok = TokenStream__Next(stream);
1719
1845
  const right_2 = parseBinary(prec + 1);
1720
- left_2 = (new Expr(/* EBinOp */ 25, [(op_1 = opTok.Kind, (op_1.tag === 49) ? "+" : ((op_1.tag === 50) ? "-" : ((op_1.tag === 51) ? "*" : ((op_1.tag === 52) ? "/" : ((op_1.tag === 53) ? "%" : ((op_1.tag === 25) ? "=" : ((op_1.tag === 54) ? "<" : ((op_1.tag === 55) ? ">" : ((op_1.tag === 56) ? "<=" : ((op_1.tag === 57) ? ">=" : ((op_1.tag === 58) ? "&&" : ((op_1.tag === 59) ? "||" : ((op_1.tag === 60) ? "|>" : ((op_1.tag === 61) ? "::" : ((op_1.tag === 62) ? "@" : "?"))))))))))))))), left_2, right_2, mkSpanFrom(Ast_spanOfExpr(left_2), Ast_spanOfExpr(right_2))]));
1846
+ left_2 = (new Expr(/* EBinOp */ 26, [(op_1 = opTok.Kind, (op_1.tag === 50) ? "+" : ((op_1.tag === 51) ? "-" : ((op_1.tag === 52) ? "*" : ((op_1.tag === 53) ? "/" : ((op_1.tag === 54) ? "%" : ((op_1.tag === 26) ? "=" : ((op_1.tag === 55) ? "<" : ((op_1.tag === 56) ? ">" : ((op_1.tag === 57) ? "<=" : ((op_1.tag === 58) ? ">=" : ((op_1.tag === 59) ? "&&" : ((op_1.tag === 60) ? "||" : ((op_1.tag === 61) ? "|>" : ((op_1.tag === 62) ? "::" : ((op_1.tag === 63) ? "@" : "?"))))))))))))))), left_2, right_2, mkSpanFrom(Ast_spanOfExpr(left_2), Ast_spanOfExpr(right_2))]));
1721
1847
  }
1722
1848
  else {
1723
1849
  looping = false;
@@ -1736,42 +1862,42 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1736
1862
  TokenStream__SkipNewlines(stream);
1737
1863
  }
1738
1864
  let elseExpr;
1739
- const matchValue_34 = TokenStream__Peek(stream).Kind;
1740
- switch (matchValue_34.tag) {
1741
- case 19: {
1865
+ const matchValue_36 = TokenStream__Peek(stream).Kind;
1866
+ switch (matchValue_36.tag) {
1867
+ case 20: {
1742
1868
  TokenStream__Next(stream);
1743
1869
  elseExpr = parseExprOrBlock();
1744
1870
  break;
1745
1871
  }
1746
- case 20: {
1872
+ case 21: {
1747
1873
  elseExpr = parseIfAfterKeyword(TokenStream__Next(stream).Span);
1748
1874
  break;
1749
1875
  }
1750
1876
  default:
1751
1877
  throw new ParseException(new ParseError("Expected \'else\' or \'elif\'", TokenStream__Peek(stream).Span));
1752
1878
  }
1753
- return new Expr(/* EIf */ 6, [cond, thenExpr, elseExpr, mkSpanFrom(startSpan, Ast_spanOfExpr(elseExpr))]);
1879
+ return new Expr(/* EIf */ 7, [cond, thenExpr, elseExpr, mkSpanFrom(startSpan, Ast_spanOfExpr(elseExpr))]);
1754
1880
  };
1755
1881
  const parseFor = () => {
1756
1882
  const forTok = TokenStream__Expect_77B9EE56(stream, TokenKind.For, "Expected \'for\'");
1757
- let name_14;
1758
- const matchValue_35 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'for\'").Kind;
1759
- name_14 = ((matchValue_35.tag === 4) ? matchValue_35.fields[0] : "");
1883
+ let name_20;
1884
+ const matchValue_37 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'for\'").Kind;
1885
+ name_20 = ((matchValue_37.tag === 4) ? matchValue_37.fields[0] : "");
1760
1886
  TokenStream__SkipNewlines(stream);
1761
- const matchValue_36 = TokenStream__Peek(stream).Kind;
1762
- let matchResult_5;
1763
- if (matchValue_36.tag === 4) {
1764
- if (matchValue_36.fields[0] === "in") {
1765
- matchResult_5 = 0;
1887
+ const matchValue_38 = TokenStream__Peek(stream).Kind;
1888
+ let matchResult_6;
1889
+ if (matchValue_38.tag === 4) {
1890
+ if (matchValue_38.fields[0] === "in") {
1891
+ matchResult_6 = 0;
1766
1892
  }
1767
1893
  else {
1768
- matchResult_5 = 1;
1894
+ matchResult_6 = 1;
1769
1895
  }
1770
1896
  }
1771
1897
  else {
1772
- matchResult_5 = 1;
1898
+ matchResult_6 = 1;
1773
1899
  }
1774
- switch (matchResult_5) {
1900
+ switch (matchResult_6) {
1775
1901
  case 0: {
1776
1902
  TokenStream__Next(stream);
1777
1903
  break;
@@ -1783,20 +1909,20 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1783
1909
  }
1784
1910
  const source_19 = parsePostfix();
1785
1911
  TokenStream__SkipNewlines(stream);
1786
- const matchValue_37 = TokenStream__Peek(stream).Kind;
1787
- let matchResult_6;
1788
- if (matchValue_37.tag === 4) {
1789
- if (matchValue_37.fields[0] === "do") {
1790
- matchResult_6 = 0;
1912
+ const matchValue_39 = TokenStream__Peek(stream).Kind;
1913
+ let matchResult_7;
1914
+ if (matchValue_39.tag === 4) {
1915
+ if (matchValue_39.fields[0] === "do") {
1916
+ matchResult_7 = 0;
1791
1917
  }
1792
1918
  else {
1793
- matchResult_6 = 1;
1919
+ matchResult_7 = 1;
1794
1920
  }
1795
1921
  }
1796
1922
  else {
1797
- matchResult_6 = 1;
1923
+ matchResult_7 = 1;
1798
1924
  }
1799
- switch (matchResult_6) {
1925
+ switch (matchResult_7) {
1800
1926
  case 0: {
1801
1927
  TokenStream__Next(stream);
1802
1928
  break;
@@ -1807,31 +1933,31 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1807
1933
  }
1808
1934
  }
1809
1935
  const body = parseExprOrBlock();
1810
- return new Expr(/* EFor */ 8, [name_14, source_19, body, mkSpanFrom(forTok.Span, Ast_spanOfExpr(body))]);
1936
+ return new Expr(/* EFor */ 9, [name_20, source_19, body, mkSpanFrom(forTok.Span, Ast_spanOfExpr(body))]);
1811
1937
  };
1812
1938
  const parseLambda = () => {
1813
1939
  const funTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Fun, "Expected \'fun\'");
1814
- const parameters = [];
1940
+ const parameters_2 = [];
1815
1941
  let doneParams = false;
1816
1942
  while (!doneParams) {
1817
1943
  TokenStream__SkipNewlines(stream);
1818
- const matchValue_38 = TokenStream__Peek(stream).Kind;
1819
- switch (matchValue_38.tag) {
1944
+ const matchValue_40 = TokenStream__Peek(stream).Kind;
1945
+ switch (matchValue_40.tag) {
1820
1946
  case 4:
1821
- case 27: {
1822
- void (parameters.push(parseParam()));
1947
+ case 28: {
1948
+ void (parameters_2.push(parseParam()));
1823
1949
  break;
1824
1950
  }
1825
1951
  default:
1826
1952
  doneParams = true;
1827
1953
  }
1828
1954
  }
1829
- if (parameters.length === 0) {
1955
+ if (parameters_2.length === 0) {
1830
1956
  throw new ParseException(new ParseError("Expected at least one lambda parameter", TokenStream__Peek(stream).Span));
1831
1957
  }
1832
1958
  TokenStream__SkipNewlines(stream);
1833
1959
  TokenStream__Expect_77B9EE56(stream, TokenKind.Arrow, "Expected \'->\' in lambda");
1834
- return foldBack_1((param_1, acc) => (new Expr(/* ELambda */ 4, [param_1, acc, mkSpanFrom(funTok.Span, Ast_spanOfExpr(acc))])), parameters, parseExprOrBlock());
1960
+ return foldBack_1((param_1, acc) => (new Expr(/* ELambda */ 5, [param_1, acc, mkSpanFrom(funTok.Span, Ast_spanOfExpr(acc))])), parameters_2, parseExprOrBlock());
1835
1961
  };
1836
1962
  const parseMatch = () => {
1837
1963
  const matchTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Match, "Expected \'match\'");
@@ -1856,8 +1982,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1856
1982
  }
1857
1983
  TokenStream__Expect_77B9EE56(stream, TokenKind.Arrow, "Expected \'->\' in match case");
1858
1984
  const body_2 = parseExprOrBlock();
1859
- const span_4 = mkSpanFrom(Ast_spanOfPattern(pat), Ast_spanOfExpr(body_2));
1860
- void (cases_2.push([pat, guard, body_2, span_4]));
1985
+ const span_6 = mkSpanFrom(Ast_spanOfPattern(pat), Ast_spanOfExpr(body_2));
1986
+ void (cases_2.push([pat, guard, body_2, span_6]));
1861
1987
  };
1862
1988
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
1863
1989
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
@@ -1882,30 +2008,30 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1882
2008
  let doneCases_1 = false;
1883
2009
  while (!doneCases_1) {
1884
2010
  TokenStream__SkipNewlines(stream);
1885
- const matchValue_39 = TokenStream__Peek(stream).Kind;
1886
- let matchResult_7;
1887
- switch (matchValue_39.tag) {
1888
- case 26: {
1889
- matchResult_7 = 0;
2011
+ const matchValue_41 = TokenStream__Peek(stream).Kind;
2012
+ let matchResult_8;
2013
+ switch (matchValue_41.tag) {
2014
+ case 27: {
2015
+ matchResult_8 = 0;
1890
2016
  break;
1891
2017
  }
1892
2018
  case 3: {
1893
2019
  if (hasIndentedCaseBlock) {
1894
- matchResult_7 = 1;
2020
+ matchResult_8 = 1;
1895
2021
  }
1896
2022
  else {
1897
- matchResult_7 = 3;
2023
+ matchResult_8 = 3;
1898
2024
  }
1899
2025
  break;
1900
2026
  }
1901
2027
  case 2: {
1902
- matchResult_7 = 2;
2028
+ matchResult_8 = 2;
1903
2029
  break;
1904
2030
  }
1905
2031
  default:
1906
- matchResult_7 = 3;
2032
+ matchResult_8 = 3;
1907
2033
  }
1908
- switch (matchResult_7) {
2034
+ switch (matchResult_8) {
1909
2035
  case 0: {
1910
2036
  ensureAlignedCaseStart();
1911
2037
  parseCase_1();
@@ -1937,9 +2063,9 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1937
2063
  let doneCases_2 = false;
1938
2064
  while (!doneCases_2) {
1939
2065
  TokenStream__SkipNewlines(stream);
1940
- const matchValue_40 = TokenStream__Peek(stream).Kind;
1941
- switch (matchValue_40.tag) {
1942
- case 26: {
2066
+ const matchValue_42 = TokenStream__Peek(stream).Kind;
2067
+ switch (matchValue_42.tag) {
2068
+ case 27: {
1943
2069
  parseCase_1();
1944
2070
  break;
1945
2071
  }
@@ -1953,28 +2079,29 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1953
2079
  }
1954
2080
  }
1955
2081
  }
1956
- return new Expr(/* EMatch */ 9, [expr_5, toList(cases_2), mkSpanFrom(matchTok.Span, Ast_spanOfExpr(expr_5))]);
2082
+ return new Expr(/* EMatch */ 10, [expr_5, toList(cases_2), mkSpanFrom(matchTok.Span, Ast_spanOfExpr(expr_5))]);
1957
2083
  };
1958
2084
  const parseLetExpr = () => {
1959
- let matchValue_43;
2085
+ let matchValue_45;
1960
2086
  const letTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Let, "Expected \'let\'");
1961
2087
  const isRec_1 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
1962
- let patternInput_2;
2088
+ let patternInput_3;
1963
2089
  if (isRec_1) {
1964
2090
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.LParen)) {
1965
2091
  throw new ParseException(new ParseError("\'let rec\' does not support pattern bindings", TokenStream__Peek(stream).Span));
1966
2092
  }
1967
2093
  const nameTok_13 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
1968
- let name_15;
1969
- const matchValue_41 = nameTok_13.Kind;
1970
- name_15 = ((matchValue_41.tag === 4) ? matchValue_41.fields[0] : "");
2094
+ let name_21;
2095
+ const matchValue_43 = nameTok_13.Kind;
2096
+ name_21 = ((matchValue_43.tag === 4) ? matchValue_43.fields[0] : "");
2097
+ const typeParameters_1 = parseTypeParameters();
1971
2098
  const args_1 = parseParamsAligned();
1972
2099
  if (args_1.length === 0) {
1973
2100
  throw new ParseException(new ParseError("\'let rec\' requires at least one function argument", nameTok_13.Span));
1974
2101
  }
1975
- patternInput_2 = [name_15, args_1, undefined, nameTok_13.Span];
2102
+ patternInput_3 = [name_21, typeParameters_1, args_1, undefined, nameTok_13.Span];
1976
2103
  }
1977
- else if (TokenStream__Peek(stream).Kind.tag === 27) {
2104
+ else if (TokenStream__Peek(stream).Kind.tag === 28) {
1978
2105
  let pattern_1;
1979
2106
  const pattern = parsePatternCons();
1980
2107
  if (pattern.tag === 5) {
@@ -1983,15 +2110,17 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
1983
2110
  else {
1984
2111
  throw new ParseException(new ParseError("Only tuple patterns are supported in let bindings", Ast_spanOfPattern(pattern)));
1985
2112
  }
1986
- patternInput_2 = ["", [], pattern_1, Ast_spanOfPattern(pattern_1)];
2113
+ patternInput_3 = ["", empty(), [], pattern_1, Ast_spanOfPattern(pattern_1)];
1987
2114
  }
1988
2115
  else {
1989
2116
  const nameTok_14 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
1990
- patternInput_2 = [(matchValue_43 = nameTok_14.Kind, (matchValue_43.tag === 4) ? matchValue_43.fields[0] : ""), parseParamsAligned(), undefined, nameTok_14.Span];
2117
+ patternInput_3 = [(matchValue_45 = nameTok_14.Kind, (matchValue_45.tag === 4) ? matchValue_45.fields[0] : ""), parseTypeParameters(), parseParamsAligned(), undefined, nameTok_14.Span];
1991
2118
  }
1992
- const tuplePatternOpt = patternInput_2[2];
1993
- const bindingName = patternInput_2[0];
1994
- const args_2 = patternInput_2[1];
2119
+ const typeParameters_3 = patternInput_3[1];
2120
+ const tuplePatternOpt = patternInput_3[3];
2121
+ const bindingSpan = patternInput_3[4];
2122
+ const bindingName = patternInput_3[0];
2123
+ const args_2 = patternInput_3[2];
1995
2124
  TokenStream__SkipNewlines(stream);
1996
2125
  let returnAnnotation;
1997
2126
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Colon)) {
@@ -2006,20 +2135,25 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2006
2135
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
2007
2136
  throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
2008
2137
  }
2138
+ if (!isEmpty(typeParameters_3) && (args_2.length === 0)) {
2139
+ throw new ParseException(new ParseError("Generic let bindings require a function argument", bindingSpan));
2140
+ }
2141
+ const returnAnnotation_1 = quantify(typeParameters_3, returnAnnotation);
2009
2142
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
2010
- const value_71 = parseExprOrBlock();
2143
+ const value_75 = parseExprOrBlock();
2011
2144
  if (isRec_1) {
2012
2145
  const bindings = [];
2013
- const firstSpan = mkSpanFrom(patternInput_2[3], Ast_spanOfExpr(value_71));
2014
- void (bindings.push([bindingName, toList(args_2), returnAnnotation, value_71, firstSpan]));
2146
+ const firstSpan = mkSpanFrom(bindingSpan, Ast_spanOfExpr(value_75));
2147
+ void (bindings.push([bindingName, toList(args_2), returnAnnotation_1, value_75, firstSpan]));
2015
2148
  let doneBindings = false;
2016
2149
  while (!doneBindings) {
2017
2150
  TokenStream__SkipNewlines(stream);
2018
2151
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
2019
2152
  const nextNameTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
2020
2153
  let nextName;
2021
- const matchValue_44 = nextNameTok.Kind;
2022
- nextName = ((matchValue_44.tag === 4) ? matchValue_44.fields[0] : "");
2154
+ const matchValue_46 = nextNameTok.Kind;
2155
+ nextName = ((matchValue_46.tag === 4) ? matchValue_46.fields[0] : "");
2156
+ const nextTypeParameters = parseTypeParameters();
2023
2157
  const nextArgs = parseParamsAligned();
2024
2158
  if (nextArgs.length === 0) {
2025
2159
  throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok.Span));
@@ -2032,26 +2166,26 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2032
2166
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
2033
2167
  const nextValue = parseExprOrBlock();
2034
2168
  const nextSpan = mkSpanFrom(nextNameTok.Span, Ast_spanOfExpr(nextValue));
2035
- void (bindings.push([nextName, toList(nextArgs), nextReturnAnnotation, nextValue, nextSpan]));
2169
+ void (bindings.push([nextName, toList(nextArgs), quantify(nextTypeParameters, nextReturnAnnotation), nextValue, nextSpan]));
2036
2170
  }
2037
2171
  else {
2038
2172
  doneBindings = true;
2039
2173
  }
2040
2174
  }
2041
- const matchValue_45 = TokenStream__Peek(stream).Kind;
2042
- let matchResult_8;
2043
- if (matchValue_45.tag === 4) {
2044
- if (matchValue_45.fields[0] === "in") {
2045
- matchResult_8 = 0;
2175
+ const matchValue_47 = TokenStream__Peek(stream).Kind;
2176
+ let matchResult_9;
2177
+ if (matchValue_47.tag === 4) {
2178
+ if (matchValue_47.fields[0] === "in") {
2179
+ matchResult_9 = 0;
2046
2180
  }
2047
2181
  else {
2048
- matchResult_8 = 1;
2182
+ matchResult_9 = 1;
2049
2183
  }
2050
2184
  }
2051
2185
  else {
2052
- matchResult_8 = 1;
2186
+ matchResult_9 = 1;
2053
2187
  }
2054
- switch (matchResult_8) {
2188
+ switch (matchResult_9) {
2055
2189
  case 0:
2056
2190
  throw new ParseException(new ParseError("\'in\' keyword is not supported", TokenStream__Peek(stream).Span));
2057
2191
  default: {
@@ -2064,29 +2198,29 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2064
2198
  body_3 = parseExprOrBlock();
2065
2199
  }
2066
2200
  if (bindings.length === 1) {
2067
- return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(/* ELambda */ 4, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2, value_71), body_3, true, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
2201
+ return new Expr(/* ELet */ 11, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(/* ELambda */ 5, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2, value_75), body_3, true, returnAnnotation_1, args_2.length, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
2068
2202
  }
2069
2203
  else {
2070
- return new Expr(/* ELetRecGroup */ 12, [toList(bindings), body_3, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
2204
+ return new Expr(/* ELetRecGroup */ 13, [toList(bindings), body_3, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
2071
2205
  }
2072
2206
  }
2073
2207
  }
2074
2208
  }
2075
2209
  else {
2076
- const matchValue_47 = TokenStream__Peek(stream).Kind;
2077
- let matchResult_9;
2078
- if (matchValue_47.tag === 4) {
2079
- if (matchValue_47.fields[0] === "in") {
2080
- matchResult_9 = 0;
2210
+ const matchValue_49 = TokenStream__Peek(stream).Kind;
2211
+ let matchResult_10;
2212
+ if (matchValue_49.tag === 4) {
2213
+ if (matchValue_49.fields[0] === "in") {
2214
+ matchResult_10 = 0;
2081
2215
  }
2082
2216
  else {
2083
- matchResult_9 = 1;
2217
+ matchResult_10 = 1;
2084
2218
  }
2085
2219
  }
2086
2220
  else {
2087
- matchResult_9 = 1;
2221
+ matchResult_10 = 1;
2088
2222
  }
2089
- switch (matchResult_9) {
2223
+ switch (matchResult_10) {
2090
2224
  case 0:
2091
2225
  throw new ParseException(new ParseError("\'in\' keyword is not supported", TokenStream__Peek(stream).Span));
2092
2226
  default: {
@@ -2099,7 +2233,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2099
2233
  body_4 = parseExprOrBlock();
2100
2234
  }
2101
2235
  if (tuplePatternOpt == null) {
2102
- return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(/* ELambda */ 4, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2, value_71), body_4, false, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
2236
+ return new Expr(/* ELet */ 11, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(/* ELambda */ 5, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2, value_75), body_4, false, returnAnnotation_1, args_2.length, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
2103
2237
  }
2104
2238
  else if (args_2.length > 0) {
2105
2239
  const pattern_3 = tuplePatternOpt;
@@ -2107,7 +2241,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2107
2241
  }
2108
2242
  else {
2109
2243
  const pattern_4 = tuplePatternOpt;
2110
- return new Expr(/* ELetPattern */ 11, [pattern_4, value_71, body_4, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
2244
+ return new Expr(/* ELetPattern */ 12, [pattern_4, value_75, body_4, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
2111
2245
  }
2112
2246
  }
2113
2247
  }
@@ -2131,59 +2265,59 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2131
2265
  let doneBlock = false;
2132
2266
  let blockStatementColumn = undefined;
2133
2267
  while (!doneBlock) {
2134
- let col, matchValue_51;
2268
+ let col, matchValue_53;
2135
2269
  TokenStream__SkipNewlines(stream);
2136
- const matchValue_49 = TokenStream__Peek(stream).Kind;
2137
- let matchResult_10;
2138
- switch (matchValue_49.tag) {
2270
+ const matchValue_51 = TokenStream__Peek(stream).Kind;
2271
+ let matchResult_11;
2272
+ switch (matchValue_51.tag) {
2139
2273
  case 3: {
2140
- matchResult_10 = 0;
2274
+ matchResult_11 = 0;
2141
2275
  break;
2142
2276
  }
2143
- case 28:
2144
- case 30:
2145
- case 44: {
2146
- matchResult_10 = 1;
2277
+ case 29:
2278
+ case 31:
2279
+ case 45: {
2280
+ matchResult_11 = 1;
2147
2281
  break;
2148
2282
  }
2149
2283
  case 0: {
2150
- matchResult_10 = 2;
2284
+ matchResult_11 = 2;
2151
2285
  break;
2152
2286
  }
2153
- case 10: {
2154
- matchResult_10 = 3;
2287
+ case 11: {
2288
+ matchResult_11 = 3;
2155
2289
  break;
2156
2290
  }
2157
- case 39: {
2158
- matchResult_10 = 4;
2291
+ case 40: {
2292
+ matchResult_11 = 4;
2159
2293
  break;
2160
2294
  }
2161
- case 42: {
2162
- matchResult_10 = 6;
2295
+ case 43: {
2296
+ matchResult_11 = 6;
2163
2297
  break;
2164
2298
  }
2165
- case 38: {
2299
+ case 39: {
2166
2300
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Import) ? true : equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Include)) {
2167
- matchResult_10 = 5;
2301
+ matchResult_11 = 5;
2168
2302
  }
2169
2303
  else {
2170
- matchResult_10 = 8;
2304
+ matchResult_11 = 8;
2171
2305
  }
2172
2306
  break;
2173
2307
  }
2174
- case 29: {
2308
+ case 30: {
2175
2309
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
2176
- matchResult_10 = 7;
2310
+ matchResult_11 = 7;
2177
2311
  }
2178
2312
  else {
2179
- matchResult_10 = 8;
2313
+ matchResult_11 = 8;
2180
2314
  }
2181
2315
  break;
2182
2316
  }
2183
2317
  default:
2184
- matchResult_10 = 8;
2318
+ matchResult_11 = 8;
2185
2319
  }
2186
- switch (matchResult_10) {
2320
+ switch (matchResult_11) {
2187
2321
  case 0: {
2188
2322
  TokenStream__Next(stream);
2189
2323
  TokenStream__SkipNewlines(stream);
@@ -2191,8 +2325,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2191
2325
  findNextNonLayout:
2192
2326
  while (true) {
2193
2327
  const offset_1 = offset_1_mut;
2194
- const matchValue_50 = TokenStream__PeekAt_Z524259A4(stream, offset_1).Kind;
2195
- switch (matchValue_50.tag) {
2328
+ const matchValue_52 = TokenStream__PeekAt_Z524259A4(stream, offset_1).Kind;
2329
+ switch (matchValue_52.tag) {
2196
2330
  case 1:
2197
2331
  case 2:
2198
2332
  case 3: {
@@ -2207,7 +2341,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2207
2341
  };
2208
2342
  const nextSignificant = findNextNonLayout(0);
2209
2343
  TokenStream__Peek(stream);
2210
- if (!((blockStatementColumn == null) ? false : ((col = (blockStatementColumn | 0), (matchValue_51 = nextSignificant.Kind, (matchValue_51.tag === 0) ? false : ((matchValue_51.tag === 3) ? false : ((matchValue_51.tag === 28) ? false : ((matchValue_51.tag === 30) ? false : ((matchValue_51.tag === 44) ? false : (nextSignificant.Span.Start.Column >= col)))))))))) {
2344
+ if (!((blockStatementColumn == null) ? false : ((col = (blockStatementColumn | 0), (matchValue_53 = nextSignificant.Kind, (matchValue_53.tag === 0) ? false : ((matchValue_53.tag === 3) ? false : ((matchValue_53.tag === 29) ? false : ((matchValue_53.tag === 31) ? false : ((matchValue_53.tag === 45) ? false : (nextSignificant.Span.Start.Column >= col)))))))))) {
2211
2345
  doneBlock = true;
2212
2346
  }
2213
2347
  break;
@@ -2264,9 +2398,9 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2264
2398
  throw new ParseException(new ParseError("Block cannot end with a let binding; add a final expression", head_1(stmts).fields[6]));
2265
2399
  }
2266
2400
  else {
2267
- const valExpr = foldBack_1((arg_5, acc_3) => (new Expr(/* ELambda */ 4, [arg_5, acc_3, head_1(stmts).fields[6]])), head_1(stmts).fields[1], head_1(stmts).fields[3]);
2401
+ const valExpr = foldBack_1((arg_5, acc_3) => (new Expr(/* ELambda */ 5, [arg_5, acc_3, head_1(stmts).fields[6]])), head_1(stmts).fields[1], head_1(stmts).fields[3]);
2268
2402
  const body_5 = desugar(tail_1(stmts));
2269
- return new Expr(/* ELet */ 10, [head_1(stmts).fields[0], valExpr, body_5, head_1(stmts).fields[4], head_1(stmts).fields[2], mkSpanFrom(head_1(stmts).fields[6], Ast_spanOfExpr(body_5))]);
2403
+ return new Expr(/* ELet */ 11, [head_1(stmts).fields[0], valExpr, body_5, head_1(stmts).fields[4], head_1(stmts).fields[2], length(head_1(stmts).fields[1]), mkSpanFrom(head_1(stmts).fields[6], Ast_spanOfExpr(body_5))]);
2270
2404
  }
2271
2405
  case 3:
2272
2406
  if (isEmpty(tail_1(stmts))) {
@@ -2274,7 +2408,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2274
2408
  }
2275
2409
  else {
2276
2410
  const body_6 = desugar(tail_1(stmts));
2277
- return new Expr(/* ELetPattern */ 11, [head_1(stmts).fields[0], head_1(stmts).fields[1], body_6, mkSpanFrom(head_1(stmts).fields[3], Ast_spanOfExpr(body_6))]);
2411
+ return new Expr(/* ELetPattern */ 12, [head_1(stmts).fields[0], head_1(stmts).fields[1], body_6, mkSpanFrom(head_1(stmts).fields[3], Ast_spanOfExpr(body_6))]);
2278
2412
  }
2279
2413
  case 4:
2280
2414
  if (isEmpty(tail_1(stmts))) {
@@ -2282,7 +2416,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2282
2416
  }
2283
2417
  else {
2284
2418
  const body_7 = desugar(tail_1(stmts));
2285
- return new Expr(/* ELetRecGroup */ 12, [head_1(stmts).fields[0], body_7, mkSpanFrom(head_1(stmts).fields[2], Ast_spanOfExpr(body_7))]);
2419
+ return new Expr(/* ELetRecGroup */ 13, [head_1(stmts).fields[0], body_7, mkSpanFrom(head_1(stmts).fields[2], Ast_spanOfExpr(body_7))]);
2286
2420
  }
2287
2421
  case 5:
2288
2422
  throw new ParseException(new ParseError("Backend imports are only supported at top level", head_1(stmts).fields[3]));
@@ -2298,7 +2432,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2298
2432
  }
2299
2433
  else {
2300
2434
  const body_8 = desugar(tail_1(stmts));
2301
- return new Expr(/* ELet */ 10, ["_", head_1(stmts).fields[0], body_8, false, undefined, mkSpanFrom(Ast_spanOfExpr(head_1(stmts).fields[0]), Ast_spanOfExpr(body_8))]);
2435
+ return new Expr(/* ELet */ 11, ["_", head_1(stmts).fields[0], body_8, false, undefined, 0, mkSpanFrom(Ast_spanOfExpr(head_1(stmts).fields[0]), Ast_spanOfExpr(body_8))]);
2302
2436
  }
2303
2437
  }
2304
2438
  }
@@ -2309,25 +2443,26 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2309
2443
  return desugar(toList(statements));
2310
2444
  };
2311
2445
  const parseLetStmt = (isExported) => {
2312
- let matchValue_54;
2446
+ let matchValue_56;
2313
2447
  const letTok_1 = TokenStream__Next(stream);
2314
2448
  const isRec_3 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
2315
- let patternInput_3;
2449
+ let patternInput_4;
2316
2450
  if (isRec_3) {
2317
2451
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.LParen)) {
2318
2452
  throw new ParseException(new ParseError("\'let rec\' does not support pattern bindings", TokenStream__Peek(stream).Span));
2319
2453
  }
2320
2454
  const nameTok_15 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
2321
- let name_18;
2322
- const matchValue_52 = nameTok_15.Kind;
2323
- name_18 = ((matchValue_52.tag === 4) ? matchValue_52.fields[0] : "");
2455
+ let name_24;
2456
+ const matchValue_54 = nameTok_15.Kind;
2457
+ name_24 = ((matchValue_54.tag === 4) ? matchValue_54.fields[0] : "");
2458
+ const typeParameters_4 = parseTypeParameters();
2324
2459
  const args_4 = parseParamsAligned();
2325
2460
  if (args_4.length === 0) {
2326
2461
  throw new ParseException(new ParseError("\'let rec\' requires at least one function argument", nameTok_15.Span));
2327
2462
  }
2328
- patternInput_3 = [name_18, args_4, undefined, nameTok_15.Span];
2463
+ patternInput_4 = [name_24, typeParameters_4, args_4, undefined, nameTok_15.Span];
2329
2464
  }
2330
- else if (TokenStream__Peek(stream).Kind.tag === 27) {
2465
+ else if (TokenStream__Peek(stream).Kind.tag === 28) {
2331
2466
  if (isExported) {
2332
2467
  throw new ParseException(new ParseError("Exported let binding requires a single identifier, not a tuple pattern", TokenStream__Peek(stream).Span));
2333
2468
  }
@@ -2339,43 +2474,50 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2339
2474
  else {
2340
2475
  throw new ParseException(new ParseError("Only tuple patterns are supported in let bindings", Ast_spanOfPattern(pattern_6)));
2341
2476
  }
2342
- patternInput_3 = ["", [], pattern_7, Ast_spanOfPattern(pattern_7)];
2477
+ patternInput_4 = ["", empty(), [], pattern_7, Ast_spanOfPattern(pattern_7)];
2343
2478
  }
2344
2479
  else {
2345
2480
  const nameTok_16 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
2346
- patternInput_3 = [(matchValue_54 = nameTok_16.Kind, (matchValue_54.tag === 4) ? matchValue_54.fields[0] : ""), parseParamsAligned(), undefined, nameTok_16.Span];
2481
+ patternInput_4 = [(matchValue_56 = nameTok_16.Kind, (matchValue_56.tag === 4) ? matchValue_56.fields[0] : ""), parseTypeParameters(), parseParamsAligned(), undefined, nameTok_16.Span];
2347
2482
  }
2348
- const tuplePatternOpt_1 = patternInput_3[2];
2349
- const bindingName_1 = patternInput_3[0];
2350
- const args_5 = patternInput_3[1];
2483
+ const typeParameters_6 = patternInput_4[1];
2484
+ const tuplePatternOpt_1 = patternInput_4[3];
2485
+ const bindingSpan_1 = patternInput_4[4];
2486
+ const bindingName_1 = patternInput_4[0];
2487
+ const args_5 = patternInput_4[2];
2351
2488
  TokenStream__SkipNewlines(stream);
2352
- let returnAnnotation_2;
2489
+ let returnAnnotation_3;
2353
2490
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Colon)) {
2354
2491
  if (args_5.length === 0) {
2355
2492
  throw new ParseException(new ParseError("Return type annotations are only supported on function let bindings", TokenStream__Peek(stream).Span));
2356
2493
  }
2357
- returnAnnotation_2 = parseTypeRef();
2494
+ returnAnnotation_3 = parseTypeRef();
2358
2495
  }
2359
2496
  else {
2360
- returnAnnotation_2 = undefined;
2497
+ returnAnnotation_3 = undefined;
2361
2498
  }
2362
2499
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
2363
2500
  throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
2364
2501
  }
2502
+ if (!isEmpty(typeParameters_6) && (args_5.length === 0)) {
2503
+ throw new ParseException(new ParseError("Generic let bindings require a function argument", bindingSpan_1));
2504
+ }
2505
+ const returnAnnotation_4 = quantify(typeParameters_6, returnAnnotation_3);
2365
2506
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
2366
- const value_79 = parseExprOrBlock();
2507
+ const value_83 = parseExprOrBlock();
2367
2508
  if (isRec_3) {
2368
2509
  const bindings_2 = [];
2369
- const firstSpan_1 = mkSpanFrom(patternInput_3[3], Ast_spanOfExpr(value_79));
2370
- void (bindings_2.push([bindingName_1, toList(args_5), returnAnnotation_2, value_79, firstSpan_1]));
2510
+ const firstSpan_1 = mkSpanFrom(bindingSpan_1, Ast_spanOfExpr(value_83));
2511
+ void (bindings_2.push([bindingName_1, toList(args_5), returnAnnotation_4, value_83, firstSpan_1]));
2371
2512
  let doneBindings_1 = false;
2372
2513
  while (!doneBindings_1) {
2373
2514
  TokenStream__SkipNewlines(stream);
2374
2515
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
2375
2516
  const nextNameTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
2376
2517
  let nextName_1;
2377
- const matchValue_55 = nextNameTok_1.Kind;
2378
- nextName_1 = ((matchValue_55.tag === 4) ? matchValue_55.fields[0] : "");
2518
+ const matchValue_57 = nextNameTok_1.Kind;
2519
+ nextName_1 = ((matchValue_57.tag === 4) ? matchValue_57.fields[0] : "");
2520
+ const nextTypeParameters_1 = parseTypeParameters();
2379
2521
  const nextArgs_1 = parseParamsAligned();
2380
2522
  if (nextArgs_1.length === 0) {
2381
2523
  throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok_1.Span));
@@ -2388,22 +2530,22 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2388
2530
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
2389
2531
  const nextValue_1 = parseExprOrBlock();
2390
2532
  const nextSpan_1 = mkSpanFrom(nextNameTok_1.Span, Ast_spanOfExpr(nextValue_1));
2391
- void (bindings_2.push([nextName_1, toList(nextArgs_1), nextReturnAnnotation_1, nextValue_1, nextSpan_1]));
2533
+ void (bindings_2.push([nextName_1, toList(nextArgs_1), quantify(nextTypeParameters_1, nextReturnAnnotation_1), nextValue_1, nextSpan_1]));
2392
2534
  }
2393
2535
  else {
2394
2536
  doneBindings_1 = true;
2395
2537
  }
2396
2538
  }
2397
2539
  if (bindings_2.length === 1) {
2398
- return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_79, true, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
2540
+ return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_4, value_83, true, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_83))]);
2399
2541
  }
2400
2542
  else {
2401
- const patternInput_4 = item(bindings_2.length - 1, bindings_2);
2402
- return new Stmt(/* SLetRecGroup */ 4, [toList(bindings_2), isExported, mkSpanFrom(letTok_1.Span, patternInput_4[4])]);
2543
+ const patternInput_5 = item(bindings_2.length - 1, bindings_2);
2544
+ return new Stmt(/* SLetRecGroup */ 4, [toList(bindings_2), isExported, mkSpanFrom(letTok_1.Span, patternInput_5[4])]);
2403
2545
  }
2404
2546
  }
2405
2547
  else if (tuplePatternOpt_1 == null) {
2406
- return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_79, false, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
2548
+ return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_4, value_83, false, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_83))]);
2407
2549
  }
2408
2550
  else if (args_5.length > 0) {
2409
2551
  const pattern_9 = tuplePatternOpt_1;
@@ -2411,40 +2553,40 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2411
2553
  }
2412
2554
  else {
2413
2555
  const pattern_10 = tuplePatternOpt_1;
2414
- return new Stmt(/* SLetPattern */ 3, [pattern_10, value_79, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
2556
+ return new Stmt(/* SLetPattern */ 3, [pattern_10, value_83, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_83))]);
2415
2557
  }
2416
2558
  };
2417
2559
  const parseAttribute = () => {
2418
2560
  TokenStream__Expect_77B9EE56(stream, TokenKind.LBracket, "Expected \'[\' in attribute");
2419
2561
  TokenStream__Expect_77B9EE56(stream, TokenKind.Less, "Expected \'<\' in attribute");
2420
2562
  const nameTok_17 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected attribute name");
2421
- let name_20;
2422
- const matchValue_56 = nameTok_17.Kind;
2423
- name_20 = ((matchValue_56.tag === 4) ? matchValue_56.fields[0] : "");
2424
- const arguments$ = [];
2563
+ let name_26;
2564
+ const matchValue_58 = nameTok_17.Kind;
2565
+ name_26 = ((matchValue_58.tag === 4) ? matchValue_58.fields[0] : "");
2566
+ const arguments$_3 = [];
2425
2567
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.LParen)) {
2426
2568
  let doneArguments = false;
2427
2569
  while (!doneArguments) {
2428
2570
  const argument = TokenStream__Next(stream);
2429
- const matchValue_57 = argument.Kind;
2430
- let matchResult_11, value_83;
2431
- switch (matchValue_57.tag) {
2432
- case 7: {
2433
- matchResult_11 = 0;
2434
- value_83 = matchValue_57.fields[0];
2571
+ const matchValue_59 = argument.Kind;
2572
+ let matchResult_12, value_87;
2573
+ switch (matchValue_59.tag) {
2574
+ case 8: {
2575
+ matchResult_12 = 0;
2576
+ value_87 = matchValue_59.fields[0];
2435
2577
  break;
2436
2578
  }
2437
2579
  case 4: {
2438
- matchResult_11 = 0;
2439
- value_83 = matchValue_57.fields[0];
2580
+ matchResult_12 = 0;
2581
+ value_87 = matchValue_59.fields[0];
2440
2582
  break;
2441
2583
  }
2442
2584
  default:
2443
- matchResult_11 = 1;
2585
+ matchResult_12 = 1;
2444
2586
  }
2445
- switch (matchResult_11) {
2587
+ switch (matchResult_12) {
2446
2588
  case 0: {
2447
- void (arguments$.push(value_83));
2589
+ void (arguments$_3.push(value_87));
2448
2590
  break;
2449
2591
  }
2450
2592
  case 1: {
@@ -2462,47 +2604,47 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2462
2604
  }
2463
2605
  TokenStream__Expect_77B9EE56(stream, TokenKind.Greater, "Expected \'>\' in attribute");
2464
2606
  TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in attribute");
2465
- return new Attribute(name_20, toList(arguments$), nameTok_17.Span);
2607
+ return new Attribute(name_26, toList(arguments$_3), nameTok_17.Span);
2466
2608
  };
2467
2609
  const parseBackendImport = (attribute_1) => {
2468
2610
  const letToken = TokenStream__Expect_77B9EE56(stream, TokenKind.Let, "Expected \'let\' after Import attribute");
2469
- const nameToken = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected imported binding name");
2470
- let name_21;
2471
- const matchValue_58 = nameToken.Kind;
2472
- name_21 = ((matchValue_58.tag === 4) ? matchValue_58.fields[0] : "");
2611
+ const nameToken_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected imported binding name");
2612
+ let name_27;
2613
+ const matchValue_60 = nameToken_1.Kind;
2614
+ name_27 = ((matchValue_60.tag === 4) ? matchValue_60.fields[0] : "");
2473
2615
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Imported binding requires a complete type signature");
2474
2616
  const signature = parseTypeRef();
2475
2617
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.Equals)) {
2476
2618
  throw new ParseException(new ParseError("Imported bindings must not have a body", TokenStream__Peek(stream).Span));
2477
2619
  }
2478
- const matchValue_59 = attribute_1.Arguments;
2479
- let matchResult_12, memberName_3, modulePath_3;
2480
- if (!isEmpty(matchValue_59)) {
2481
- if (!isEmpty(tail_1(matchValue_59))) {
2482
- if (isEmpty(tail_1(tail_1(matchValue_59)))) {
2483
- if (!isNullOrWhiteSpace(head_1(matchValue_59)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_59)))) {
2484
- matchResult_12 = 0;
2485
- memberName_3 = head_1(tail_1(matchValue_59));
2486
- modulePath_3 = head_1(matchValue_59);
2620
+ const matchValue_61 = attribute_1.Arguments;
2621
+ let matchResult_13, memberName_3, modulePath_3;
2622
+ if (!isEmpty(matchValue_61)) {
2623
+ if (!isEmpty(tail_1(matchValue_61))) {
2624
+ if (isEmpty(tail_1(tail_1(matchValue_61)))) {
2625
+ if (!isNullOrWhiteSpace(head_1(matchValue_61)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_61)))) {
2626
+ matchResult_13 = 0;
2627
+ memberName_3 = head_1(tail_1(matchValue_61));
2628
+ modulePath_3 = head_1(matchValue_61);
2487
2629
  }
2488
2630
  else {
2489
- matchResult_12 = 1;
2631
+ matchResult_13 = 1;
2490
2632
  }
2491
2633
  }
2492
2634
  else {
2493
- matchResult_12 = 1;
2635
+ matchResult_13 = 1;
2494
2636
  }
2495
2637
  }
2496
2638
  else {
2497
- matchResult_12 = 1;
2639
+ matchResult_13 = 1;
2498
2640
  }
2499
2641
  }
2500
2642
  else {
2501
- matchResult_12 = 1;
2643
+ matchResult_13 = 1;
2502
2644
  }
2503
- switch (matchResult_12) {
2645
+ switch (matchResult_13) {
2504
2646
  case 0:
2505
- return new Stmt(/* SBackendImport */ 5, [name_21, signature, new BackendImport(modulePath_3, memberName_3, attribute_1.Span), mkSpanFrom(letToken.Span, nameToken.Span)]);
2647
+ return new Stmt(/* SBackendImport */ 5, [name_27, signature, new BackendImport(modulePath_3, memberName_3, attribute_1.Span), mkSpanFrom(letToken.Span, nameToken_1.Span)]);
2506
2648
  default:
2507
2649
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute_1.Span));
2508
2650
  }
@@ -2518,7 +2660,7 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2518
2660
  }
2519
2661
  };
2520
2662
  const parseAttributedStmt = () => {
2521
- let matchValue_64;
2663
+ let matchValue_66;
2522
2664
  let hasAttributes = false;
2523
2665
  let backendImport_1 = undefined;
2524
2666
  const structuredAttributes = [];
@@ -2527,8 +2669,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2527
2669
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) && equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
2528
2670
  hasAttributes = true;
2529
2671
  const attribute_2 = parseAttribute();
2530
- const matchValue_60 = attribute_2.Name;
2531
- switch (matchValue_60) {
2672
+ const matchValue_62 = attribute_2.Name;
2673
+ switch (matchValue_62) {
2532
2674
  case "export":
2533
2675
  case "Export": {
2534
2676
  throw new ParseException(new ParseError("Unexpected attribute", attribute_2.Span));
@@ -2551,20 +2693,20 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2551
2693
  }
2552
2694
  }
2553
2695
  let statement;
2554
- const matchValue_61 = TokenStream__Peek(stream).Kind;
2555
- switch (matchValue_61.tag) {
2556
- case 38: {
2696
+ const matchValue_63 = TokenStream__Peek(stream).Kind;
2697
+ switch (matchValue_63.tag) {
2698
+ case 39: {
2557
2699
  if (hasAttributes) {
2558
2700
  throw new ParseException(new ParseError("Attributes are not supported on \'import\' directives", TokenStream__Peek(stream).Span));
2559
2701
  }
2560
2702
  const hashTok = TokenStream__Next(stream);
2561
- const matchValue_62 = TokenStream__Next(stream).Kind;
2562
- switch (matchValue_62.tag) {
2563
- case 41: {
2703
+ const matchValue_64 = TokenStream__Next(stream).Kind;
2704
+ switch (matchValue_64.tag) {
2705
+ case 42: {
2564
2706
  throw new ParseException(new ParseError("\'#include\' was removed in 0.32.0; use \'import \"file.fss\" as Alias\'", hashTok.Span));
2565
2707
  break;
2566
2708
  }
2567
- case 39: {
2709
+ case 40: {
2568
2710
  throw new ParseException(new ParseError("\'#import\' was removed in 0.32.0; use \'import \"file.fss\" as Alias\'", hashTok.Span));
2569
2711
  break;
2570
2712
  }
@@ -2573,18 +2715,18 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2573
2715
  }
2574
2716
  break;
2575
2717
  }
2576
- case 39: {
2718
+ case 40: {
2577
2719
  if (hasAttributes) {
2578
2720
  throw new ParseException(new ParseError("Attributes are not supported on \'import\' directives", TokenStream__Peek(stream).Span));
2579
2721
  }
2580
2722
  const importTok = TokenStream__Next(stream);
2581
2723
  const pathTok = TokenStream__Next(stream);
2582
- const matchValue_63 = pathTok.Kind;
2583
- if (matchValue_63.tag === 7) {
2584
- if (!isNullOrWhiteSpace(matchValue_63.fields[0])) {
2724
+ const matchValue_65 = pathTok.Kind;
2725
+ if (matchValue_65.tag === 8) {
2726
+ if (!isNullOrWhiteSpace(matchValue_65.fields[0])) {
2585
2727
  TokenStream__Expect_77B9EE56(stream, TokenKind.As, "Expected \'as\' in import directive. Use: import \"file.fss\" as Alias");
2586
2728
  const aliasTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected module alias after \'as\'");
2587
- statement = (new Stmt(/* SImport */ 1, [(matchValue_64 = aliasTok.Kind, (matchValue_64.tag === 4) ? matchValue_64.fields[0] : ""), matchValue_63.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]));
2729
+ statement = (new Stmt(/* SImport */ 1, [(matchValue_66 = aliasTok.Kind, (matchValue_66.tag === 4) ? matchValue_66.fields[0] : ""), matchValue_65.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]));
2588
2730
  }
2589
2731
  else {
2590
2732
  throw new ParseException(new ParseError("Import path cannot be empty", pathTok.Span));
@@ -2595,15 +2737,15 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2595
2737
  }
2596
2738
  break;
2597
2739
  }
2598
- case 42: {
2740
+ case 43: {
2599
2741
  throw new ParseException(new ParseError("\'module\' declarations are not supported in scripts", TokenStream__Peek(stream).Span));
2600
2742
  break;
2601
2743
  }
2602
- case 45: {
2744
+ case 46: {
2603
2745
  statement = parseTypeDecl(backendImport_1);
2604
2746
  break;
2605
2747
  }
2606
- case 10: {
2748
+ case 11: {
2607
2749
  statement = ((backendImport_1 == null) ? parseLetStmt(false) : parseBackendImport(backendImport_1));
2608
2750
  break;
2609
2751
  }
@@ -2625,8 +2767,8 @@ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, sta
2625
2767
  const program = [];
2626
2768
  TokenStream__SkipNewlines(stream);
2627
2769
  while (!TokenStream__get_AtEnd(stream)) {
2628
- const matchValue_65 = TokenStream__Peek(stream).Kind;
2629
- switch (matchValue_65.tag) {
2770
+ const matchValue_67 = TokenStream__Peek(stream).Kind;
2771
+ switch (matchValue_67.tag) {
2630
2772
  case 0: {
2631
2773
  TokenStream__Next(stream);
2632
2774
  break;
@@ -2659,7 +2801,7 @@ export function parseProgramWithRecordFieldLabels(sourceName, src) {
2659
2801
  });
2660
2802
  return [parseProgramWithSourceNameAndOrigin((span, fields) => {
2661
2803
  labels.set(span, fields);
2662
- }, sourceName, 1, 1, src), ofSeq_1(map_1((pair) => [pair[0], pair[1]], labels), {
2804
+ }, sourceName, 1, 1, src), ofSeq_2(map_1((pair) => [pair[0], pair[1]], labels), {
2663
2805
  Compare: (x_1, y_1) => (compare(x_1, y_1) | 0),
2664
2806
  })];
2665
2807
  }