@magnusopera/fscript 0.94.3 → 0.95.2

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,30 +1,30 @@
1
1
 
2
2
  import { toString, FSharpRef, Record } from "../fable_modules/fable-library-js.5.27.0/Types.js";
3
3
  import { array_type, bool_type, obj_type, record_type, class_type, string_type, enum_type, int32_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
4
- import { Scheme as Scheme_1, Type, Types_typeToString, Type_$reflection } from "./Types.js";
5
- import { ExternalFunction, ExternalCallContext, MapKey, Value, TaskHandle_$reflection, Value_$reflection } from "./Value.js";
4
+ import { Scheme as Scheme_1, Type, Types_typeToString, Types_ftvType, Type_$reflection } from "./Types.js";
5
+ import { ExternalFunction, ExternalCallContext, MapKey, JsonDeserialization_scheme, JsonDeserialization_name, Value, JsonDeserialization_withTarget, TaskHandle_$reflection, Value_$reflection } from "./Value.js";
6
6
  import { Span, Position } from "./Span.js";
7
+ import { scriptTypeDefinitions, specializeEvaluationType, applyType } from "./TypeInfer.js";
8
+ import { keys, containsKey, FSharpMap__Add, empty as empty_1, FSharpMap__get_Item, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, toSeq, ofList, tryFind, forAll, FSharpMap__get_Count, toList, add as add_1, fold, FSharpMap__TryFind, ofSeq } from "../fable_modules/fable-library-js.5.27.0/Map.js";
9
+ import { toList as toList_1, foldBack, head as head_2, tryPick, map, exists, choose } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
10
+ import { compare as compare_1, defaultOf, disposeSafe, getEnumerator, int64ToString, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
11
+ import { ofArray, collect, tryFind as tryFind_1, tryPick as tryPick_1, reverse, append, zip, fold as fold_1, singleton, forAll as forAll_1, cons, tail as tail_2, head as head_1, choose as choose_1, forAll2, length, map as map_1, isEmpty, empty } from "../fable_modules/fable-library-js.5.27.0/List.js";
12
+ import { contains, FSharpSet__get_IsEmpty } from "../fable_modules/fable-library-js.5.27.0/Set.js";
7
13
  import { printf, toText, float64ToString, join, concat } from "../fable_modules/fable-library-js.5.27.0/String.js";
8
14
  import { EvalException, EvalError$ } from "./Error.js";
9
15
  import { ofExterns, typeDefinitions, permitted, invoke, prepareCall, matches, $007CRecordFields$007C_$007C, permissionNames, allows } from "./HostInterop.js";
10
16
  import { FSharpChoice$2 } from "../fable_modules/fable-library-js.5.27.0/Choice.js";
11
- import { toList as toList_1, foldBack, head as head_2, tryPick, map, exists } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
12
17
  import { item as item_1 } from "../fable_modules/fable-library-js.5.27.0/Array.js";
13
- import { compare as compare_1, defaultOf, disposeSafe, getEnumerator, comparePrimitives, equals as equals_1, int64ToString } from "../fable_modules/fable-library-js.5.27.0/Util.js";
14
- import { ofArray, collect, tryFind as tryFind_1, tryPick as tryPick_1, reverse, append, zip, fold as fold_1, singleton, forAll as forAll_1, empty, cons, tail as tail_2, head as head_1, choose, isEmpty, forAll2, length, map as map_1 } from "../fable_modules/fable-library-js.5.27.0/List.js";
15
- import { keys, containsKey, FSharpMap__Add, fold, empty as empty_1, FSharpMap__get_Item, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, add as add_1, FSharpMap__TryFind, toSeq, ofList, tryFind, forAll, FSharpMap__get_Count, toList } from "../fable_modules/fable-library-js.5.27.0/Map.js";
16
- import { compare, op_Modulus, op_Division, op_Multiply, op_Subtraction, op_Addition, toInt64_unchecked, equals } from "../fable_modules/fable-library-js.5.27.0/BigInt.js";
18
+ import { compare, op_Modulus, op_Division, op_Multiply, op_Subtraction, op_Addition, toInt64_unchecked, equals as equals_1 } from "../fable_modules/fable-library-js.5.27.0/BigInt.js";
17
19
  import { some, toArray } from "../fable_modules/fable-library-js.5.27.0/Option.js";
18
- import { Ast_spanOfExpr, Expr, Ast_spanOfPattern, TypeRef } from "./Ast.js";
20
+ import { Expr, Ast_spanOfExpr, Ast_spanOfPattern, TypeRef } from "./Ast.js";
19
21
  import { Execution_fold, Execution_map, Execution_execution, Execution_Builder__For_Z3A5BE4A, Execution$1__get_IsImmediate, Execution$1, Execution_run } from "./Execution.js";
20
22
  import { isCanonical } from "./TaskFunctions.js";
21
23
  import { builtinExterns, tryExecution } from "./BuiltinFunctions.js";
22
24
  import { StringBuilder__Append_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.27.0/System.Text.js";
23
25
  import { Operators_InvalidOp } from "../fable_modules/fable-library-js.5.27.0/FSharp.Core.js";
24
- import { contains } from "../fable_modules/fable-library-js.5.27.0/Set.js";
25
26
  import { builtinReservedNames } from "./BuiltinSignatures.js";
26
27
  import { typeDefs as typeDefs_2 } from "./BuiltinTypes.js";
27
- import { scriptTypeDefinitions } from "./TypeInfer.js";
28
28
 
29
29
  export class ProgramState extends Record {
30
30
  constructor(Permissions, TypeDefs, Env, LastValue, ExitCode) {
@@ -70,6 +70,145 @@ function RuntimeState_$reflection() {
70
70
 
71
71
  const unknownSpan = new Span(new Position(undefined, 0, 0), new Position(undefined, 0, 0));
72
72
 
73
+ const evidencePrefix = "\u0000type:";
74
+
75
+ function evidenceKey(id) {
76
+ return `${evidencePrefix}${id}`;
77
+ }
78
+
79
+ function applyTypeEvidence(env, typ) {
80
+ return applyType(ofSeq(choose((id) => {
81
+ const matchValue = FSharpMap__TryFind(env, evidenceKey(id));
82
+ let matchResult, target;
83
+ if (matchValue != null) {
84
+ if (matchValue.tag === 12) {
85
+ matchResult = 0;
86
+ target = matchValue.fields[0];
87
+ }
88
+ else {
89
+ matchResult = 1;
90
+ }
91
+ }
92
+ else {
93
+ matchResult = 1;
94
+ }
95
+ switch (matchResult) {
96
+ case 0:
97
+ return [id, target];
98
+ default:
99
+ return undefined;
100
+ }
101
+ }, Types_ftvType(typ)), {
102
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
103
+ }), typ);
104
+ }
105
+
106
+ function closureBody(_arg) {
107
+ if (_arg.tag === 5) {
108
+ return _arg.fields[0];
109
+ }
110
+ else {
111
+ return _arg;
112
+ }
113
+ }
114
+
115
+ function specializeFunction(typeDefs, env, span, signature, value) {
116
+ let external;
117
+ let matchResult, external_1, body, captured, parameter, template;
118
+ switch (value.tag) {
119
+ case 15: {
120
+ if (isEmpty(value.fields[1])) {
121
+ if ((external = value.fields[0], (external.Name === JsonDeserialization_name) && equals(external.Scheme, JsonDeserialization_scheme))) {
122
+ matchResult = 0;
123
+ external_1 = value.fields[0];
124
+ }
125
+ else {
126
+ matchResult = 2;
127
+ }
128
+ }
129
+ else {
130
+ matchResult = 2;
131
+ }
132
+ break;
133
+ }
134
+ case 14: {
135
+ if (value.fields[1].tag === 5) {
136
+ matchResult = 1;
137
+ body = value.fields[1];
138
+ captured = value.fields[2];
139
+ parameter = value.fields[0];
140
+ template = value.fields[1].fields[1];
141
+ }
142
+ else {
143
+ matchResult = 2;
144
+ }
145
+ break;
146
+ }
147
+ default:
148
+ matchResult = 2;
149
+ }
150
+ switch (matchResult) {
151
+ case 0: {
152
+ const matchValue = applyTypeEvidence(env, signature);
153
+ let matchResult_1, target_1;
154
+ if (matchValue.tag === 11) {
155
+ if (matchValue.fields[0].tag === 4) {
156
+ if (matchValue.fields[1].tag === 10) {
157
+ if (FSharpSet__get_IsEmpty(Types_ftvType(matchValue.fields[1].fields[0]))) {
158
+ matchResult_1 = 0;
159
+ target_1 = matchValue.fields[1].fields[0];
160
+ }
161
+ else {
162
+ matchResult_1 = 1;
163
+ }
164
+ }
165
+ else {
166
+ matchResult_1 = 1;
167
+ }
168
+ }
169
+ else {
170
+ matchResult_1 = 1;
171
+ }
172
+ }
173
+ else {
174
+ matchResult_1 = 1;
175
+ }
176
+ switch (matchResult_1) {
177
+ case 0:
178
+ return new Value(/* VExternal */ 15, [JsonDeserialization_withTarget(typeDefs, target_1, external_1), empty()]);
179
+ default:
180
+ return value;
181
+ }
182
+ }
183
+ case 1: {
184
+ const instance = applyTypeEvidence(env, signature);
185
+ const template_1 = applyTypeEvidence(captured.contents, template);
186
+ if (FSharpSet__get_IsEmpty(Types_ftvType(template_1)) ? true : equals(template_1, instance)) {
187
+ return value;
188
+ }
189
+ else {
190
+ const evidence = specializeEvaluationType(typeDefs, span, template_1, instance);
191
+ const specialized = fold((scope, id, target_2) => {
192
+ if (FSharpSet__get_IsEmpty(Types_ftvType(target_2))) {
193
+ return add_1(evidenceKey(id), new Value(/* VTypeToken */ 12, [target_2]), scope);
194
+ }
195
+ else {
196
+ return scope;
197
+ }
198
+ }, captured.contents, evidence);
199
+ if (specialized === captured.contents) {
200
+ return value;
201
+ }
202
+ else {
203
+ return new Value(/* VClosure */ 14, [parameter, body, new FSharpRef(specialized)]);
204
+ }
205
+ }
206
+ }
207
+ default:
208
+ return value;
209
+ }
210
+ }
211
+
73
212
  function wrapUnexpectedTaskFailure(ex) {
74
213
  return new EvalError$(concat("Task failed: ", ex.message), unknownSpan);
75
214
  }
@@ -523,7 +662,7 @@ function valueEquals(a_mut, b_mut) {
523
662
  case 0:
524
663
  return true;
525
664
  case 1:
526
- return equals(x, y);
665
+ return equals_1(x, y);
527
666
  case 2:
528
667
  return x_1 === y_1;
529
668
  case 3:
@@ -711,7 +850,7 @@ function valueEquals(a_mut, b_mut) {
711
850
  return false;
712
851
  }
713
852
  case 4:
714
- return equals_1(tx_1, ty_1);
853
+ return equals(tx_1, ty_1);
715
854
  case 5:
716
855
  return tx_2 === ty_2;
717
856
  default:
@@ -906,7 +1045,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
906
1045
  case 8:
907
1046
  return undefined;
908
1047
  case 9: {
909
- const resolved = choose(resolve, arguments$);
1048
+ const resolved = choose_1(resolve, arguments$);
910
1049
  if (length(resolved) === length(arguments$)) {
911
1050
  return new Type(/* TApplied */ 13, [name_1, resolved]);
912
1051
  }
@@ -951,7 +1090,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
951
1090
  }
952
1091
  }
953
1092
  case 14: {
954
- const matchValue = equals_1(keyType, new TypeRef(/* TRName */ 0, ["numeric"])) ? Type.TInt : resolve(keyType);
1093
+ const matchValue = equals(keyType, new TypeRef(/* TRName */ 0, ["numeric"])) ? Type.TInt : resolve(keyType);
955
1094
  const matchValue_1 = resolve(valueType);
956
1095
  let matchResult_1, key, value_1;
957
1096
  if (matchValue != null) {
@@ -2056,27 +2195,66 @@ function awaitTaskValue(runtime, taskValue) {
2056
2195
  function applyFunctionValue(runtime, typeDefs, span, fnValue, argValue) {
2057
2196
  checkRuntime(runtime);
2058
2197
  switch (fnValue.tag) {
2059
- case 14:
2060
- if (fnValue.fields[1].tag === 5) {
2061
- return new Execution$1(new Value(/* VClosure */ 14, [fnValue.fields[1].fields[0].Name, fnValue.fields[1].fields[1], new FSharpRef(FSharpMap__Add(fnValue.fields[2].contents, fnValue.fields[0], argValue))]), defaultOf());
2198
+ case 14: {
2199
+ const scope = FSharpMap__Add(fnValue.fields[2].contents, fnValue.fields[0], argValue);
2200
+ const matchValue = closureBody(fnValue.fields[1]);
2201
+ if (matchValue.tag === 7) {
2202
+ return new Execution$1(new Value(/* VClosure */ 14, [matchValue.fields[0].Name, matchValue.fields[1], new FSharpRef(scope)]), defaultOf());
2062
2203
  }
2063
2204
  else {
2064
- return evalExpr(runtime, typeDefs, FSharpMap__Add(fnValue.fields[2].contents, fnValue.fields[0], argValue), fnValue.fields[1]);
2205
+ return evalExpr(runtime, typeDefs, scope, matchValue);
2065
2206
  }
2207
+ }
2066
2208
  case 11:
2067
2209
  return new Execution$1(new Value(/* VUnionCase */ 10, [fnValue.fields[0], fnValue.fields[1], argValue]), defaultOf());
2068
2210
  case 15: {
2069
- const arguments$ = cons(argValue, fnValue.fields[1]);
2070
- if (length(arguments$) === fnValue.fields[0].Arity) {
2071
- return invokeExternal(runtime, typeDefs, span, fnValue.fields[0], reverse(arguments$));
2211
+ const ext = fnValue.fields[0];
2212
+ const second = () => {
2213
+ const arguments$ = cons(argValue, fnValue.fields[1]);
2214
+ if (length(arguments$) === ext.Arity) {
2215
+ return invokeExternal(runtime, typeDefs, span, ext, reverse(arguments$));
2216
+ }
2217
+ else if (length(arguments$) < ext.Arity) {
2218
+ return new Execution$1(new Value(/* VExternal */ 15, [ext, arguments$]), defaultOf());
2219
+ }
2220
+ else {
2221
+ return new Execution$1((() => {
2222
+ throw new EvalException(new EvalError$(concat("External function \'", ext.Name, "\' received too many arguments"), span));
2223
+ })(), defaultOf());
2224
+ }
2225
+ };
2226
+ let body_4;
2227
+ if ((ext.Name === JsonDeserialization_name) && equals(ext.Scheme, JsonDeserialization_scheme)) {
2228
+ throw new EvalException(new EvalError$("Json.deserialize requires a concrete target type", span));
2229
+ body_4 = (new Execution$1(undefined, defaultOf()));
2230
+ }
2231
+ else {
2232
+ body_4 = (new Execution$1(undefined, defaultOf()));
2072
2233
  }
2073
- else if (length(arguments$) < fnValue.fields[0].Arity) {
2074
- return new Execution$1(new Value(/* VExternal */ 15, [fnValue.fields[0], arguments$]), defaultOf());
2234
+ if (Execution$1__get_IsImmediate(body_4)) {
2235
+ return second();
2075
2236
  }
2076
2237
  else {
2077
- return new Execution$1((() => {
2078
- throw new EvalException(new EvalError$(concat("External function \'", fnValue.fields[0].Name, "\' received too many arguments"), span));
2079
- })(), defaultOf());
2238
+ return new Execution$1(defaultOf(), (continuation) => {
2239
+ const execution_1 = body_4;
2240
+ if (Execution$1__get_IsImmediate(execution_1)) {
2241
+ const execution = second();
2242
+ const continuation_1 = continuation;
2243
+ if (Execution$1__get_IsImmediate(execution)) {
2244
+ return continuation_1(execution.Value);
2245
+ }
2246
+ else {
2247
+ return execution.Resume(continuation_1);
2248
+ }
2249
+ }
2250
+ else {
2251
+ return execution_1.Resume((value_10) => {
2252
+ const execution = second();
2253
+ const continuation_1 = continuation;
2254
+ return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
2255
+ });
2256
+ }
2257
+ });
2080
2258
  }
2081
2259
  }
2082
2260
  default:
@@ -2453,6 +2631,36 @@ function evalExpr(runtime, typeDefs, env, expr) {
2453
2631
  checkRuntime(runtime);
2454
2632
  const immediate = (value) => (new Execution$1(value, defaultOf()));
2455
2633
  switch (expr.tag) {
2634
+ case 4: {
2635
+ const signature = expr.fields[1];
2636
+ const inner = expr.fields[0];
2637
+ const body_1 = evalExpr(runtime, typeDefs, env, inner);
2638
+ if (Execution$1__get_IsImmediate(body_1)) {
2639
+ return new Execution$1(specializeFunction(typeDefs, env, Ast_spanOfExpr(inner), signature, body_1.Value), defaultOf());
2640
+ }
2641
+ else {
2642
+ return new Execution$1(defaultOf(), (continuation) => {
2643
+ const execution_1 = body_1;
2644
+ if (Execution$1__get_IsImmediate(execution_1)) {
2645
+ const execution = new Execution$1(specializeFunction(typeDefs, env, Ast_spanOfExpr(inner), signature, execution_1.Value), defaultOf());
2646
+ const continuation_1 = continuation;
2647
+ if (Execution$1__get_IsImmediate(execution)) {
2648
+ return continuation_1(execution.Value);
2649
+ }
2650
+ else {
2651
+ return execution.Resume(continuation_1);
2652
+ }
2653
+ }
2654
+ else {
2655
+ return execution_1.Resume((value_5) => {
2656
+ const execution = new Execution$1(specializeFunction(typeDefs, env, Ast_spanOfExpr(inner), signature, value_5), defaultOf());
2657
+ const continuation_1 = continuation;
2658
+ return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
2659
+ });
2660
+ }
2661
+ });
2662
+ }
2663
+ }
2456
2664
  case 0:
2457
2665
  return immediate(Value.VUnit);
2458
2666
  case 1:
@@ -2467,11 +2675,11 @@ function evalExpr(runtime, typeDefs, env, expr) {
2467
2675
  return immediate(matchValue);
2468
2676
  }
2469
2677
  }
2470
- case 5:
2678
+ case 7:
2471
2679
  return immediate(new Value(/* VClosure */ 14, [expr.fields[0].Name, expr.fields[1], new FSharpRef(env)]));
2472
- case 28:
2680
+ case 30:
2473
2681
  return immediate(new Value(/* VOption */ 9, [undefined]));
2474
- case 29: {
2682
+ case 31: {
2475
2683
  const name_1 = expr.fields[0];
2476
2684
  const matchValue_1 = FSharpMap__TryFind(typeDefs, name_1);
2477
2685
  if (matchValue_1 == null) {
@@ -2481,7 +2689,7 @@ function evalExpr(runtime, typeDefs, env, expr) {
2481
2689
  return immediate(new Value(/* VTypeToken */ 12, [matchValue_1]));
2482
2690
  }
2483
2691
  }
2484
- case 30: {
2692
+ case 32: {
2485
2693
  const name_2 = expr.fields[0];
2486
2694
  if (FSharpMap__ContainsKey(env, name_2)) {
2487
2695
  return immediate(new Value(/* VString */ 4, [name_2]));
@@ -2502,26 +2710,32 @@ function evalCompound(runtime, typeDefs, env, expr) {
2502
2710
  case 0:
2503
2711
  case 1:
2504
2712
  case 2:
2505
- case 5:
2506
- case 28:
2507
- case 29:
2508
- case 30: {
2713
+ case 7:
2714
+ case 30:
2715
+ case 31:
2716
+ case 32:
2717
+ case 4: {
2509
2718
  matchResult = 22;
2510
2719
  break;
2511
2720
  }
2721
+ case 6: {
2722
+ matchResult = 0;
2723
+ inner = expr.fields[0];
2724
+ break;
2725
+ }
2512
2726
  case 3: {
2513
2727
  matchResult = 0;
2514
2728
  inner = expr.fields[0];
2515
2729
  break;
2516
2730
  }
2517
- case 6: {
2731
+ case 8: {
2518
2732
  matchResult = 1;
2519
2733
  arg = expr.fields[1];
2520
2734
  fn = expr.fields[0];
2521
2735
  span = expr.fields[2];
2522
2736
  break;
2523
2737
  }
2524
- case 7: {
2738
+ case 9: {
2525
2739
  matchResult = 2;
2526
2740
  cond = expr.fields[0];
2527
2741
  no = expr.fields[2];
@@ -2529,13 +2743,13 @@ function evalCompound(runtime, typeDefs, env, expr) {
2529
2743
  yes = expr.fields[1];
2530
2744
  break;
2531
2745
  }
2532
- case 8: {
2746
+ case 10: {
2533
2747
  matchResult = 3;
2534
2748
  span_2 = expr.fields[1];
2535
2749
  valueExpr = expr.fields[0];
2536
2750
  break;
2537
2751
  }
2538
- case 9: {
2752
+ case 11: {
2539
2753
  matchResult = 4;
2540
2754
  body_12 = expr.fields[2];
2541
2755
  name = expr.fields[0];
@@ -2543,7 +2757,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2543
2757
  span_3 = expr.fields[3];
2544
2758
  break;
2545
2759
  }
2546
- case 11: {
2760
+ case 13: {
2547
2761
  matchResult = 5;
2548
2762
  body_18 = expr.fields[2];
2549
2763
  isRec = expr.fields[3];
@@ -2552,7 +2766,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2552
2766
  value_21 = expr.fields[1];
2553
2767
  break;
2554
2768
  }
2555
- case 12: {
2769
+ case 14: {
2556
2770
  matchResult = 6;
2557
2771
  body_23 = expr.fields[2];
2558
2772
  pattern = expr.fields[0];
@@ -2560,81 +2774,81 @@ function evalCompound(runtime, typeDefs, env, expr) {
2560
2774
  value_25 = expr.fields[1];
2561
2775
  break;
2562
2776
  }
2563
- case 13: {
2777
+ case 15: {
2564
2778
  matchResult = 7;
2565
2779
  bindings_1 = expr.fields[0];
2566
2780
  body_27 = expr.fields[1];
2567
2781
  span_6 = expr.fields[2];
2568
2782
  break;
2569
2783
  }
2570
- case 10: {
2784
+ case 12: {
2571
2785
  matchResult = 8;
2572
2786
  cases = expr.fields[1];
2573
2787
  scrutinee = expr.fields[0];
2574
2788
  span_7 = expr.fields[2];
2575
2789
  break;
2576
2790
  }
2577
- case 14: {
2791
+ case 16: {
2578
2792
  matchResult = 9;
2579
2793
  items_1 = expr.fields[0];
2580
2794
  break;
2581
2795
  }
2582
- case 16: {
2796
+ case 18: {
2583
2797
  matchResult = 10;
2584
2798
  items_2 = expr.fields[0];
2585
2799
  break;
2586
2800
  }
2587
- case 15: {
2801
+ case 17: {
2588
2802
  matchResult = 11;
2589
2803
  first_1 = expr.fields[0];
2590
2804
  last = expr.fields[1];
2591
2805
  span_8 = expr.fields[2];
2592
2806
  break;
2593
2807
  }
2594
- case 17: {
2808
+ case 19: {
2595
2809
  matchResult = 12;
2596
2810
  fields = expr.fields[0];
2597
2811
  break;
2598
2812
  }
2599
- case 18: {
2813
+ case 20: {
2600
2814
  matchResult = 12;
2601
2815
  fields = expr.fields[0];
2602
2816
  break;
2603
2817
  }
2604
- case 19: {
2818
+ case 21: {
2605
2819
  matchResult = 13;
2606
2820
  entries_1 = expr.fields[0];
2607
2821
  break;
2608
2822
  }
2609
- case 20: {
2823
+ case 22: {
2610
2824
  matchResult = 14;
2611
2825
  span_9 = expr.fields[2];
2612
2826
  target = expr.fields[0];
2613
2827
  updates = expr.fields[1];
2614
2828
  break;
2615
2829
  }
2616
- case 21: {
2830
+ case 23: {
2617
2831
  matchResult = 15;
2618
2832
  span_10 = expr.fields[2];
2619
2833
  target_1 = expr.fields[0];
2620
2834
  updates_1 = expr.fields[1];
2621
2835
  break;
2622
2836
  }
2623
- case 22: {
2837
+ case 24: {
2624
2838
  matchResult = 16;
2625
2839
  field = expr.fields[1];
2626
2840
  span_11 = expr.fields[2];
2627
2841
  target_2 = expr.fields[0];
2628
2842
  break;
2629
2843
  }
2630
- case 23: {
2844
+ case 25: {
2631
2845
  matchResult = 17;
2632
2846
  keyExpr_1 = expr.fields[1];
2633
2847
  span_12 = expr.fields[2];
2634
2848
  target_3 = expr.fields[0];
2635
2849
  break;
2636
2850
  }
2637
- case 26: {
2851
+ case 28: {
2638
2852
  switch (expr.fields[0]) {
2639
2853
  case "&&": {
2640
2854
  matchResult = 18;
@@ -2661,26 +2875,26 @@ function evalCompound(runtime, typeDefs, env, expr) {
2661
2875
  }
2662
2876
  break;
2663
2877
  }
2664
- case 24: {
2878
+ case 26: {
2665
2879
  matchResult = 19;
2666
2880
  a_3 = expr.fields[0];
2667
2881
  b_2 = expr.fields[1];
2668
2882
  span_14 = expr.fields[2];
2669
2883
  break;
2670
2884
  }
2671
- case 25: {
2885
+ case 27: {
2672
2886
  matchResult = 19;
2673
2887
  a_3 = expr.fields[0];
2674
2888
  b_2 = expr.fields[1];
2675
2889
  span_14 = expr.fields[2];
2676
2890
  break;
2677
2891
  }
2678
- case 27: {
2892
+ case 29: {
2679
2893
  matchResult = 20;
2680
2894
  value_113 = expr.fields[0];
2681
2895
  break;
2682
2896
  }
2683
- case 31: {
2897
+ case 33: {
2684
2898
  matchResult = 21;
2685
2899
  parts = expr.fields[0];
2686
2900
  break;
@@ -3101,7 +3315,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
3101
3315
  }
3102
3316
  case 5:
3103
3317
  if (isRec) {
3104
- if (value_21.tag === 5) {
3318
+ if (value_21.tag === 7) {
3105
3319
  const recEnv = new FSharpRef(env);
3106
3320
  recEnv.contents = FSharpMap__Add(env, name_1, new Value(/* VClosure */ 14, [value_21.fields[0].Name, value_21.fields[1], recEnv]));
3107
3321
  return evalExpr(runtime, typeDefs, recEnv.contents, body_18);
@@ -3187,13 +3401,8 @@ function evalCompound(runtime, typeDefs, env, expr) {
3187
3401
  case 7: {
3188
3402
  const recEnv_1 = new FSharpRef(env);
3189
3403
  const entries = map_1((tupledArg) => {
3190
- const args = tupledArg[1];
3191
- const bindingSpan = tupledArg[4];
3192
- if (isEmpty(args)) {
3193
- throw new EvalException(new EvalError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
3194
- }
3195
- const matchValue_1 = foldBack((arg_1, acc) => (new Expr(/* ELambda */ 5, [arg_1, acc, bindingSpan])), args, tupledArg[3]);
3196
- if (matchValue_1.tag === 5) {
3404
+ const matchValue_1 = foldBack((arg_1, acc) => (new Expr(/* ELambda */ 7, [arg_1, acc, tupledArg[4]])), tupledArg[1], tupledArg[3]);
3405
+ if (matchValue_1.tag === 7) {
3197
3406
  return [tupledArg[0], new Value(/* VClosure */ 14, [matchValue_1.fields[0].Name, matchValue_1.fields[1], recEnv_1])];
3198
3407
  }
3199
3408
  else {
@@ -4338,7 +4547,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4338
4547
  }
4339
4548
  break;
4340
4549
  }
4341
- case 22: {
4550
+ case 24: {
4342
4551
  matchResult_13 = 2;
4343
4552
  name_8 = _arg_22.fields[1];
4344
4553
  parent = _arg_22.fields[0];
@@ -4552,7 +4761,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4552
4761
  while (true) {
4553
4762
  const items_5 = items_5_mut, current_1 = current_1_mut;
4554
4763
  if (!isEmpty(items_5)) {
4555
- if (equals(current_1, index)) {
4764
+ if (equals_1(current_1, index)) {
4556
4765
  return some(head_1(items_5));
4557
4766
  }
4558
4767
  else {
@@ -4646,7 +4855,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4646
4855
  while (true) {
4647
4856
  const items_5 = items_5_mut_1, current_1 = current_1_mut_1;
4648
4857
  if (!isEmpty(items_5)) {
4649
- if (equals(current_1, index)) {
4858
+ if (equals_1(current_1, index)) {
4650
4859
  return some(head_1(items_5));
4651
4860
  }
4652
4861
  else {
@@ -4752,7 +4961,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4752
4961
  while (true) {
4753
4962
  const items_5 = items_5_mut_2, current_1 = current_1_mut_2;
4754
4963
  if (!isEmpty(items_5)) {
4755
- if (equals(current_1, index)) {
4964
+ if (equals_1(current_1, index)) {
4756
4965
  return some(head_1(items_5));
4757
4966
  }
4758
4967
  else {
@@ -4862,7 +5071,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4862
5071
  while (true) {
4863
5072
  const items_5 = items_5_mut_3, current_1 = current_1_mut_3;
4864
5073
  if (!isEmpty(items_5)) {
4865
- if (equals(current_1, index)) {
5074
+ if (equals_1(current_1, index)) {
4866
5075
  return some(head_1(items_5));
4867
5076
  }
4868
5077
  else {
@@ -4963,7 +5172,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4963
5172
  while (true) {
4964
5173
  const items_5 = items_5_mut_4, current_1 = current_1_mut_4;
4965
5174
  if (!isEmpty(items_5)) {
4966
- if (equals(current_1, index)) {
5175
+ if (equals_1(current_1, index)) {
4967
5176
  return some(head_1(items_5));
4968
5177
  }
4969
5178
  else {
@@ -5069,7 +5278,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5069
5278
  while (true) {
5070
5279
  const items_5 = items_5_mut_5, current_1 = current_1_mut_5;
5071
5280
  if (!isEmpty(items_5)) {
5072
- if (equals(current_1, index)) {
5281
+ if (equals_1(current_1, index)) {
5073
5282
  return some(head_1(items_5));
5074
5283
  }
5075
5284
  else {
@@ -5184,7 +5393,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5184
5393
  while (true) {
5185
5394
  const items_5 = items_5_mut_6, current_1 = current_1_mut_6;
5186
5395
  if (!isEmpty(items_5)) {
5187
- if (equals(current_1, index)) {
5396
+ if (equals_1(current_1, index)) {
5188
5397
  return some(head_1(items_5));
5189
5398
  }
5190
5399
  else {
@@ -5285,7 +5494,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5285
5494
  while (true) {
5286
5495
  const items_5 = items_5_mut_7, current_1 = current_1_mut_7;
5287
5496
  if (!isEmpty(items_5)) {
5288
- if (equals(current_1, index)) {
5497
+ if (equals_1(current_1, index)) {
5289
5498
  return some(head_1(items_5));
5290
5499
  }
5291
5500
  else {
@@ -5391,7 +5600,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5391
5600
  while (true) {
5392
5601
  const items_5 = items_5_mut_8, current_1 = current_1_mut_8;
5393
5602
  if (!isEmpty(items_5)) {
5394
- if (equals(current_1, index)) {
5603
+ if (equals_1(current_1, index)) {
5395
5604
  return some(head_1(items_5));
5396
5605
  }
5397
5606
  else {
@@ -5634,7 +5843,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5634
5843
  const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5635
5844
  if (Execution$1__get_IsImmediate(body_72)) {
5636
5845
  const bv = body_72.Value;
5637
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5846
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5638
5847
  if (op_2 === "|>") {
5639
5848
  return applyFunctionValue(runtime, typeDefs, span_14, bv, av);
5640
5849
  }
@@ -5648,7 +5857,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5648
5857
  if (Execution$1__get_IsImmediate(execution_53)) {
5649
5858
  let execution_52;
5650
5859
  const bv = execution_53.Value;
5651
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5860
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5652
5861
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5653
5862
  const continuation_79 = continuation_78;
5654
5863
  if (Execution$1__get_IsImmediate(execution_52)) {
@@ -5662,7 +5871,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5662
5871
  return execution_53.Resume((value_111) => {
5663
5872
  let execution_52;
5664
5873
  const bv = value_111;
5665
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5874
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5666
5875
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5667
5876
  const continuation_79 = continuation_78;
5668
5877
  return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
@@ -5680,7 +5889,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5680
5889
  const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5681
5890
  if (Execution$1__get_IsImmediate(body_72)) {
5682
5891
  const bv = body_72.Value;
5683
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5892
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5684
5893
  execution_54 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5685
5894
  }
5686
5895
  else {
@@ -5689,7 +5898,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5689
5898
  if (Execution$1__get_IsImmediate(execution_53)) {
5690
5899
  let execution_52;
5691
5900
  const bv = execution_53.Value;
5692
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5901
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5693
5902
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5694
5903
  const continuation_79 = continuation_78;
5695
5904
  if (Execution$1__get_IsImmediate(execution_52)) {
@@ -5703,7 +5912,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5703
5912
  return execution_53.Resume((value_111) => {
5704
5913
  let execution_52;
5705
5914
  const bv = value_111;
5706
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5915
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5707
5916
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5708
5917
  const continuation_79 = continuation_78;
5709
5918
  return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
@@ -5726,7 +5935,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5726
5935
  const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5727
5936
  if (Execution$1__get_IsImmediate(body_72)) {
5728
5937
  const bv = body_72.Value;
5729
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5938
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5730
5939
  execution_54 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5731
5940
  }
5732
5941
  else {
@@ -5735,7 +5944,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5735
5944
  if (Execution$1__get_IsImmediate(execution_53)) {
5736
5945
  let execution_52;
5737
5946
  const bv = execution_53.Value;
5738
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5947
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5739
5948
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5740
5949
  const continuation_79 = continuation_78;
5741
5950
  if (Execution$1__get_IsImmediate(execution_52)) {
@@ -5749,7 +5958,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
5749
5958
  return execution_53.Resume((value_111) => {
5750
5959
  let execution_52;
5751
5960
  const bv = value_111;
5752
- const op_2 = (expr.tag === 24) ? "::" : ((expr.tag === 25) ? "@" : ((expr.tag === 26) ? expr.fields[0] : ""));
5961
+ const op_2 = (expr.tag === 26) ? "::" : ((expr.tag === 27) ? "@" : ((expr.tag === 28) ? expr.fields[0] : ""));
5753
5962
  execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5754
5963
  const continuation_79 = continuation_78;
5755
5964
  return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
@@ -5878,6 +6087,9 @@ export function invokeValueWithPermissionsAndExitCode(permissions, typeDefs, fnV
5878
6087
  switch (currentValue.tag) {
5879
6088
  case 15: {
5880
6089
  const ext = currentValue.fields[0];
6090
+ if ((ext.Name === JsonDeserialization_name) && equals(ext.Scheme, JsonDeserialization_scheme)) {
6091
+ throw new EvalException(new EvalError$("Json.deserialize requires a concrete target type", unknownSpan));
6092
+ }
5881
6093
  const allArgs = append(reverse(currentValue.fields[1]), remainingArgs);
5882
6094
  if (length(allArgs) === ext.Arity) {
5883
6095
  return invoke(typeDefs, ext, createExternContext(runtime, typeDefs, unknownSpan), allArgs);
@@ -5894,13 +6106,14 @@ export function invokeValueWithPermissionsAndExitCode(permissions, typeDefs, fnV
5894
6106
  bindLambdaChain:
5895
6107
  while (true) {
5896
6108
  const envAcc = envAcc_mut, exprAcc = exprAcc_mut, argsAcc = argsAcc_mut;
6109
+ const matchValue_1 = closureBody(exprAcc);
5897
6110
  let matchResult, nextArg, nextBody, param, rest;
5898
- if (exprAcc.tag === 5) {
6111
+ if (matchValue_1.tag === 7) {
5899
6112
  if (!isEmpty(argsAcc)) {
5900
6113
  matchResult = 0;
5901
6114
  nextArg = head_1(argsAcc);
5902
- nextBody = exprAcc.fields[1];
5903
- param = exprAcc.fields[0];
6115
+ nextBody = matchValue_1.fields[1];
6116
+ param = matchValue_1.fields[0];
5904
6117
  rest = tail_2(argsAcc);
5905
6118
  }
5906
6119
  else {
@@ -6041,7 +6254,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
6041
6254
  const name_1 = stmt.fields[0];
6042
6255
  const expr = stmt.fields[1];
6043
6256
  if (stmt.fields[3]) {
6044
- if (expr.tag === 5) {
6257
+ if (expr.tag === 7) {
6045
6258
  const recEnv = new FSharpRef(env);
6046
6259
  const finalEnv = add_1(name_1, new Value(/* VClosure */ 14, [expr.fields[0].Name, expr.fields[1], recEnv]), env);
6047
6260
  recEnv.contents = finalEnv;
@@ -6075,7 +6288,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
6075
6288
  let finalEnv_1;
6076
6289
  const list_1 = map_1((tupledArg) => {
6077
6290
  const expr_2 = tupledArg[1];
6078
- if (expr_2.tag === 5) {
6291
+ if (expr_2.tag === 7) {
6079
6292
  return [tupledArg[0], new Value(/* VClosure */ 14, [expr_2.fields[0].Name, expr_2.fields[1], recEnv_1])];
6080
6293
  }
6081
6294
  else {
@@ -6117,7 +6330,7 @@ function evaluateRegistered(registration, program) {
6117
6330
  if (option_1 != null) {
6118
6331
  throw new EvalException(new EvalError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
6119
6332
  }
6120
- const decls = ofList(append(map_1((def) => [def.Name, def], typeDefs_2), choose((_arg) => {
6333
+ const decls = ofList(append(map_1((def) => [def.Name, def], typeDefs_2), choose_1((_arg) => {
6121
6334
  if (_arg.tag === 0) {
6122
6335
  const def_1 = _arg.fields[0];
6123
6336
  return [def_1.Name, def_1];