@magnusopera/fscript 0.79.0 → 0.80.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.
@@ -11,8 +11,8 @@ import { ofArray, collect, tryFindIndex, choose, tryFind as tryFind_1, tryPick a
11
11
  import { map as map_1, containsKey, FSharpMap__Add, fold, empty as empty_1, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, add, FSharpMap__TryFind, tryFind, toSeq, ofList, FSharpMap__get_Item, forAll, FSharpMap__get_Keys, FSharpMap__get_Count, toList } from "../fable_modules/fable-library-js.5.13.0/Map.js";
12
12
  import { op_Modulus, op_Division, op_Multiply, op_Subtraction, op_Addition, toInt64_unchecked, compare as compare_1, equals } from "../fable_modules/fable-library-js.5.13.0/BigInt.js";
13
13
  import { contains, ofSeq } from "../fable_modules/fable-library-js.5.13.0/Set.js";
14
- import { filter, length as length_1, foldBack, head as head_3, tryPick } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
15
14
  import { Ast_spanOfExpr, Expr, Ast_spanOfPattern, TypeRef } from "./Ast.js";
15
+ import { filter, length as length_1, foldBack, head as head_3, tryPick } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
16
16
  import { some } from "../fable_modules/fable-library-js.5.13.0/Option.js";
17
17
  import { StringBuilder__Append_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.13.0/System.Text.js";
18
18
  import { builtinReservedNames } from "./BuiltinSignatures.js";
@@ -117,7 +117,7 @@ function valueToInterpolationString(v) {
117
117
  const arg_7 = join("; ", map((tupledArg_1) => {
118
118
  let arg_5;
119
119
  const key = tupledArg_1[0];
120
- arg_5 = ((key.tag === 1) ? int64ToString(key.fields[0]) : concat("\"", key.fields[0], "\""));
120
+ arg_5 = ((key.tag === 1) ? int64ToString(key.fields[0]) : ((key.tag === 2) ? (key.fields[0] ? "true" : "false") : ((key.tag === 3) ? concat(key.fields[0], ".", key.fields[1]) : concat("\"", key.fields[0], "\""))));
121
121
  const arg_6 = valueToInterpolationString(tupledArg_1[1]);
122
122
  return toText(printf("%s => %s"))(arg_5)(arg_6);
123
123
  }, toList(v.fields[0])));
@@ -430,22 +430,61 @@ function valueEquals(a_mut, b_mut) {
430
430
  }
431
431
 
432
432
  function mapKeyToValue(key) {
433
- if (key.tag === 1) {
434
- return new Value(/* VInt */ 1, [key.fields[0]]);
435
- }
436
- else {
437
- return new Value(/* VString */ 4, [key.fields[0]]);
433
+ switch (key.tag) {
434
+ case 1:
435
+ return new Value(/* VInt */ 1, [key.fields[0]]);
436
+ case 2:
437
+ return new Value(/* VBool */ 3, [key.fields[0]]);
438
+ case 3:
439
+ return new Value(/* VUnionCase */ 10, [key.fields[0], key.fields[1], undefined]);
440
+ default:
441
+ return new Value(/* VString */ 4, [key.fields[0]]);
438
442
  }
439
443
  }
440
444
 
441
445
  function valueToMapKey(span, value) {
446
+ let matchResult, s, i, b, caseName, typeName;
442
447
  switch (value.tag) {
443
- case 4:
444
- return new MapKey(/* MKString */ 0, [value.fields[0]]);
448
+ case 4: {
449
+ matchResult = 0;
450
+ s = value.fields[0];
451
+ break;
452
+ }
453
+ case 1: {
454
+ matchResult = 1;
455
+ i = value.fields[0];
456
+ break;
457
+ }
458
+ case 3: {
459
+ matchResult = 2;
460
+ b = value.fields[0];
461
+ break;
462
+ }
463
+ case 10: {
464
+ if (value.fields[2] == null) {
465
+ matchResult = 3;
466
+ caseName = value.fields[1];
467
+ typeName = value.fields[0];
468
+ }
469
+ else {
470
+ matchResult = 4;
471
+ }
472
+ break;
473
+ }
474
+ default:
475
+ matchResult = 4;
476
+ }
477
+ switch (matchResult) {
478
+ case 0:
479
+ return new MapKey(/* MKString */ 0, [s]);
445
480
  case 1:
446
- return new MapKey(/* MKInt */ 1, [value.fields[0]]);
481
+ return new MapKey(/* MKInt */ 1, [i]);
482
+ case 2:
483
+ return new MapKey(/* MKBool */ 2, [b]);
484
+ case 3:
485
+ return new MapKey(/* MKUnionCase */ 3, [typeName, caseName]);
447
486
  default:
448
- throw new EvalException(new EvalError$("Map key must be string or int", span));
487
+ throw new EvalException(new EvalError$("Map key must be string, int, bool, or a payload-free union case", span));
449
488
  }
450
489
  }
451
490
 
@@ -505,6 +544,30 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
505
544
  return undefined;
506
545
  }
507
546
  case 4: {
547
+ const matchValue = equals_1(tref_1.fields[0], new TypeRef(/* TRName */ 0, ["numeric"])) ? Type.TInt : resolve(tref_1.fields[0]);
548
+ const matchValue_1 = resolve(tref_1.fields[1]);
549
+ let matchResult, key, value_1;
550
+ if (matchValue != null) {
551
+ if (matchValue_1 != null) {
552
+ matchResult = 0;
553
+ key = matchValue;
554
+ value_1 = matchValue_1;
555
+ }
556
+ else {
557
+ matchResult = 1;
558
+ }
559
+ }
560
+ else {
561
+ matchResult = 1;
562
+ }
563
+ switch (matchResult) {
564
+ case 0:
565
+ return new Type(/* TMap */ 9, [key, value_1]);
566
+ default:
567
+ return undefined;
568
+ }
569
+ }
570
+ case 5: {
508
571
  let shape;
509
572
  const option_11 = resolveFieldList(tref_1.fields[0]);
510
573
  shape = ((option_11 != null) ? ofList(option_11, {
@@ -514,20 +577,20 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
514
577
  const s = shape;
515
578
  return tryPick((tupledArg) => {
516
579
  const t_1 = tupledArg[1];
517
- let matchResult, f_1;
580
+ let matchResult_1, f_1;
518
581
  if (t_1.tag === 8) {
519
582
  if (t_1.fields[0].Equals(s)) {
520
- matchResult = 0;
583
+ matchResult_1 = 0;
521
584
  f_1 = t_1.fields[0];
522
585
  }
523
586
  else {
524
- matchResult = 1;
587
+ matchResult_1 = 1;
525
588
  }
526
589
  }
527
590
  else {
528
- matchResult = 1;
591
+ matchResult_1 = 1;
529
592
  }
530
- switch (matchResult) {
593
+ switch (matchResult_1) {
531
594
  case 0:
532
595
  return new Type(/* TNamed */ 12, [tupledArg[0]]);
533
596
  default:
@@ -539,7 +602,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
539
602
  return undefined;
540
603
  }
541
604
  }
542
- case 5: {
605
+ case 6: {
543
606
  const option_13 = resolveFieldList(tref_1.fields[0]);
544
607
  if (option_13 != null) {
545
608
  return new Type(/* TRecord */ 8, [ofList(option_13, {
@@ -569,23 +632,23 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
569
632
  };
570
633
  const resolveTypeList = (items) => {
571
634
  if (!isEmpty(items)) {
572
- const matchValue = resolve(head_2(items));
573
- const matchValue_1 = resolveTypeList(tail_2(items));
574
- let matchResult_1, h, t_2;
575
- if (matchValue != null) {
576
- if (matchValue_1 != null) {
577
- matchResult_1 = 0;
578
- h = matchValue;
579
- t_2 = matchValue_1;
635
+ const matchValue_3 = resolve(head_2(items));
636
+ const matchValue_4 = resolveTypeList(tail_2(items));
637
+ let matchResult_2, h, t_2;
638
+ if (matchValue_3 != null) {
639
+ if (matchValue_4 != null) {
640
+ matchResult_2 = 0;
641
+ h = matchValue_3;
642
+ t_2 = matchValue_4;
580
643
  }
581
644
  else {
582
- matchResult_1 = 1;
645
+ matchResult_2 = 1;
583
646
  }
584
647
  }
585
648
  else {
586
- matchResult_1 = 1;
649
+ matchResult_2 = 1;
587
650
  }
588
- switch (matchResult_1) {
651
+ switch (matchResult_2) {
589
652
  case 0:
590
653
  return cons(h, t_2);
591
654
  default:
@@ -598,23 +661,23 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
598
661
  };
599
662
  const resolveFieldList = (fields_2) => {
600
663
  if (!isEmpty(fields_2)) {
601
- const matchValue_3 = resolve(head_2(fields_2)[1]);
602
- const matchValue_4 = resolveFieldList(tail_2(fields_2));
603
- let matchResult_2, rest, t_3;
604
- if (matchValue_3 != null) {
605
- if (matchValue_4 != null) {
606
- matchResult_2 = 0;
607
- rest = matchValue_4;
608
- t_3 = matchValue_3;
664
+ const matchValue_6 = resolve(head_2(fields_2)[1]);
665
+ const matchValue_7 = resolveFieldList(tail_2(fields_2));
666
+ let matchResult_3, rest, t_3;
667
+ if (matchValue_6 != null) {
668
+ if (matchValue_7 != null) {
669
+ matchResult_3 = 0;
670
+ rest = matchValue_7;
671
+ t_3 = matchValue_6;
609
672
  }
610
673
  else {
611
- matchResult_2 = 1;
674
+ matchResult_3 = 1;
612
675
  }
613
676
  }
614
677
  else {
615
- matchResult_2 = 1;
678
+ matchResult_3 = 1;
616
679
  }
617
- switch (matchResult_2) {
680
+ switch (matchResult_3) {
618
681
  case 0:
619
682
  return cons([head_2(fields_2)[0], t_3], rest);
620
683
  default:
@@ -625,135 +688,135 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
625
688
  return empty();
626
689
  }
627
690
  };
628
- const valueHasType = (value_1_mut, t_4_mut) => {
691
+ const valueHasType = (value_2_mut, t_4_mut) => {
629
692
  valueHasType:
630
693
  while (true) {
631
- const value_1 = value_1_mut, t_4 = t_4_mut;
632
- let matchResult_3, inner_4, items_1, inner_5, items_2, inner_6, inner_7, v_1, fields_3, values, name_4, v_2;
694
+ const value_2 = value_2_mut, t_4 = t_4_mut;
695
+ let matchResult_4, inner_4, items_1, inner_5, items_2, inner_6, inner_7, v_1, fields_3, values, name_4, v_2;
633
696
  switch (t_4.tag) {
634
697
  case 0: {
635
- if (value_1.tag === 0) {
636
- matchResult_3 = 0;
698
+ if (value_2.tag === 0) {
699
+ matchResult_4 = 0;
637
700
  }
638
701
  else {
639
- matchResult_3 = 13;
702
+ matchResult_4 = 13;
640
703
  }
641
704
  break;
642
705
  }
643
706
  case 1: {
644
- if (value_1.tag === 1) {
645
- matchResult_3 = 1;
707
+ if (value_2.tag === 1) {
708
+ matchResult_4 = 1;
646
709
  }
647
710
  else {
648
- matchResult_3 = 13;
711
+ matchResult_4 = 13;
649
712
  }
650
713
  break;
651
714
  }
652
715
  case 2: {
653
- if (value_1.tag === 2) {
654
- matchResult_3 = 2;
716
+ if (value_2.tag === 2) {
717
+ matchResult_4 = 2;
655
718
  }
656
719
  else {
657
- matchResult_3 = 13;
720
+ matchResult_4 = 13;
658
721
  }
659
722
  break;
660
723
  }
661
724
  case 3: {
662
- if (value_1.tag === 3) {
663
- matchResult_3 = 3;
725
+ if (value_2.tag === 3) {
726
+ matchResult_4 = 3;
664
727
  }
665
728
  else {
666
- matchResult_3 = 13;
729
+ matchResult_4 = 13;
667
730
  }
668
731
  break;
669
732
  }
670
733
  case 4: {
671
- if (value_1.tag === 4) {
672
- matchResult_3 = 4;
734
+ if (value_2.tag === 4) {
735
+ matchResult_4 = 4;
673
736
  }
674
737
  else {
675
- matchResult_3 = 13;
738
+ matchResult_4 = 13;
676
739
  }
677
740
  break;
678
741
  }
679
742
  case 5: {
680
- if (value_1.tag === 5) {
681
- matchResult_3 = 5;
743
+ if (value_2.tag === 5) {
744
+ matchResult_4 = 5;
682
745
  inner_4 = t_4.fields[0];
683
- items_1 = value_1.fields[0];
746
+ items_1 = value_2.fields[0];
684
747
  }
685
748
  else {
686
- matchResult_3 = 13;
749
+ matchResult_4 = 13;
687
750
  }
688
751
  break;
689
752
  }
690
753
  case 6: {
691
- if (value_1.tag === 13) {
692
- matchResult_3 = 6;
754
+ if (value_2.tag === 13) {
755
+ matchResult_4 = 6;
693
756
  }
694
757
  else {
695
- matchResult_3 = 13;
758
+ matchResult_4 = 13;
696
759
  }
697
760
  break;
698
761
  }
699
762
  case 7: {
700
- if (value_1.tag === 6) {
701
- matchResult_3 = 7;
763
+ if (value_2.tag === 6) {
764
+ matchResult_4 = 7;
702
765
  inner_5 = t_4.fields[0];
703
- items_2 = value_1.fields[0];
766
+ items_2 = value_2.fields[0];
704
767
  }
705
768
  else {
706
- matchResult_3 = 13;
769
+ matchResult_4 = 13;
707
770
  }
708
771
  break;
709
772
  }
710
773
  case 10: {
711
- if (value_1.tag === 9) {
712
- if (value_1.fields[0] != null) {
713
- matchResult_3 = 9;
774
+ if (value_2.tag === 9) {
775
+ if (value_2.fields[0] != null) {
776
+ matchResult_4 = 9;
714
777
  inner_7 = t_4.fields[0];
715
- v_1 = value_1.fields[0];
778
+ v_1 = value_2.fields[0];
716
779
  }
717
780
  else {
718
- matchResult_3 = 8;
781
+ matchResult_4 = 8;
719
782
  inner_6 = t_4.fields[0];
720
783
  }
721
784
  }
722
785
  else {
723
- matchResult_3 = 13;
786
+ matchResult_4 = 13;
724
787
  }
725
788
  break;
726
789
  }
727
790
  case 9: {
728
- if (value_1.tag === 8) {
729
- matchResult_3 = 10;
791
+ if (value_2.tag === 8) {
792
+ matchResult_4 = 10;
730
793
  }
731
794
  else {
732
- matchResult_3 = 13;
795
+ matchResult_4 = 13;
733
796
  }
734
797
  break;
735
798
  }
736
799
  case 8: {
737
- if (value_1.tag === 7) {
738
- matchResult_3 = 11;
800
+ if (value_2.tag === 7) {
801
+ matchResult_4 = 11;
739
802
  fields_3 = t_4.fields[0];
740
- values = value_1.fields[0];
803
+ values = value_2.fields[0];
741
804
  }
742
805
  else {
743
- matchResult_3 = 13;
806
+ matchResult_4 = 13;
744
807
  }
745
808
  break;
746
809
  }
747
810
  case 12: {
748
- matchResult_3 = 12;
811
+ matchResult_4 = 12;
749
812
  name_4 = t_4.fields[0];
750
- v_2 = value_1;
813
+ v_2 = value_2;
751
814
  break;
752
815
  }
753
816
  default:
754
- matchResult_3 = 13;
817
+ matchResult_4 = 13;
755
818
  }
756
- switch (matchResult_3) {
819
+ switch (matchResult_4) {
757
820
  case 0:
758
821
  return true;
759
822
  case 1:
@@ -778,7 +841,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
778
841
  case 8:
779
842
  return true;
780
843
  case 9: {
781
- value_1_mut = v_1;
844
+ value_2_mut = v_1;
782
845
  t_4_mut = inner_7;
783
846
  continue valueHasType;
784
847
  }
@@ -786,22 +849,22 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
786
849
  return true;
787
850
  case 11:
788
851
  return forAll((name_3, ft) => {
789
- const matchValue_7 = FSharpMap__TryFind(values, name_3);
790
- if (matchValue_7 == null) {
852
+ const matchValue_10 = FSharpMap__TryFind(values, name_3);
853
+ if (matchValue_10 == null) {
791
854
  return false;
792
855
  }
793
856
  else {
794
- return valueHasType(matchValue_7, ft);
857
+ return valueHasType(matchValue_10, ft);
795
858
  }
796
859
  }, fields_3);
797
860
  case 12: {
798
- const matchValue_8 = FSharpMap__TryFind(typeDefs, name_4);
799
- if (matchValue_8 == null) {
861
+ const matchValue_11 = FSharpMap__TryFind(typeDefs, name_4);
862
+ if (matchValue_11 == null) {
800
863
  return false;
801
864
  }
802
865
  else {
803
- value_1_mut = v_2;
804
- t_4_mut = matchValue_8;
866
+ value_2_mut = v_2;
867
+ t_4_mut = matchValue_11;
805
868
  continue valueHasType;
806
869
  }
807
870
  }
@@ -812,31 +875,31 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
812
875
  }
813
876
  };
814
877
  switch (tref.tag) {
815
- case 4: {
816
- const matchValue_9 = resolve(tref);
817
- if (matchValue_9 == null) {
878
+ case 5: {
879
+ const matchValue_12 = resolve(tref);
880
+ if (matchValue_12 == null) {
818
881
  return false;
819
882
  }
820
883
  else {
821
- return valueHasType(value, matchValue_9);
884
+ return valueHasType(value, matchValue_12);
822
885
  }
823
886
  }
824
- case 5: {
825
- const matchValue_10 = resolve(new TypeRef(/* TRStructuralRecord */ 5, [tref.fields[0]]));
826
- if (matchValue_10 == null) {
887
+ case 6: {
888
+ const matchValue_13 = resolve(new TypeRef(/* TRStructuralRecord */ 6, [tref.fields[0]]));
889
+ if (matchValue_13 == null) {
827
890
  return false;
828
891
  }
829
892
  else {
830
- return valueHasType(value, matchValue_10);
893
+ return valueHasType(value, matchValue_13);
831
894
  }
832
895
  }
833
896
  default: {
834
- const matchValue_11 = resolve(tref);
835
- if (matchValue_11 == null) {
897
+ const matchValue_14 = resolve(tref);
898
+ if (matchValue_14 == null) {
836
899
  return false;
837
900
  }
838
901
  else {
839
- return valueHasType(value, matchValue_11);
902
+ return valueHasType(value, matchValue_14);
840
903
  }
841
904
  }
842
905
  }
@@ -938,19 +1001,7 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
938
1001
  const matchValue_7 = FSharpMap__TryFind(envAcc, keyPattern.fields[0]);
939
1002
  if (matchValue_7 != null) {
940
1003
  const targetKeyValue = matchValue_7;
941
- let targetKey;
942
- switch (targetKeyValue.tag) {
943
- case 4: {
944
- targetKey = (new MapKey(/* MKString */ 0, [targetKeyValue.fields[0]]));
945
- break;
946
- }
947
- case 1: {
948
- targetKey = (new MapKey(/* MKInt */ 1, [targetKeyValue.fields[0]]));
949
- break;
950
- }
951
- default:
952
- throw new EvalException(new EvalError$("Map key must be string or int", Ast_spanOfPattern(keyPattern)));
953
- }
1004
+ const targetKey = valueToMapKey(Ast_spanOfPattern(keyPattern), targetKeyValue);
954
1005
  if (!FSharpMap__ContainsKey(remaining, targetKey)) {
955
1006
  return undefined;
956
1007
  }
@@ -1672,12 +1723,31 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1672
1723
  else {
1673
1724
  const keyExpr = entry.fields[0];
1674
1725
  const keyValue = evalExpr(runtime, typeDefs, env, keyExpr);
1726
+ let matchResult_1;
1675
1727
  switch (keyValue.tag) {
1676
1728
  case 4:
1677
1729
  case 1:
1730
+ case 3: {
1731
+ matchResult_1 = 0;
1732
+ break;
1733
+ }
1734
+ case 10: {
1735
+ if (keyValue.fields[2] == null) {
1736
+ matchResult_1 = 0;
1737
+ }
1738
+ else {
1739
+ matchResult_1 = 1;
1740
+ }
1741
+ break;
1742
+ }
1743
+ default:
1744
+ matchResult_1 = 1;
1745
+ }
1746
+ switch (matchResult_1) {
1747
+ case 0:
1678
1748
  return FSharpMap__Add(acc_4, valueToMapKey(Ast_spanOfExpr(keyExpr), keyValue), evalExpr(runtime, typeDefs, env, entry.fields[1]));
1679
1749
  default:
1680
- throw new EvalException(new EvalError$("Map literal keys must be string or int", Ast_spanOfExpr(keyExpr)));
1750
+ throw new EvalException(new EvalError$("Unsupported map literal key", Ast_spanOfExpr(keyExpr)));
1681
1751
  }
1682
1752
  }
1683
1753
  }, empty_1({
@@ -1714,20 +1784,20 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1714
1784
  const target_2 = expr.fields[0];
1715
1785
  const span_12 = expr.fields[2];
1716
1786
  const fieldName = expr.fields[1];
1717
- let matchResult_1, moduleName_1;
1787
+ let matchResult_2, moduleName_1;
1718
1788
  if (target_2.tag === 2) {
1719
1789
  if (!FSharpMap__ContainsKey(env, target_2.fields[0])) {
1720
- matchResult_1 = 0;
1790
+ matchResult_2 = 0;
1721
1791
  moduleName_1 = target_2.fields[0];
1722
1792
  }
1723
1793
  else {
1724
- matchResult_1 = 1;
1794
+ matchResult_2 = 1;
1725
1795
  }
1726
1796
  }
1727
1797
  else {
1728
- matchResult_1 = 1;
1798
+ matchResult_2 = 1;
1729
1799
  }
1730
- switch (matchResult_1) {
1800
+ switch (matchResult_2) {
1731
1801
  case 0: {
1732
1802
  const matchValue_11 = FSharpMap__TryFind(env, concat(moduleName_1, ".", fieldName));
1733
1803
  if (matchValue_11 == null) {
@@ -1770,40 +1840,55 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1770
1840
  const span_13 = expr.fields[2];
1771
1841
  const targetValue = evalExpr(runtime, typeDefs, env, expr.fields[0]);
1772
1842
  const keyValue_1 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1773
- let matchResult_2, index, values, mapValue;
1843
+ let matchResult_3, index, values, mapValue;
1774
1844
  switch (targetValue.tag) {
1775
1845
  case 5: {
1776
1846
  if (keyValue_1.tag === 1) {
1777
- matchResult_2 = 0;
1847
+ matchResult_3 = 0;
1778
1848
  index = keyValue_1.fields[0];
1779
1849
  values = targetValue.fields[0];
1780
1850
  }
1781
1851
  else {
1782
- matchResult_2 = 3;
1852
+ matchResult_3 = 3;
1783
1853
  }
1784
1854
  break;
1785
1855
  }
1786
1856
  case 8: {
1787
1857
  switch (keyValue_1.tag) {
1788
1858
  case 4: {
1789
- matchResult_2 = 1;
1859
+ matchResult_3 = 1;
1790
1860
  mapValue = targetValue.fields[0];
1791
1861
  break;
1792
1862
  }
1793
1863
  case 1: {
1794
- matchResult_2 = 1;
1864
+ matchResult_3 = 1;
1865
+ mapValue = targetValue.fields[0];
1866
+ break;
1867
+ }
1868
+ case 3: {
1869
+ matchResult_3 = 1;
1795
1870
  mapValue = targetValue.fields[0];
1796
1871
  break;
1797
1872
  }
1873
+ case 10: {
1874
+ if (keyValue_1.fields[2] == null) {
1875
+ matchResult_3 = 1;
1876
+ mapValue = targetValue.fields[0];
1877
+ }
1878
+ else {
1879
+ matchResult_3 = 2;
1880
+ }
1881
+ break;
1882
+ }
1798
1883
  default:
1799
- matchResult_2 = 2;
1884
+ matchResult_3 = 2;
1800
1885
  }
1801
1886
  break;
1802
1887
  }
1803
1888
  default:
1804
- matchResult_2 = 4;
1889
+ matchResult_3 = 4;
1805
1890
  }
1806
- switch (matchResult_2) {
1891
+ switch (matchResult_3) {
1807
1892
  case 0: {
1808
1893
  const loop = (remaining_mut, current_1_mut) => {
1809
1894
  loop:
@@ -1835,7 +1920,7 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1835
1920
  case 1:
1836
1921
  return new Value(/* VOption */ 9, [FSharpMap__TryFind(mapValue, valueToMapKey(span_13, keyValue_1))]);
1837
1922
  case 2:
1838
- throw new EvalException(new EvalError$("Map index key must be string or int", span_13));
1923
+ throw new EvalException(new EvalError$("Map index key must be string, int, bool, or a payload-free union case", span_13));
1839
1924
  case 3:
1840
1925
  throw new EvalException(new EvalError$("List index must be int", span_13));
1841
1926
  default:
@@ -1855,21 +1940,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1855
1940
  case 24: {
1856
1941
  const av = evalExpr(runtime, typeDefs, env, expr.fields[0]);
1857
1942
  const bv = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1858
- let matchResult_3, xs_1, ys;
1943
+ let matchResult_4, xs_1, ys;
1859
1944
  if (av.tag === 5) {
1860
1945
  if (bv.tag === 5) {
1861
- matchResult_3 = 0;
1946
+ matchResult_4 = 0;
1862
1947
  xs_1 = av.fields[0];
1863
1948
  ys = bv.fields[0];
1864
1949
  }
1865
1950
  else {
1866
- matchResult_3 = 1;
1951
+ matchResult_4 = 1;
1867
1952
  }
1868
1953
  }
1869
1954
  else {
1870
- matchResult_3 = 1;
1955
+ matchResult_4 = 1;
1871
1956
  }
1872
- switch (matchResult_3) {
1957
+ switch (matchResult_4) {
1873
1958
  case 0:
1874
1959
  return new Value(/* VList */ 5, [append(xs_1, ys)]);
1875
1960
  default:
@@ -1882,34 +1967,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1882
1967
  const av_1 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1883
1968
  const bv_1 = evalExpr(runtime, typeDefs, env, expr.fields[2]);
1884
1969
  const arith = (fInt, fFloat) => {
1885
- let matchResult_4, x_3, y_3, x_4, y_4;
1970
+ let matchResult_5, x_3, y_3, x_4, y_4;
1886
1971
  switch (av_1.tag) {
1887
1972
  case 1: {
1888
1973
  if (bv_1.tag === 1) {
1889
- matchResult_4 = 0;
1974
+ matchResult_5 = 0;
1890
1975
  x_3 = av_1.fields[0];
1891
1976
  y_3 = bv_1.fields[0];
1892
1977
  }
1893
1978
  else {
1894
- matchResult_4 = 2;
1979
+ matchResult_5 = 2;
1895
1980
  }
1896
1981
  break;
1897
1982
  }
1898
1983
  case 2: {
1899
1984
  if (bv_1.tag === 2) {
1900
- matchResult_4 = 1;
1985
+ matchResult_5 = 1;
1901
1986
  x_4 = av_1.fields[0];
1902
1987
  y_4 = bv_1.fields[0];
1903
1988
  }
1904
1989
  else {
1905
- matchResult_4 = 2;
1990
+ matchResult_5 = 2;
1906
1991
  }
1907
1992
  break;
1908
1993
  }
1909
1994
  default:
1910
- matchResult_4 = 2;
1995
+ matchResult_5 = 2;
1911
1996
  }
1912
- switch (matchResult_4) {
1997
+ switch (matchResult_5) {
1913
1998
  case 0:
1914
1999
  return new Value(/* VInt */ 1, [fInt(x_3)(y_3)]);
1915
2000
  case 1:
@@ -1928,34 +2013,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1928
2013
  case "*":
1929
2014
  return arith((x_9) => ((y_9) => toInt64_unchecked(op_Multiply(x_9, y_9))), (x_10) => ((y_10) => (x_10 * y_10)));
1930
2015
  case "/": {
1931
- let matchResult_5, x_11, y_11, x_12, y_12;
2016
+ let matchResult_6, x_11, y_11, x_12, y_12;
1932
2017
  switch (av_1.tag) {
1933
2018
  case 1: {
1934
2019
  if (bv_1.tag === 1) {
1935
- matchResult_5 = 0;
2020
+ matchResult_6 = 0;
1936
2021
  x_11 = av_1.fields[0];
1937
2022
  y_11 = bv_1.fields[0];
1938
2023
  }
1939
2024
  else {
1940
- matchResult_5 = 2;
2025
+ matchResult_6 = 2;
1941
2026
  }
1942
2027
  break;
1943
2028
  }
1944
2029
  case 2: {
1945
2030
  if (bv_1.tag === 2) {
1946
- matchResult_5 = 1;
2031
+ matchResult_6 = 1;
1947
2032
  x_12 = av_1.fields[0];
1948
2033
  y_12 = bv_1.fields[0];
1949
2034
  }
1950
2035
  else {
1951
- matchResult_5 = 2;
2036
+ matchResult_6 = 2;
1952
2037
  }
1953
2038
  break;
1954
2039
  }
1955
2040
  default:
1956
- matchResult_5 = 2;
2041
+ matchResult_6 = 2;
1957
2042
  }
1958
- switch (matchResult_5) {
2043
+ switch (matchResult_6) {
1959
2044
  case 0:
1960
2045
  return new Value(/* VInt */ 1, [toInt64_unchecked(op_Division(x_11, y_11))]);
1961
2046
  case 1:
@@ -1965,21 +2050,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1965
2050
  }
1966
2051
  }
1967
2052
  case "%": {
1968
- let matchResult_6, x_13, y_13;
2053
+ let matchResult_7, x_13, y_13;
1969
2054
  if (av_1.tag === 1) {
1970
2055
  if (bv_1.tag === 1) {
1971
- matchResult_6 = 0;
2056
+ matchResult_7 = 0;
1972
2057
  x_13 = av_1.fields[0];
1973
2058
  y_13 = bv_1.fields[0];
1974
2059
  }
1975
2060
  else {
1976
- matchResult_6 = 1;
2061
+ matchResult_7 = 1;
1977
2062
  }
1978
2063
  }
1979
2064
  else {
1980
- matchResult_6 = 1;
2065
+ matchResult_7 = 1;
1981
2066
  }
1982
- switch (matchResult_6) {
2067
+ switch (matchResult_7) {
1983
2068
  case 0:
1984
2069
  return new Value(/* VInt */ 1, [toInt64_unchecked(op_Modulus(x_13, y_13))]);
1985
2070
  default:
@@ -1992,34 +2077,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1992
2077
  case ">":
1993
2078
  case "<=":
1994
2079
  case ">=": {
1995
- let matchResult_7, x_14, y_14, x_15, y_15;
2080
+ let matchResult_8, x_14, y_14, x_15, y_15;
1996
2081
  switch (av_1.tag) {
1997
2082
  case 1: {
1998
2083
  if (bv_1.tag === 1) {
1999
- matchResult_7 = 0;
2084
+ matchResult_8 = 0;
2000
2085
  x_14 = av_1.fields[0];
2001
2086
  y_14 = bv_1.fields[0];
2002
2087
  }
2003
2088
  else {
2004
- matchResult_7 = 2;
2089
+ matchResult_8 = 2;
2005
2090
  }
2006
2091
  break;
2007
2092
  }
2008
2093
  case 2: {
2009
2094
  if (bv_1.tag === 2) {
2010
- matchResult_7 = 1;
2095
+ matchResult_8 = 1;
2011
2096
  x_15 = av_1.fields[0];
2012
2097
  y_15 = bv_1.fields[0];
2013
2098
  }
2014
2099
  else {
2015
- matchResult_7 = 2;
2100
+ matchResult_8 = 2;
2016
2101
  }
2017
2102
  break;
2018
2103
  }
2019
2104
  default:
2020
- matchResult_7 = 2;
2105
+ matchResult_8 = 2;
2021
2106
  }
2022
- switch (matchResult_7) {
2107
+ switch (matchResult_8) {
2023
2108
  case 0:
2024
2109
  return new Value(/* VBool */ 3, [(op === "<") ? (compare_1(x_14, y_14) < 0) : ((op === ">") ? (compare_1(x_14, y_14) > 0) : ((op === "<=") ? (compare_1(x_14, y_14) <= 0) : ((op === ">=") && (compare_1(x_14, y_14) >= 0))))]);
2025
2110
  case 1:
@@ -2030,21 +2115,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2030
2115
  }
2031
2116
  case "&&":
2032
2117
  case "||": {
2033
- let matchResult_8, x_16, y_16;
2118
+ let matchResult_9, x_16, y_16;
2034
2119
  if (av_1.tag === 3) {
2035
2120
  if (bv_1.tag === 3) {
2036
- matchResult_8 = 0;
2121
+ matchResult_9 = 0;
2037
2122
  x_16 = av_1.fields[0];
2038
2123
  y_16 = bv_1.fields[0];
2039
2124
  }
2040
2125
  else {
2041
- matchResult_8 = 1;
2126
+ matchResult_9 = 1;
2042
2127
  }
2043
2128
  }
2044
2129
  else {
2045
- matchResult_8 = 1;
2130
+ matchResult_9 = 1;
2046
2131
  }
2047
- switch (matchResult_8) {
2132
+ switch (matchResult_9) {
2048
2133
  case 0:
2049
2134
  return new Value(/* VBool */ 3, [(op === "&&") ? (x_16 && y_16) : (x_16 ? true : y_16)]);
2050
2135
  default:
@@ -2059,21 +2144,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2059
2144
  throw new EvalException(new EvalError$("Right side of \'::\' must be list", span_16));
2060
2145
  }
2061
2146
  case "@": {
2062
- let matchResult_9, xs_3, ys_1;
2147
+ let matchResult_10, xs_3, ys_1;
2063
2148
  if (av_1.tag === 5) {
2064
2149
  if (bv_1.tag === 5) {
2065
- matchResult_9 = 0;
2150
+ matchResult_10 = 0;
2066
2151
  xs_3 = av_1.fields[0];
2067
2152
  ys_1 = bv_1.fields[0];
2068
2153
  }
2069
2154
  else {
2070
- matchResult_9 = 1;
2155
+ matchResult_10 = 1;
2071
2156
  }
2072
2157
  }
2073
2158
  else {
2074
- matchResult_9 = 1;
2159
+ matchResult_10 = 1;
2075
2160
  }
2076
- switch (matchResult_9) {
2161
+ switch (matchResult_10) {
2077
2162
  case 0:
2078
2163
  return new Value(/* VList */ 5, [append(xs_3, ys_1)]);
2079
2164
  default:
@@ -2388,10 +2473,12 @@ export function evalProgramWithExternsState(externs, program) {
2388
2473
  throw new EvalException(new EvalError$(concat("Unsupported type suffix ", tref.fields[1]), unknownSpan));
2389
2474
  }
2390
2475
  case 4:
2476
+ return new Type(/* TMap */ 9, [equals_1(tref.fields[0], new TypeRef(/* TRName */ 0, ["numeric"])) ? Type.TInt : fromRef(stack, tref.fields[0]), fromRef(stack, tref.fields[1])]);
2477
+ case 5:
2391
2478
  return new Type(/* TRecord */ 8, [ofList(map((tupledArg_2) => [tupledArg_2[0], fromRef(stack, tupledArg_2[1])], tref.fields[0]), {
2392
2479
  Compare: (x_3, y_4) => (comparePrimitives(x_3, y_4) | 0),
2393
2480
  })]);
2394
- case 5:
2481
+ case 6:
2395
2482
  return new Type(/* TRecord */ 8, [ofList(map((tupledArg_3) => [tupledArg_3[0], fromRef(stack, tupledArg_3[1])], tref.fields[0]), {
2396
2483
  Compare: (x_4, y_5) => (comparePrimitives(x_4, y_5) | 0),
2397
2484
  })]);