@magnusopera/fscript 0.83.2 → 0.84.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,8 +1,8 @@
1
1
 
2
2
  import { toString, FSharpRef, Record } from "../fable_modules/fable-library-js.5.13.0/Types.js";
3
- import { option_type, array_type, bool_type, obj_type, record_type, class_type, string_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
4
- import { Type, Types_typeToString, Type_$reflection } from "./Types.js";
5
- import { ExternalCallContext, MapKey, Value, TaskHandle_$reflection, Value_$reflection } from "./Value.js";
3
+ import { option_type, array_type, bool_type, obj_type, record_type, int32_type, class_type, string_type } from "../fable_modules/fable-library-js.5.13.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";
6
6
  import { EvalException, EvalError$, EvalError$_$reflection } from "./Error.js";
7
7
  import { Span, Position } from "./Span.js";
8
8
  import { printf, toText, join, concat } from "../fable_modules/fable-library-js.5.13.0/String.js";
@@ -23,22 +23,36 @@ import { builtinReservedNames } from "./BuiltinSignatures.js";
23
23
  import { typeDefs as typeDefs_2 } from "./BuiltinTypes.js";
24
24
 
25
25
  export class ProgramState extends Record {
26
- constructor(TypeDefs, Env, LastValue) {
26
+ constructor(TypeDefs, Env, LastValue, ExitCode) {
27
27
  super();
28
28
  this.TypeDefs = TypeDefs;
29
29
  this.Env = Env;
30
30
  this.LastValue = LastValue;
31
+ this.ExitCode = (ExitCode | 0);
31
32
  }
32
33
  }
33
34
 
34
35
  export function ProgramState_$reflection() {
35
- return record_type("FScript.Language.Eval.ProgramState", [], ProgramState, () => [["TypeDefs", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Type_$reflection()])], ["Env", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Value_$reflection()])], ["LastValue", Value_$reflection()]]);
36
+ return record_type("FScript.Language.Eval.ProgramState", [], ProgramState, () => [["TypeDefs", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Type_$reflection()])], ["Env", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Value_$reflection()])], ["LastValue", Value_$reflection()], ["ExitCode", int32_type]]);
37
+ }
38
+
39
+ export class InvocationResult extends Record {
40
+ constructor(Value, ExitCode) {
41
+ super();
42
+ this.Value = Value;
43
+ this.ExitCode = (ExitCode | 0);
44
+ }
45
+ }
46
+
47
+ export function InvocationResult_$reflection() {
48
+ return record_type("FScript.Language.Eval.InvocationResult", [], InvocationResult, () => [["Value", Value_$reflection()], ["ExitCode", int32_type]]);
36
49
  }
37
50
 
38
51
  class RuntimeState extends Record {
39
- constructor(SyncRoot, Active, PendingTasks, BackgroundFailure) {
52
+ constructor(SyncRoot, ExitCode, Active, PendingTasks, BackgroundFailure) {
40
53
  super();
41
54
  this.SyncRoot = SyncRoot;
55
+ this.ExitCode = ExitCode;
42
56
  this.Active = Active;
43
57
  this.PendingTasks = PendingTasks;
44
58
  this.BackgroundFailure = BackgroundFailure;
@@ -46,7 +60,7 @@ class RuntimeState extends Record {
46
60
  }
47
61
 
48
62
  function RuntimeState_$reflection() {
49
- return record_type("FScript.Language.Eval.RuntimeState", [], RuntimeState, () => [["SyncRoot", obj_type], ["Active", record_type("Microsoft.FSharp.Core.FSharpRef`1", [bool_type], FSharpRef, () => [["contents", bool_type]])], ["PendingTasks", array_type(TaskHandle_$reflection())], ["BackgroundFailure", record_type("Microsoft.FSharp.Core.FSharpRef`1", [option_type(EvalError$_$reflection())], FSharpRef, () => [["contents", option_type(EvalError$_$reflection())]])]]);
63
+ return record_type("FScript.Language.Eval.RuntimeState", [], RuntimeState, () => [["SyncRoot", obj_type], ["ExitCode", record_type("Microsoft.FSharp.Core.FSharpRef`1", [int32_type], FSharpRef, () => [["contents", int32_type]])], ["Active", record_type("Microsoft.FSharp.Core.FSharpRef`1", [bool_type], FSharpRef, () => [["contents", bool_type]])], ["PendingTasks", array_type(TaskHandle_$reflection())], ["BackgroundFailure", record_type("Microsoft.FSharp.Core.FSharpRef`1", [option_type(EvalError$_$reflection())], FSharpRef, () => [["contents", option_type(EvalError$_$reflection())]])]]);
50
64
  }
51
65
 
52
66
  const unknownSpan = new Span(new Position(undefined, 0, 0), new Position(undefined, 0, 0));
@@ -1834,6 +1848,7 @@ function binaryOperator(span, op, av, bv) {
1834
1848
  function createExternContext(runtime, typeDefs, span) {
1835
1849
  return new ExternalCallContext(runtime.SyncRoot, () => runtime.Active.contents, (f_1, a) => Execution_run(applyFunctionValue(runtime, typeDefs, span, f_1, a)), (thunk) => spawnTaskValue(runtime, typeDefs, thunk), (taskValue) => awaitTaskValue(runtime, taskValue), () => {
1836
1850
  raiseIfBackgroundFailed(runtime);
1851
+ }, (value) => {
1837
1852
  });
1838
1853
  }
1839
1854
 
@@ -2290,131 +2305,200 @@ function evalExpr(runtime, typeDefs, env, expr) {
2290
2305
  }
2291
2306
 
2292
2307
  function evalCompound(runtime, typeDefs, env, expr) {
2293
- let matchResult, fields, a_2, b_1, span_13;
2308
+ let value_97;
2309
+ let matchResult, inner, arg, fn, span, cond, no, span_1, yes, span_2, valueExpr, body_12, name, source, span_3, body_18, isRec, name_1, span_4, value_21, body_23, pattern, span_5, value_25, bindings_1, body_27, span_6, cases, scrutinee, span_7, items_1, items_2, first_1, last, span_8, fields, entries_1, span_9, target, updates, span_10, target_1, updates_1, field, span_11, target_2, keyExpr_1, span_12, target_3, a_2, b_1, op, span_13, a_3, b_2, span_14, value_113, parts;
2294
2310
  switch (expr.tag) {
2311
+ case 0:
2312
+ case 1:
2313
+ case 2:
2314
+ case 4:
2315
+ case 27:
2316
+ case 28:
2317
+ case 29: {
2318
+ matchResult = 22;
2319
+ break;
2320
+ }
2295
2321
  case 5: {
2296
2322
  matchResult = 1;
2323
+ arg = expr.fields[1];
2324
+ fn = expr.fields[0];
2325
+ span = expr.fields[2];
2297
2326
  break;
2298
2327
  }
2299
2328
  case 6: {
2300
2329
  matchResult = 2;
2330
+ cond = expr.fields[0];
2331
+ no = expr.fields[2];
2332
+ span_1 = expr.fields[3];
2333
+ yes = expr.fields[1];
2301
2334
  break;
2302
2335
  }
2303
2336
  case 7: {
2304
2337
  matchResult = 3;
2338
+ span_2 = expr.fields[1];
2339
+ valueExpr = expr.fields[0];
2305
2340
  break;
2306
2341
  }
2307
2342
  case 8: {
2308
2343
  matchResult = 4;
2344
+ body_12 = expr.fields[2];
2345
+ name = expr.fields[0];
2346
+ source = expr.fields[1];
2347
+ span_3 = expr.fields[3];
2309
2348
  break;
2310
2349
  }
2311
2350
  case 10: {
2312
2351
  matchResult = 5;
2352
+ body_18 = expr.fields[2];
2353
+ isRec = expr.fields[3];
2354
+ name_1 = expr.fields[0];
2355
+ span_4 = expr.fields[5];
2356
+ value_21 = expr.fields[1];
2313
2357
  break;
2314
2358
  }
2315
2359
  case 11: {
2316
2360
  matchResult = 6;
2361
+ body_23 = expr.fields[2];
2362
+ pattern = expr.fields[0];
2363
+ span_5 = expr.fields[3];
2364
+ value_25 = expr.fields[1];
2317
2365
  break;
2318
2366
  }
2319
2367
  case 12: {
2320
2368
  matchResult = 7;
2369
+ bindings_1 = expr.fields[0];
2370
+ body_27 = expr.fields[1];
2371
+ span_6 = expr.fields[2];
2321
2372
  break;
2322
2373
  }
2323
2374
  case 9: {
2324
2375
  matchResult = 8;
2376
+ cases = expr.fields[1];
2377
+ scrutinee = expr.fields[0];
2378
+ span_7 = expr.fields[2];
2325
2379
  break;
2326
2380
  }
2327
2381
  case 13: {
2328
2382
  matchResult = 9;
2383
+ items_1 = expr.fields[0];
2329
2384
  break;
2330
2385
  }
2331
2386
  case 15: {
2332
2387
  matchResult = 10;
2388
+ items_2 = expr.fields[0];
2333
2389
  break;
2334
2390
  }
2335
2391
  case 14: {
2336
2392
  matchResult = 11;
2393
+ first_1 = expr.fields[0];
2394
+ last = expr.fields[1];
2395
+ span_8 = expr.fields[2];
2396
+ break;
2397
+ }
2398
+ case 16: {
2399
+ matchResult = 12;
2400
+ fields = expr.fields[0];
2401
+ break;
2402
+ }
2403
+ case 17: {
2404
+ matchResult = 12;
2405
+ fields = expr.fields[0];
2337
2406
  break;
2338
2407
  }
2339
2408
  case 18: {
2340
2409
  matchResult = 13;
2410
+ entries_1 = expr.fields[0];
2341
2411
  break;
2342
2412
  }
2343
2413
  case 19: {
2344
2414
  matchResult = 14;
2415
+ span_9 = expr.fields[2];
2416
+ target = expr.fields[0];
2417
+ updates = expr.fields[1];
2345
2418
  break;
2346
2419
  }
2347
2420
  case 20: {
2348
2421
  matchResult = 15;
2422
+ span_10 = expr.fields[2];
2423
+ target_1 = expr.fields[0];
2424
+ updates_1 = expr.fields[1];
2349
2425
  break;
2350
2426
  }
2351
2427
  case 21: {
2352
2428
  matchResult = 16;
2429
+ field = expr.fields[1];
2430
+ span_11 = expr.fields[2];
2431
+ target_2 = expr.fields[0];
2353
2432
  break;
2354
2433
  }
2355
2434
  case 22: {
2356
2435
  matchResult = 17;
2436
+ keyExpr_1 = expr.fields[1];
2437
+ span_12 = expr.fields[2];
2438
+ target_3 = expr.fields[0];
2357
2439
  break;
2358
2440
  }
2359
- case 26: {
2360
- matchResult = 19;
2361
- break;
2362
- }
2363
- case 30: {
2364
- matchResult = 20;
2365
- break;
2366
- }
2367
- case 0:
2368
- case 1:
2369
- case 2:
2370
- case 4:
2371
- case 27:
2372
- case 28:
2373
- case 29: {
2374
- matchResult = 21;
2375
- break;
2376
- }
2377
- case 16: {
2378
- matchResult = 12;
2379
- fields = expr.fields[0];
2380
- break;
2381
- }
2382
- case 17: {
2383
- matchResult = 12;
2384
- fields = expr.fields[0];
2441
+ case 25: {
2442
+ switch (expr.fields[0]) {
2443
+ case "&&": {
2444
+ matchResult = 18;
2445
+ a_2 = expr.fields[1];
2446
+ b_1 = expr.fields[2];
2447
+ op = expr.fields[0];
2448
+ span_13 = expr.fields[3];
2449
+ break;
2450
+ }
2451
+ case "||": {
2452
+ matchResult = 18;
2453
+ a_2 = expr.fields[1];
2454
+ b_1 = expr.fields[2];
2455
+ op = expr.fields[0];
2456
+ span_13 = expr.fields[3];
2457
+ break;
2458
+ }
2459
+ default: {
2460
+ matchResult = 19;
2461
+ a_3 = expr.fields[1];
2462
+ b_2 = expr.fields[2];
2463
+ span_14 = expr.fields[3];
2464
+ }
2465
+ }
2385
2466
  break;
2386
2467
  }
2387
2468
  case 23: {
2388
- matchResult = 18;
2389
- a_2 = expr.fields[0];
2390
- b_1 = expr.fields[1];
2391
- span_13 = expr.fields[2];
2469
+ matchResult = 19;
2470
+ a_3 = expr.fields[0];
2471
+ b_2 = expr.fields[1];
2472
+ span_14 = expr.fields[2];
2392
2473
  break;
2393
2474
  }
2394
2475
  case 24: {
2395
- matchResult = 18;
2396
- a_2 = expr.fields[0];
2397
- b_1 = expr.fields[1];
2398
- span_13 = expr.fields[2];
2476
+ matchResult = 19;
2477
+ a_3 = expr.fields[0];
2478
+ b_2 = expr.fields[1];
2479
+ span_14 = expr.fields[2];
2399
2480
  break;
2400
2481
  }
2401
- case 25: {
2402
- matchResult = 18;
2403
- a_2 = expr.fields[1];
2404
- b_1 = expr.fields[2];
2405
- span_13 = expr.fields[3];
2482
+ case 26: {
2483
+ matchResult = 20;
2484
+ value_113 = expr.fields[0];
2406
2485
  break;
2407
2486
  }
2408
- default:
2487
+ case 30: {
2488
+ matchResult = 21;
2489
+ parts = expr.fields[0];
2490
+ break;
2491
+ }
2492
+ default: {
2409
2493
  matchResult = 0;
2494
+ inner = expr.fields[0];
2495
+ }
2410
2496
  }
2411
2497
  switch (matchResult) {
2412
2498
  case 0:
2413
- return evalExpr(runtime, typeDefs, env, expr.fields[0]);
2499
+ return evalExpr(runtime, typeDefs, env, inner);
2414
2500
  case 1: {
2415
- const span = expr.fields[2];
2416
- const arg = expr.fields[1];
2417
- const body_5 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
2501
+ const body_5 = evalExpr(runtime, typeDefs, env, fn);
2418
2502
  if (Execution$1__get_IsImmediate(body_5)) {
2419
2503
  const f = body_5.Value;
2420
2504
  const body_3 = evalExpr(runtime, typeDefs, env, arg);
@@ -2512,10 +2596,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2512
2596
  }
2513
2597
  }
2514
2598
  case 2: {
2515
- const yes = expr.fields[1];
2516
- const span_1 = expr.fields[3];
2517
- const no = expr.fields[2];
2518
- const body_9 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
2599
+ const body_9 = evalExpr(runtime, typeDefs, env, cond);
2519
2600
  if (Execution$1__get_IsImmediate(body_9)) {
2520
2601
  const value_2 = body_9.Value;
2521
2602
  if (value_2.tag === 3) {
@@ -2564,8 +2645,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2564
2645
  }
2565
2646
  }
2566
2647
  case 3: {
2567
- const span_2 = expr.fields[1];
2568
- const body_11 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
2648
+ const body_11 = evalExpr(runtime, typeDefs, env, valueExpr);
2569
2649
  if (Execution$1__get_IsImmediate(body_11)) {
2570
2650
  const value_6 = body_11.Value;
2571
2651
  if (value_6.tag === 4) {
@@ -2615,10 +2695,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2615
2695
  }
2616
2696
  }
2617
2697
  case 4: {
2618
- const span_3 = expr.fields[3];
2619
- const name = expr.fields[0];
2620
- const body_12 = expr.fields[2];
2621
- const body_17 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
2698
+ const body_17 = evalExpr(runtime, typeDefs, env, source);
2622
2699
  if (Execution$1__get_IsImmediate(body_17)) {
2623
2700
  const value_12 = body_17.Value;
2624
2701
  if (value_12.tag === 5) {
@@ -2826,11 +2903,8 @@ function evalCompound(runtime, typeDefs, env, expr) {
2826
2903
  });
2827
2904
  }
2828
2905
  }
2829
- case 5: {
2830
- const value_21 = expr.fields[1];
2831
- const name_1 = expr.fields[0];
2832
- const body_18 = expr.fields[2];
2833
- if (expr.fields[3]) {
2906
+ case 5:
2907
+ if (isRec) {
2834
2908
  if (value_21.tag === 4) {
2835
2909
  const recEnv = new FSharpRef(env);
2836
2910
  recEnv.contents = FSharpMap__Add(env, name_1, new Value(/* VClosure */ 14, [value_21.fields[0].Name, value_21.fields[1], recEnv]));
@@ -2838,7 +2912,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
2838
2912
  }
2839
2913
  else {
2840
2914
  return new Execution$1((() => {
2841
- throw new EvalException(new EvalError$("let rec requires a function binding", expr.fields[5]));
2915
+ throw new EvalException(new EvalError$("let rec requires a function binding", span_4));
2842
2916
  })(), defaultOf());
2843
2917
  }
2844
2918
  }
@@ -2870,12 +2944,8 @@ function evalCompound(runtime, typeDefs, env, expr) {
2870
2944
  });
2871
2945
  }
2872
2946
  }
2873
- }
2874
2947
  case 6: {
2875
- const span_5 = expr.fields[3];
2876
- const pattern = expr.fields[0];
2877
- const body_23 = expr.fields[2];
2878
- const body_26 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
2948
+ const body_26 = evalExpr(runtime, typeDefs, env, value_25);
2879
2949
  if (Execution$1__get_IsImmediate(body_26)) {
2880
2950
  const matchValue = patternMatch(typeDefs, pattern, body_26.Value);
2881
2951
  if (matchValue == null) {
@@ -2931,16 +3001,14 @@ function evalCompound(runtime, typeDefs, env, expr) {
2931
3001
  return [tupledArg[0], new Value(/* VClosure */ 14, [matchValue_1.fields[0].Name, matchValue_1.fields[1], recEnv_1])];
2932
3002
  }
2933
3003
  else {
2934
- throw new EvalException(new EvalError$("let rec requires a function binding", expr.fields[2]));
3004
+ throw new EvalException(new EvalError$("let rec requires a function binding", span_6));
2935
3005
  }
2936
- }, expr.fields[0]);
3006
+ }, bindings_1);
2937
3007
  recEnv_1.contents = fold_1((state_1, tupledArg_1) => add(tupledArg_1[0], tupledArg_1[1], state_1), env, entries);
2938
- return evalExpr(runtime, typeDefs, recEnv_1.contents, expr.fields[1]);
3008
+ return evalExpr(runtime, typeDefs, recEnv_1.contents, body_27);
2939
3009
  }
2940
3010
  case 8: {
2941
- const span_7 = expr.fields[2];
2942
- const cases = expr.fields[1];
2943
- const body_37 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
3011
+ const body_37 = evalExpr(runtime, typeDefs, env, scrutinee);
2944
3012
  if (Execution$1__get_IsImmediate(body_37)) {
2945
3013
  const tryCases = (cases_1_mut) => {
2946
3014
  tryCases:
@@ -3189,7 +3257,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
3189
3257
  }
3190
3258
  }
3191
3259
  case 9: {
3192
- const body_39 = Execution_map((expr_1) => evalExpr(runtime, typeDefs, env, expr_1), expr.fields[0]);
3260
+ const body_39 = Execution_map((expr_1) => evalExpr(runtime, typeDefs, env, expr_1), items_1);
3193
3261
  if (Execution$1__get_IsImmediate(body_39)) {
3194
3262
  return new Execution$1(new Value(/* VList */ 5, [body_39.Value]), defaultOf());
3195
3263
  }
@@ -3217,7 +3285,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
3217
3285
  }
3218
3286
  }
3219
3287
  case 10: {
3220
- const body_41 = Execution_map((expr_2) => evalExpr(runtime, typeDefs, env, expr_2), expr.fields[0]);
3288
+ const body_41 = Execution_map((expr_2) => evalExpr(runtime, typeDefs, env, expr_2), items_2);
3221
3289
  if (Execution$1__get_IsImmediate(body_41)) {
3222
3290
  return new Execution$1(new Value(/* VTuple */ 6, [body_41.Value]), defaultOf());
3223
3291
  }
@@ -3245,9 +3313,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
3245
3313
  }
3246
3314
  }
3247
3315
  case 11: {
3248
- const span_8 = expr.fields[2];
3249
- const last = expr.fields[1];
3250
- const body_45 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
3316
+ const body_45 = evalExpr(runtime, typeDefs, env, first_1);
3251
3317
  if (Execution$1__get_IsImmediate(body_45)) {
3252
3318
  const a_1 = body_45.Value;
3253
3319
  const body_43 = evalExpr(runtime, typeDefs, env, last);
@@ -4019,7 +4085,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4019
4085
  }
4020
4086
  }, empty_1({
4021
4087
  Compare: (x_1, y_1) => (compare(x_1, y_1) | 0),
4022
- }), expr.fields[0]);
4088
+ }), entries_1);
4023
4089
  if (Execution$1__get_IsImmediate(body_57)) {
4024
4090
  return new Execution$1(new Value(/* VMap */ 8, [body_57.Value]), defaultOf());
4025
4091
  }
@@ -4047,42 +4113,53 @@ function evalCompound(runtime, typeDefs, env, expr) {
4047
4113
  }
4048
4114
  }
4049
4115
  case 14:
4050
- return updateRecord(runtime, typeDefs, env, expr.fields[0], expr.fields[1], expr.fields[2], false);
4116
+ return updateRecord(runtime, typeDefs, env, target, updates, span_9, false);
4051
4117
  case 15:
4052
- return updateRecord(runtime, typeDefs, env, expr.fields[0], expr.fields[1], expr.fields[2], true);
4118
+ return updateRecord(runtime, typeDefs, env, target_1, updates_1, span_10, true);
4053
4119
  case 16: {
4054
- const target_2 = expr.fields[0];
4055
- const span_11 = expr.fields[2];
4056
- const field = expr.fields[1];
4057
4120
  const qualified = (_arg_22) => {
4058
- let matchResult_13, name_6, name_7, parent;
4121
+ let matchResult_13, name_7, name_8, parent;
4059
4122
  switch (_arg_22.tag) {
4060
4123
  case 2: {
4061
- if (!FSharpMap__ContainsKey(env, _arg_22.fields[0])) {
4062
- matchResult_13 = 0;
4063
- name_6 = _arg_22.fields[0];
4124
+ if (_arg_22.fields[0] === "Env") {
4125
+ if (field === "setExitCode") {
4126
+ matchResult_13 = 0;
4127
+ }
4128
+ else if (!FSharpMap__ContainsKey(env, _arg_22.fields[0])) {
4129
+ matchResult_13 = 1;
4130
+ name_7 = _arg_22.fields[0];
4131
+ }
4132
+ else {
4133
+ matchResult_13 = 3;
4134
+ }
4135
+ }
4136
+ else if (!FSharpMap__ContainsKey(env, _arg_22.fields[0])) {
4137
+ matchResult_13 = 1;
4138
+ name_7 = _arg_22.fields[0];
4064
4139
  }
4065
4140
  else {
4066
- matchResult_13 = 2;
4141
+ matchResult_13 = 3;
4067
4142
  }
4068
4143
  break;
4069
4144
  }
4070
4145
  case 21: {
4071
- matchResult_13 = 1;
4072
- name_7 = _arg_22.fields[1];
4146
+ matchResult_13 = 2;
4147
+ name_8 = _arg_22.fields[1];
4073
4148
  parent = _arg_22.fields[0];
4074
4149
  break;
4075
4150
  }
4076
4151
  default:
4077
- matchResult_13 = 2;
4152
+ matchResult_13 = 3;
4078
4153
  }
4079
4154
  switch (matchResult_13) {
4080
4155
  case 0:
4081
- return name_6;
4082
- case 1: {
4156
+ return "Env";
4157
+ case 1:
4158
+ return name_7;
4159
+ case 2: {
4083
4160
  const option_1 = qualified(parent);
4084
4161
  if (option_1 != null) {
4085
- return (option_1 + ".") + name_7;
4162
+ return (option_1 + ".") + name_8;
4086
4163
  }
4087
4164
  else {
4088
4165
  return undefined;
@@ -4218,9 +4295,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
4218
4295
  }
4219
4296
  }
4220
4297
  case 17: {
4221
- const span_12 = expr.fields[2];
4222
- const keyExpr_1 = expr.fields[1];
4223
- const body_65 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
4298
+ const body_65 = evalExpr(runtime, typeDefs, env, target_3);
4224
4299
  if (Execution$1__get_IsImmediate(body_65)) {
4225
4300
  const targetValue = body_65.Value;
4226
4301
  const body_63 = evalExpr(runtime, typeDefs, env, keyExpr_1);
@@ -5173,69 +5248,35 @@ function evalCompound(runtime, typeDefs, env, expr) {
5173
5248
  }
5174
5249
  }
5175
5250
  case 18: {
5176
- const body_70 = evalExpr(runtime, typeDefs, env, a_2);
5177
- if (Execution$1__get_IsImmediate(body_70)) {
5178
- const av = body_70.Value;
5179
- const body_68 = evalExpr(runtime, typeDefs, env, b_1);
5180
- if (Execution$1__get_IsImmediate(body_68)) {
5181
- const bv = body_68.Value;
5182
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5183
- if (op_1 === "|>") {
5184
- return applyFunctionValue(runtime, typeDefs, span_13, bv, av);
5251
+ const body_69 = evalExpr(runtime, typeDefs, env, a_2);
5252
+ if (Execution$1__get_IsImmediate(body_69)) {
5253
+ const first_2 = body_69.Value;
5254
+ if (first_2.tag === 3) {
5255
+ if ((value_97 = first_2.fields[0], ((op === "&&") && !value_97) ? true : ((op === "||") && value_97))) {
5256
+ return new Execution$1(new Value(/* VBool */ 3, [first_2.fields[0]]), defaultOf());
5185
5257
  }
5186
5258
  else {
5187
- return new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf());
5188
- }
5189
- }
5190
- else {
5191
- return new Execution$1(defaultOf(), (continuation_72) => {
5192
- const execution_49 = body_68;
5193
- if (Execution$1__get_IsImmediate(execution_49)) {
5194
- let execution_48;
5195
- const bv = execution_49.Value;
5196
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5197
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5198
- const continuation_73 = continuation_72;
5199
- if (Execution$1__get_IsImmediate(execution_48)) {
5200
- return continuation_73(execution_48.Value);
5259
+ const body_67 = evalExpr(runtime, typeDefs, env, b_1);
5260
+ if (Execution$1__get_IsImmediate(body_67)) {
5261
+ const second_1 = body_67.Value;
5262
+ if (second_1.tag === 3) {
5263
+ return new Execution$1(second_1, defaultOf());
5201
5264
  }
5202
5265
  else {
5203
- return execution_48.Resume(continuation_73);
5266
+ return new Execution$1((() => {
5267
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5268
+ })(), defaultOf());
5204
5269
  }
5205
5270
  }
5206
5271
  else {
5207
- return execution_49.Resume((value_99) => {
5208
- let execution_48;
5209
- const bv = value_99;
5210
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5211
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5212
- const continuation_73 = continuation_72;
5213
- return Execution$1__get_IsImmediate(execution_48) ? continuation_73(execution_48.Value) : execution_48.Resume(continuation_73);
5214
- });
5215
- }
5216
- });
5217
- }
5218
- }
5219
- else {
5220
- return new Execution$1(defaultOf(), (continuation_75) => {
5221
- const execution_51 = body_70;
5222
- if (Execution$1__get_IsImmediate(execution_51)) {
5223
- let execution_50;
5224
- const av = execution_51.Value;
5225
- const body_68 = evalExpr(runtime, typeDefs, env, b_1);
5226
- if (Execution$1__get_IsImmediate(body_68)) {
5227
- const bv = body_68.Value;
5228
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5229
- execution_50 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5230
- }
5231
- else {
5232
- execution_50 = (new Execution$1(defaultOf(), (continuation_72) => {
5233
- const execution_49 = body_68;
5272
+ return new Execution$1(defaultOf(), (continuation_72) => {
5273
+ const execution_49 = body_67;
5234
5274
  if (Execution$1__get_IsImmediate(execution_49)) {
5235
5275
  let execution_48;
5236
- const bv = execution_49.Value;
5237
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5238
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5276
+ const second_1 = execution_49.Value;
5277
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5278
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5279
+ })(), defaultOf())));
5239
5280
  const continuation_73 = continuation_72;
5240
5281
  if (Execution$1__get_IsImmediate(execution_48)) {
5241
5282
  return continuation_73(execution_48.Value);
@@ -5245,16 +5286,81 @@ function evalCompound(runtime, typeDefs, env, expr) {
5245
5286
  }
5246
5287
  }
5247
5288
  else {
5248
- return execution_49.Resume((value_99) => {
5289
+ return execution_49.Resume((value_105) => {
5249
5290
  let execution_48;
5250
- const bv = value_99;
5251
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5252
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5291
+ const second_1 = value_105;
5292
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5293
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5294
+ })(), defaultOf())));
5253
5295
  const continuation_73 = continuation_72;
5254
5296
  return Execution$1__get_IsImmediate(execution_48) ? continuation_73(execution_48.Value) : execution_48.Resume(continuation_73);
5255
5297
  });
5256
5298
  }
5257
- }));
5299
+ });
5300
+ }
5301
+ }
5302
+ }
5303
+ else {
5304
+ return new Execution$1((() => {
5305
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5306
+ })(), defaultOf());
5307
+ }
5308
+ }
5309
+ else {
5310
+ return new Execution$1(defaultOf(), (continuation_75) => {
5311
+ let value_97;
5312
+ const execution_51 = body_69;
5313
+ if (Execution$1__get_IsImmediate(execution_51)) {
5314
+ let execution_50;
5315
+ const first_2 = execution_51.Value;
5316
+ if (first_2.tag === 3) {
5317
+ if ((value_97 = first_2.fields[0], ((op === "&&") && !value_97) ? true : ((op === "||") && value_97))) {
5318
+ execution_50 = (new Execution$1(new Value(/* VBool */ 3, [first_2.fields[0]]), defaultOf()));
5319
+ }
5320
+ else {
5321
+ const body_67 = evalExpr(runtime, typeDefs, env, b_1);
5322
+ if (Execution$1__get_IsImmediate(body_67)) {
5323
+ const second_1 = body_67.Value;
5324
+ execution_50 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5325
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5326
+ })(), defaultOf())));
5327
+ }
5328
+ else {
5329
+ execution_50 = (new Execution$1(defaultOf(), (continuation_72) => {
5330
+ const execution_49 = body_67;
5331
+ if (Execution$1__get_IsImmediate(execution_49)) {
5332
+ let execution_48;
5333
+ const second_1 = execution_49.Value;
5334
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5335
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5336
+ })(), defaultOf())));
5337
+ const continuation_73 = continuation_72;
5338
+ if (Execution$1__get_IsImmediate(execution_48)) {
5339
+ return continuation_73(execution_48.Value);
5340
+ }
5341
+ else {
5342
+ return execution_48.Resume(continuation_73);
5343
+ }
5344
+ }
5345
+ else {
5346
+ return execution_49.Resume((value_105) => {
5347
+ let execution_48;
5348
+ const second_1 = value_105;
5349
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5350
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5351
+ })(), defaultOf())));
5352
+ const continuation_73 = continuation_72;
5353
+ return Execution$1__get_IsImmediate(execution_48) ? continuation_73(execution_48.Value) : execution_48.Resume(continuation_73);
5354
+ });
5355
+ }
5356
+ }));
5357
+ }
5358
+ }
5359
+ }
5360
+ else {
5361
+ execution_50 = (new Execution$1((() => {
5362
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5363
+ })(), defaultOf()));
5258
5364
  }
5259
5365
  const continuation_76 = continuation_75;
5260
5366
  if (Execution$1__get_IsImmediate(execution_50)) {
@@ -5265,111 +5371,264 @@ function evalCompound(runtime, typeDefs, env, expr) {
5265
5371
  }
5266
5372
  }
5267
5373
  else {
5268
- return execution_51.Resume((value_100) => {
5374
+ return execution_51.Resume((value_108) => {
5375
+ let value_97;
5269
5376
  let execution_50;
5270
- const av = value_100;
5271
- const body_68 = evalExpr(runtime, typeDefs, env, b_1);
5272
- if (Execution$1__get_IsImmediate(body_68)) {
5273
- const bv = body_68.Value;
5274
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5275
- execution_50 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5377
+ const first_2 = value_108;
5378
+ if (first_2.tag === 3) {
5379
+ if ((value_97 = first_2.fields[0], ((op === "&&") && !value_97) ? true : ((op === "||") && value_97))) {
5380
+ execution_50 = (new Execution$1(new Value(/* VBool */ 3, [first_2.fields[0]]), defaultOf()));
5381
+ }
5382
+ else {
5383
+ const body_67 = evalExpr(runtime, typeDefs, env, b_1);
5384
+ if (Execution$1__get_IsImmediate(body_67)) {
5385
+ const second_1 = body_67.Value;
5386
+ execution_50 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5387
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5388
+ })(), defaultOf())));
5389
+ }
5390
+ else {
5391
+ execution_50 = (new Execution$1(defaultOf(), (continuation_72) => {
5392
+ const execution_49 = body_67;
5393
+ if (Execution$1__get_IsImmediate(execution_49)) {
5394
+ let execution_48;
5395
+ const second_1 = execution_49.Value;
5396
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5397
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5398
+ })(), defaultOf())));
5399
+ const continuation_73 = continuation_72;
5400
+ if (Execution$1__get_IsImmediate(execution_48)) {
5401
+ return continuation_73(execution_48.Value);
5402
+ }
5403
+ else {
5404
+ return execution_48.Resume(continuation_73);
5405
+ }
5406
+ }
5407
+ else {
5408
+ return execution_49.Resume((value_105) => {
5409
+ let execution_48;
5410
+ const second_1 = value_105;
5411
+ execution_48 = ((second_1.tag === 3) ? (new Execution$1(second_1, defaultOf())) : (new Execution$1((() => {
5412
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5413
+ })(), defaultOf())));
5414
+ const continuation_73 = continuation_72;
5415
+ return Execution$1__get_IsImmediate(execution_48) ? continuation_73(execution_48.Value) : execution_48.Resume(continuation_73);
5416
+ });
5417
+ }
5418
+ }));
5419
+ }
5420
+ }
5276
5421
  }
5277
5422
  else {
5278
- execution_50 = (new Execution$1(defaultOf(), (continuation_72) => {
5279
- const execution_49 = body_68;
5280
- if (Execution$1__get_IsImmediate(execution_49)) {
5281
- let execution_48;
5282
- const bv = execution_49.Value;
5283
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5284
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5285
- const continuation_73 = continuation_72;
5286
- if (Execution$1__get_IsImmediate(execution_48)) {
5287
- return continuation_73(execution_48.Value);
5423
+ execution_50 = (new Execution$1((() => {
5424
+ throw new EvalException(new EvalError$("Boolean operands required", span_13));
5425
+ })(), defaultOf()));
5426
+ }
5427
+ const continuation_76 = continuation_75;
5428
+ return Execution$1__get_IsImmediate(execution_50) ? continuation_76(execution_50.Value) : execution_50.Resume(continuation_76);
5429
+ });
5430
+ }
5431
+ });
5432
+ }
5433
+ }
5434
+ case 19: {
5435
+ const body_74 = evalExpr(runtime, typeDefs, env, a_3);
5436
+ if (Execution$1__get_IsImmediate(body_74)) {
5437
+ const av = body_74.Value;
5438
+ const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5439
+ if (Execution$1__get_IsImmediate(body_72)) {
5440
+ const bv = body_72.Value;
5441
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5442
+ if (op_2 === "|>") {
5443
+ return applyFunctionValue(runtime, typeDefs, span_14, bv, av);
5444
+ }
5445
+ else {
5446
+ return new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf());
5447
+ }
5448
+ }
5449
+ else {
5450
+ return new Execution$1(defaultOf(), (continuation_78) => {
5451
+ const execution_53 = body_72;
5452
+ if (Execution$1__get_IsImmediate(execution_53)) {
5453
+ let execution_52;
5454
+ const bv = execution_53.Value;
5455
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5456
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5457
+ const continuation_79 = continuation_78;
5458
+ if (Execution$1__get_IsImmediate(execution_52)) {
5459
+ return continuation_79(execution_52.Value);
5460
+ }
5461
+ else {
5462
+ return execution_52.Resume(continuation_79);
5463
+ }
5464
+ }
5465
+ else {
5466
+ return execution_53.Resume((value_111) => {
5467
+ let execution_52;
5468
+ const bv = value_111;
5469
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5470
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5471
+ const continuation_79 = continuation_78;
5472
+ return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
5473
+ });
5474
+ }
5475
+ });
5476
+ }
5477
+ }
5478
+ else {
5479
+ return new Execution$1(defaultOf(), (continuation_81) => {
5480
+ const execution_55 = body_74;
5481
+ if (Execution$1__get_IsImmediate(execution_55)) {
5482
+ let execution_54;
5483
+ const av = execution_55.Value;
5484
+ const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5485
+ if (Execution$1__get_IsImmediate(body_72)) {
5486
+ const bv = body_72.Value;
5487
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5488
+ execution_54 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5489
+ }
5490
+ else {
5491
+ execution_54 = (new Execution$1(defaultOf(), (continuation_78) => {
5492
+ const execution_53 = body_72;
5493
+ if (Execution$1__get_IsImmediate(execution_53)) {
5494
+ let execution_52;
5495
+ const bv = execution_53.Value;
5496
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5497
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5498
+ const continuation_79 = continuation_78;
5499
+ if (Execution$1__get_IsImmediate(execution_52)) {
5500
+ return continuation_79(execution_52.Value);
5501
+ }
5502
+ else {
5503
+ return execution_52.Resume(continuation_79);
5504
+ }
5505
+ }
5506
+ else {
5507
+ return execution_53.Resume((value_111) => {
5508
+ let execution_52;
5509
+ const bv = value_111;
5510
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5511
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5512
+ const continuation_79 = continuation_78;
5513
+ return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
5514
+ });
5515
+ }
5516
+ }));
5517
+ }
5518
+ const continuation_82 = continuation_81;
5519
+ if (Execution$1__get_IsImmediate(execution_54)) {
5520
+ return continuation_82(execution_54.Value);
5521
+ }
5522
+ else {
5523
+ return execution_54.Resume(continuation_82);
5524
+ }
5525
+ }
5526
+ else {
5527
+ return execution_55.Resume((value_112) => {
5528
+ let execution_54;
5529
+ const av = value_112;
5530
+ const body_72 = evalExpr(runtime, typeDefs, env, b_2);
5531
+ if (Execution$1__get_IsImmediate(body_72)) {
5532
+ const bv = body_72.Value;
5533
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5534
+ execution_54 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5535
+ }
5536
+ else {
5537
+ execution_54 = (new Execution$1(defaultOf(), (continuation_78) => {
5538
+ const execution_53 = body_72;
5539
+ if (Execution$1__get_IsImmediate(execution_53)) {
5540
+ let execution_52;
5541
+ const bv = execution_53.Value;
5542
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5543
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5544
+ const continuation_79 = continuation_78;
5545
+ if (Execution$1__get_IsImmediate(execution_52)) {
5546
+ return continuation_79(execution_52.Value);
5288
5547
  }
5289
5548
  else {
5290
- return execution_48.Resume(continuation_73);
5549
+ return execution_52.Resume(continuation_79);
5291
5550
  }
5292
5551
  }
5293
5552
  else {
5294
- return execution_49.Resume((value_99) => {
5295
- let execution_48;
5296
- const bv = value_99;
5297
- const op_1 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5298
- execution_48 = ((op_1 === "|>") ? applyFunctionValue(runtime, typeDefs, span_13, bv, av) : (new Execution$1(binaryOperator(span_13, op_1, av, bv), defaultOf())));
5299
- const continuation_73 = continuation_72;
5300
- return Execution$1__get_IsImmediate(execution_48) ? continuation_73(execution_48.Value) : execution_48.Resume(continuation_73);
5553
+ return execution_53.Resume((value_111) => {
5554
+ let execution_52;
5555
+ const bv = value_111;
5556
+ const op_2 = (expr.tag === 23) ? "::" : ((expr.tag === 24) ? "@" : ((expr.tag === 25) ? expr.fields[0] : ""));
5557
+ execution_52 = ((op_2 === "|>") ? applyFunctionValue(runtime, typeDefs, span_14, bv, av) : (new Execution$1(binaryOperator(span_14, op_2, av, bv), defaultOf())));
5558
+ const continuation_79 = continuation_78;
5559
+ return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
5301
5560
  });
5302
5561
  }
5303
5562
  }));
5304
5563
  }
5305
- const continuation_76 = continuation_75;
5306
- return Execution$1__get_IsImmediate(execution_50) ? continuation_76(execution_50.Value) : execution_50.Resume(continuation_76);
5564
+ const continuation_82 = continuation_81;
5565
+ return Execution$1__get_IsImmediate(execution_54) ? continuation_82(execution_54.Value) : execution_54.Resume(continuation_82);
5307
5566
  });
5308
5567
  }
5309
5568
  });
5310
5569
  }
5311
5570
  }
5312
- case 19: {
5313
- const body_72 = evalExpr(runtime, typeDefs, env, expr.fields[0]);
5314
- if (Execution$1__get_IsImmediate(body_72)) {
5315
- return new Execution$1(new Value(/* VOption */ 9, [body_72.Value]), defaultOf());
5571
+ case 20: {
5572
+ const body_76 = evalExpr(runtime, typeDefs, env, value_113);
5573
+ if (Execution$1__get_IsImmediate(body_76)) {
5574
+ return new Execution$1(new Value(/* VOption */ 9, [body_76.Value]), defaultOf());
5316
5575
  }
5317
5576
  else {
5318
- return new Execution$1(defaultOf(), (continuation_78) => {
5319
- const execution_53 = body_72;
5320
- if (Execution$1__get_IsImmediate(execution_53)) {
5321
- const execution_52 = new Execution$1(new Value(/* VOption */ 9, [execution_53.Value]), defaultOf());
5322
- const continuation_79 = continuation_78;
5323
- if (Execution$1__get_IsImmediate(execution_52)) {
5324
- return continuation_79(execution_52.Value);
5577
+ return new Execution$1(defaultOf(), (continuation_84) => {
5578
+ const execution_57 = body_76;
5579
+ if (Execution$1__get_IsImmediate(execution_57)) {
5580
+ const execution_56 = new Execution$1(new Value(/* VOption */ 9, [execution_57.Value]), defaultOf());
5581
+ const continuation_85 = continuation_84;
5582
+ if (Execution$1__get_IsImmediate(execution_56)) {
5583
+ return continuation_85(execution_56.Value);
5325
5584
  }
5326
5585
  else {
5327
- return execution_52.Resume(continuation_79);
5586
+ return execution_56.Resume(continuation_85);
5328
5587
  }
5329
5588
  }
5330
5589
  else {
5331
- return execution_53.Resume((value_104) => {
5332
- const execution_52 = new Execution$1(new Value(/* VOption */ 9, [value_104]), defaultOf());
5333
- const continuation_79 = continuation_78;
5334
- return Execution$1__get_IsImmediate(execution_52) ? continuation_79(execution_52.Value) : execution_52.Resume(continuation_79);
5590
+ return execution_57.Resume((value_116) => {
5591
+ const execution_56 = new Execution$1(new Value(/* VOption */ 9, [value_116]), defaultOf());
5592
+ const continuation_85 = continuation_84;
5593
+ return Execution$1__get_IsImmediate(execution_56) ? continuation_85(execution_56.Value) : execution_56.Resume(continuation_85);
5335
5594
  });
5336
5595
  }
5337
5596
  });
5338
5597
  }
5339
5598
  }
5340
- case 20: {
5599
+ case 21: {
5341
5600
  const sb = StringBuilder_$ctor();
5342
- const second_1 = () => (new Execution$1(new Value(/* VString */ 4, [toString(sb)]), defaultOf()));
5343
- const body_75 = Execution_Builder__For_Z3A5BE4A(Execution_execution, expr.fields[0], (_arg_29) => {
5344
- const part = _arg_29;
5601
+ const second_2 = () => (new Execution$1(new Value(/* VString */ 4, [toString(sb)]), defaultOf()));
5602
+ const body_79 = Execution_Builder__For_Z3A5BE4A(Execution_execution, parts, (_arg_31) => {
5603
+ const part = _arg_31;
5345
5604
  if (part.tag === 1) {
5346
- const body_74 = evalExpr(runtime, typeDefs, env, part.fields[0]);
5347
- if (Execution$1__get_IsImmediate(body_74)) {
5348
- StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(body_74.Value));
5605
+ const body_78 = evalExpr(runtime, typeDefs, env, part.fields[0]);
5606
+ if (Execution$1__get_IsImmediate(body_78)) {
5607
+ StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(body_78.Value));
5349
5608
  return new Execution$1(undefined, defaultOf());
5350
5609
  }
5351
5610
  else {
5352
- return new Execution$1(defaultOf(), (continuation_81) => {
5353
- const execution_55 = body_74;
5354
- if (Execution$1__get_IsImmediate(execution_55)) {
5355
- let execution_54;
5356
- StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(execution_55.Value));
5357
- execution_54 = (new Execution$1(undefined, defaultOf()));
5358
- const continuation_82 = continuation_81;
5359
- if (Execution$1__get_IsImmediate(execution_54)) {
5360
- return continuation_82(execution_54.Value);
5611
+ return new Execution$1(defaultOf(), (continuation_87) => {
5612
+ const execution_59 = body_78;
5613
+ if (Execution$1__get_IsImmediate(execution_59)) {
5614
+ let execution_58;
5615
+ StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(execution_59.Value));
5616
+ execution_58 = (new Execution$1(undefined, defaultOf()));
5617
+ const continuation_88 = continuation_87;
5618
+ if (Execution$1__get_IsImmediate(execution_58)) {
5619
+ return continuation_88(execution_58.Value);
5361
5620
  }
5362
5621
  else {
5363
- return execution_54.Resume(continuation_82);
5622
+ return execution_58.Resume(continuation_88);
5364
5623
  }
5365
5624
  }
5366
5625
  else {
5367
- return execution_55.Resume((value_110) => {
5368
- let execution_54;
5369
- StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(value_110));
5370
- execution_54 = (new Execution$1(undefined, defaultOf()));
5371
- const continuation_82 = continuation_81;
5372
- return Execution$1__get_IsImmediate(execution_54) ? continuation_82(execution_54.Value) : execution_54.Resume(continuation_82);
5626
+ return execution_59.Resume((value_122) => {
5627
+ let execution_58;
5628
+ StringBuilder__Append_Z721C83C5(sb, valueToInterpolationString(value_122));
5629
+ execution_58 = (new Execution$1(undefined, defaultOf()));
5630
+ const continuation_88 = continuation_87;
5631
+ return Execution$1__get_IsImmediate(execution_58) ? continuation_88(execution_58.Value) : execution_58.Resume(continuation_88);
5373
5632
  });
5374
5633
  }
5375
5634
  });
@@ -5380,27 +5639,27 @@ function evalCompound(runtime, typeDefs, env, expr) {
5380
5639
  return new Execution$1(undefined, defaultOf());
5381
5640
  }
5382
5641
  });
5383
- if (Execution$1__get_IsImmediate(body_75)) {
5384
- return second_1();
5642
+ if (Execution$1__get_IsImmediate(body_79)) {
5643
+ return second_2();
5385
5644
  }
5386
5645
  else {
5387
- return new Execution$1(defaultOf(), (continuation_84) => {
5388
- const execution_57 = body_75;
5389
- if (Execution$1__get_IsImmediate(execution_57)) {
5390
- const execution_56 = second_1();
5391
- const continuation_85 = continuation_84;
5392
- if (Execution$1__get_IsImmediate(execution_56)) {
5393
- return continuation_85(execution_56.Value);
5646
+ return new Execution$1(defaultOf(), (continuation_90) => {
5647
+ const execution_61 = body_79;
5648
+ if (Execution$1__get_IsImmediate(execution_61)) {
5649
+ const execution_60 = second_2();
5650
+ const continuation_91 = continuation_90;
5651
+ if (Execution$1__get_IsImmediate(execution_60)) {
5652
+ return continuation_91(execution_60.Value);
5394
5653
  }
5395
5654
  else {
5396
- return execution_56.Resume(continuation_85);
5655
+ return execution_60.Resume(continuation_91);
5397
5656
  }
5398
5657
  }
5399
5658
  else {
5400
- return execution_57.Resume((value_113) => {
5401
- const execution_56 = second_1();
5402
- const continuation_85 = continuation_84;
5403
- return Execution$1__get_IsImmediate(execution_56) ? continuation_85(execution_56.Value) : execution_56.Resume(continuation_85);
5659
+ return execution_61.Resume((value_125) => {
5660
+ const execution_60 = second_2();
5661
+ const continuation_91 = continuation_90;
5662
+ return Execution$1__get_IsImmediate(execution_60) ? continuation_91(execution_60.Value) : execution_60.Resume(continuation_91);
5404
5663
  });
5405
5664
  }
5406
5665
  });
@@ -5413,8 +5672,8 @@ function evalCompound(runtime, typeDefs, env, expr) {
5413
5672
  }
5414
5673
  }
5415
5674
 
5416
- export function invokeValue(typeDefs, fnValue, args) {
5417
- const runtime = new RuntimeState({}, new FSharpRef(true), [], new FSharpRef(undefined));
5675
+ export function invokeValueWithExitCode(typeDefs, fnValue, args) {
5676
+ const runtime = new RuntimeState({}, new FSharpRef(0), new FSharpRef(true), [], new FSharpRef(undefined));
5418
5677
  const applyMany = (currentValue_mut, remainingArgs_mut) => {
5419
5678
  applyMany:
5420
5679
  while (true) {
@@ -5487,13 +5746,17 @@ export function invokeValue(typeDefs, fnValue, args) {
5487
5746
  }
5488
5747
  };
5489
5748
  try {
5490
- return applyMany(fnValue, args);
5749
+ return new InvocationResult(applyMany(fnValue, args), runtime.ExitCode.contents);
5491
5750
  }
5492
5751
  finally {
5493
5752
  runtime.Active.contents = false;
5494
5753
  }
5495
5754
  }
5496
5755
 
5756
+ export function invokeValue(typeDefs, fnValue, args) {
5757
+ return invokeValueWithExitCode(typeDefs, fnValue, args).Value;
5758
+ }
5759
+
5497
5760
  function validateTopLevelBindings(program) {
5498
5761
  const option_5 = tryPick_1((_arg) => {
5499
5762
  let matchResult, name_1, bindings, bindings_1;
@@ -5561,13 +5824,31 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
5561
5824
  const stmt = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
5562
5825
  raiseIfBackgroundFailed(runtime);
5563
5826
  switch (stmt.tag) {
5564
- case 1: {
5827
+ case 4: {
5565
5828
  const name = stmt.fields[0];
5829
+ const importedType = stmt.fields[1];
5830
+ const import$ = stmt.fields[2];
5831
+ const arity = (_arg) => {
5832
+ if (_arg.tag === 11) {
5833
+ return (1 + arity(_arg.fields[1])) | 0;
5834
+ }
5835
+ else {
5836
+ return 0;
5837
+ }
5838
+ };
5839
+ const external = new ExternalFunction(name, new Scheme_1(empty(), importedType), (_arg_1, _arg_2) => {
5840
+ throw new EvalException(new EvalError$(`Backend import '${import$.ModulePath}.${import$.MemberName}' is not executable in the legacy evaluator`, stmt.fields[3]));
5841
+ }, arity(importedType));
5842
+ env = add(name, new Value(/* VExternal */ 15, [external, empty()]), env);
5843
+ break;
5844
+ }
5845
+ case 1: {
5846
+ const name_1 = stmt.fields[0];
5566
5847
  const expr = stmt.fields[1];
5567
5848
  if (stmt.fields[3]) {
5568
5849
  if (expr.tag === 4) {
5569
5850
  const recEnv = new FSharpRef(env);
5570
- const finalEnv = add(name, new Value(/* VClosure */ 14, [expr.fields[0].Name, expr.fields[1], recEnv]), env);
5851
+ const finalEnv = add(name_1, new Value(/* VClosure */ 14, [expr.fields[0].Name, expr.fields[1], recEnv]), env);
5571
5852
  recEnv.contents = finalEnv;
5572
5853
  env = finalEnv;
5573
5854
  }
@@ -5577,7 +5858,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
5577
5858
  }
5578
5859
  else {
5579
5860
  const v = Execution_run(evalExpr(runtime, typeDefs, env, expr));
5580
- env = add(name, v, env);
5861
+ env = add(name_1, v, env);
5581
5862
  }
5582
5863
  break;
5583
5864
  }
@@ -5612,7 +5893,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
5612
5893
  }
5613
5894
  break;
5614
5895
  }
5615
- case 4: {
5896
+ case 5: {
5616
5897
  lastValue = Execution_run(evalExpr(runtime, typeDefs, env, stmt.fields[0].Expr));
5617
5898
  break;
5618
5899
  }
@@ -5629,11 +5910,11 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
5629
5910
  if (unawaitedCount > 0) {
5630
5911
  throw new EvalException(new EvalError$(`Program completed with ${unawaitedCount} unawaited ${(unawaitedCount === 1) ? "task" : "tasks"}`, unknownSpan));
5631
5912
  }
5632
- return new ProgramState(typeDefs, env, lastValue);
5913
+ return new ProgramState(typeDefs, env, lastValue, runtime.ExitCode.contents);
5633
5914
  }
5634
5915
 
5635
5916
  export function evalProgramFromState(state, program) {
5636
- const runtime = new RuntimeState({}, new FSharpRef(true), [], new FSharpRef(undefined));
5917
+ const runtime = new RuntimeState({}, new FSharpRef(state.ExitCode), new FSharpRef(true), [], new FSharpRef(undefined));
5637
5918
  try {
5638
5919
  return evaluateStatements(runtime, state.TypeDefs, state.Env, program);
5639
5920
  }
@@ -5644,7 +5925,7 @@ export function evalProgramFromState(state, program) {
5644
5925
 
5645
5926
  function evaluateRegistered(registration, program) {
5646
5927
  const externs = registration.Functions;
5647
- const runtime = new RuntimeState({}, new FSharpRef(true), [], new FSharpRef(undefined));
5928
+ const runtime = new RuntimeState({}, new FSharpRef(0), new FSharpRef(true), [], new FSharpRef(undefined));
5648
5929
  const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
5649
5930
  if (option_1 != null) {
5650
5931
  throw new EvalException(new EvalError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));