@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.
@@ -3,24 +3,26 @@ import { Span_$reflection, Span, Position } from "./Span.js";
3
3
  import { find, toSeq, FSharpMap__get_IsEmpty, containsKey, ofSeq as ofSeq_1, FSharpMap__Add, iterate as iterate_2, values as values_4, FSharpMap__get_Keys, keys, toList, FSharpMap__get_Count, forAll, FSharpMap__ContainsKey, filter, ofList, exists as exists_1, add, fold as fold_1, FSharpMap__get_Item, remove, map, FSharpMap__TryFind, tryFind, isEmpty, empty } from "../fable_modules/fable-library-js.5.27.0/Map.js";
4
4
  import { safeHash, curry3, arrayHash, equalArrays, compare, uncurry2, curry2, disposeSafe, getEnumerator, defaultOf, stringHash, Exception, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
5
5
  import { PurityContractsModule_empty, Types_ftvScheme, Types_applied, Types_ftvEnv, Types_generalize, Types_definitionBody, Types_freshNumeric, PurityContracts_$reflection, Scheme_$reflection, Types_ftvType, Type_$reflection, Types_freshVar, Types_$007CTypeApplication$007C_$007C, Types_typeToString, Types_expand, Scheme, Types_mapChildren, Type as Type_1 } from "./Types.js";
6
- import { exactlyOne, replicate, map2, sortBy, tryFind as tryFind_1, indexed, collect as collect_2, unzip, iterate, mapIndexed, tryFindIndex, contains as contains_1, append, reverse, choose, cons, empty as empty_2, head as head_4, tail as tail_6, isEmpty as isEmpty_1, ofArrayWithTail, map as map_1, ofArray, singleton, zip, length, exists, fold } from "../fable_modules/fable-library-js.5.27.0/List.js";
6
+ import { exactlyOne, replicate, map2, sortBy, tryFind as tryFind_1, foldBack as foldBack_1, indexed, collect as collect_2, unzip, iterate, mapIndexed, tryFindIndex, contains as contains_1, append, reverse, choose, cons, empty as empty_2, head as head_4, tail as tail_6, isEmpty as isEmpty_1, ofArrayWithTail, map as map_1, ofArray, singleton, zip, length, exists, fold } from "../fable_modules/fable-library-js.5.27.0/List.js";
7
7
  import { recursiveOpaqueEffects, generalizeValue, InferenceEnv__AddValue_Z1D943954, factoryDelay, InferenceEnv__Add_Z72D39050, InferenceEnv__ContainsKey_Z721C83C5, InferenceEnv__TryFind_Z721C83C5, opaqueVariables, combineOpaqueEffects, OpaqueEffect, noOpaque, OpaqueEffect_$reflection, InferenceEnv, mapOpaqueEffect } from "./OpaqueInference.js";
8
8
  import { FSharpSet__get_IsEmpty, intersect, exists as exists_3, remove as remove_1, ofList as ofList_1, difference, union, ofSeq, contains, add as add_1, toList as toList_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.27.0/Set.js";
9
9
  import { EvalException, TypeException, TypeError$ } from "./Error.js";
10
10
  import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.27.0/String.js";
11
11
  import { orElse, flatten, value as value_42, toArray as toArray_1, defaultArg } from "../fable_modules/fable-library-js.5.27.0/Option.js";
12
12
  import { FSharpRef, Union, Record } from "../fable_modules/fable-library-js.5.27.0/Types.js";
13
- import { Attribute, Expr, Ast_spanOfPattern, TypeRef, Ast_spanOfExpr, Attribute_$reflection, BackendImport_$reflection, Pattern_$reflection, TypeDef_$reflection, Expr_$reflection } from "./Ast.js";
13
+ import { Attribute, InterpolatedPart, MapEntry, Expr, Ast_spanOfPattern, TypeRef, Ast_spanOfExpr, Attribute_$reflection, BackendImport_$reflection, Pattern_$reflection, TypeDef_$reflection, Expr_$reflection } from "./Ast.js";
14
14
  import { array_type, class_type, tuple_type, list_type, bool_type, float64_type, int64_type, union_type, int32_type, string_type, option_type, record_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
15
15
  import { tryPick, forAll as forAll_1, tryFind as tryFind_2, foldBack, iterate as iterate_1, exists as exists_2, empty as empty_3, choose as choose_1, collect as collect_1, append as append_1, singleton as singleton_1, delay as delay_2, fold as fold_2, toArray, filter as filter_1, map as map_2, toList as toList_2 } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
16
16
  import { last as last_2, setItem, item as item_22 } from "../fable_modules/fable-library-js.5.27.0/Array.js";
17
17
  import { distinct } from "../fable_modules/fable-library-js.5.27.0/Seq2.js";
18
18
  import { addToSet, getItemFromDict, addToDict, tryGetValue } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
19
19
  import { min } from "../fable_modules/fable-library-js.5.27.0/Double.js";
20
+ import { Operators_InvalidOp } from "../fable_modules/fable-library-js.5.27.0/FSharp.Core.js";
20
21
  import { check } from "./MatchCoverage.js";
21
22
  import { builtinReservedNames, builtinSchemes } from "./BuiltinSignatures.js";
22
23
  import { ofExterns, typeDefinitions } from "./HostInterop.js";
23
24
  import { typeDefs as typeDefs_1 } from "./BuiltinTypes.js";
25
+ import { JsonDeserialization_name } from "./Value.js";
24
26
  import { Dictionary } from "../fable_modules/fable-library-js.5.27.0/MutableMap.js";
25
27
  import { rangeDouble } from "../fable_modules/fable-library-js.5.27.0/Range.js";
26
28
 
@@ -30,7 +32,7 @@ const emptySubst = empty({
30
32
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
31
33
  });
32
34
 
33
- function applyType(s, t) {
35
+ export function applyType(s, t) {
34
36
  if (isEmpty(s)) {
35
37
  return t;
36
38
  }
@@ -3231,7 +3233,7 @@ function inferExpr(telemetry, typeDefs, constructors, scope, env, expr) {
3231
3233
  }), noOpaque.FactoryDelay)]);
3232
3234
  return new OpaqueEffect(combined_1.Live, combined_1.Latent, (option_2 = fn.FactoryDelay, (option_2 != null) ? ((delay_1 = (option_2 | 0), (delay_1 > 0) ? (delay_1 - 1) : undefined)) : undefined));
3233
3235
  };
3234
- const effect_2 = applyOpaqueEffect(combined, (matchValue_1 = patternInput[2].Opaque, (matchValue_1 == null) ? ((expr.tag === 6) ? ((children.length === 2) ? call(item_22(0, children), item_22(1, children)) : combineOpaqueEffects(children)) : ((expr.tag === 26) ? ((expr.fields[0] === "|>") ? ((children.length === 2) ? call(item_22(1, children), item_22(0, children)) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)) : ((expr.tag === 7) ? ((children.length === 3) ? ((combined_2 = combineOpaqueEffects(children), (matchValue_2 = item_22(1, children).FactoryDelay, (matchValue_3 = item_22(2, children).FactoryDelay, (matchValue_2 != null) ? ((matchValue_3 != null) ? ((left = (matchValue_2 | 0), (right = (matchValue_3 | 0), new OpaqueEffect(combined_2.Live, combined_2.Latent, min(left, right))))) : combined_2) : combined_2)))) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)))) : matchValue_1));
3236
+ const effect_2 = applyOpaqueEffect(combined, (matchValue_1 = patternInput[2].Opaque, (matchValue_1 == null) ? ((expr.tag === 8) ? ((children.length === 2) ? call(item_22(0, children), item_22(1, children)) : combineOpaqueEffects(children)) : ((expr.tag === 28) ? ((expr.fields[0] === "|>") ? ((children.length === 2) ? call(item_22(1, children), item_22(0, children)) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)) : ((expr.tag === 9) ? ((children.length === 3) ? ((combined_2 = combineOpaqueEffects(children), (matchValue_2 = item_22(1, children).FactoryDelay, (matchValue_3 = item_22(2, children).FactoryDelay, (matchValue_2 != null) ? ((matchValue_3 != null) ? ((left = (matchValue_2 | 0), (right = (matchValue_3 | 0), new OpaqueEffect(combined_2.Live, combined_2.Latent, min(left, right))))) : combined_2) : combined_2)))) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)))) : matchValue_1));
3235
3237
  const effect_3 = new OpaqueEffect(union(effect_2.Live, opaqueVariables(typeDefs, resolved)), effect_2.Latent, effect_2.FactoryDelay);
3236
3238
  applyAnnotationScope(scope, combined);
3237
3239
  applySubstToCapturedExpressions(telemetry, expressionStart, combined);
@@ -3268,6 +3270,9 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3268
3270
  return [emptySubst, t_1, withOpaqueEffect(patternInput[1], asTyped(telemetry, expr, t_1))];
3269
3271
  }
3270
3272
  }
3273
+ case 4:
3274
+ case 5:
3275
+ throw Operators_InvalidOp("Evaluation annotations require a checked program.");
3271
3276
  case 3: {
3272
3277
  const target = expr.fields[0];
3273
3278
  const span_1 = expr.fields[2];
@@ -3276,7 +3281,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3276
3281
  switch (_arg.tag) {
3277
3282
  case 2:
3278
3283
  return _arg.fields[0];
3279
- case 22: {
3284
+ case 24: {
3280
3285
  const option_1 = qualified(_arg.fields[0]);
3281
3286
  if (option_1 != null) {
3282
3287
  return (option_1 + ".") + _arg.fields[1];
@@ -3311,12 +3316,12 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3311
3316
  throw new TypeException(new TypeError$(`Expected ${length(parameters_2)} type arguments, got ${length(arguments$)}`, span_1));
3312
3317
  }
3313
3318
  }
3314
- case 4: {
3319
+ case 6: {
3315
3320
  const patternInput_4 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3316
3321
  const t_3 = patternInput_4[1];
3317
3322
  return [patternInput_4[0], t_3, asTyped(telemetry, expr, t_3)];
3318
3323
  }
3319
- case 29: {
3324
+ case 31: {
3320
3325
  const span_2 = expr.fields[1];
3321
3326
  const name_4 = expr.fields[0];
3322
3327
  const matchValue_2 = FSharpMap__TryFind(typeDefs, name_4);
@@ -3330,7 +3335,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3330
3335
  return [emptySubst, Type_1.TTypeToken, asTyped(telemetry, expr, Type_1.TTypeToken)];
3331
3336
  }
3332
3337
  }
3333
- case 30: {
3338
+ case 32: {
3334
3339
  const name_5 = expr.fields[0];
3335
3340
  if (InferenceEnv__ContainsKey_Z721C83C5(env, name_5)) {
3336
3341
  return [emptySubst, Type_1.TString, asTyped(telemetry, expr, Type_1.TString)];
@@ -3339,7 +3344,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3339
3344
  throw new TypeException(new TypeError$(toText(printf("Unbound variable \'%s\'"))(name_5), expr.fields[1]));
3340
3345
  }
3341
3346
  }
3342
- case 31: {
3347
+ case 33: {
3343
3348
  let sAcc = emptySubst;
3344
3349
  const enumerator = getEnumerator(expr.fields[0]);
3345
3350
  try {
@@ -3356,7 +3361,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3356
3361
  }
3357
3362
  return [sAcc, Type_1.TString, asTyped(telemetry, expr, Type_1.TString)];
3358
3363
  }
3359
- case 5: {
3364
+ case 7: {
3360
3365
  const param = expr.fields[0];
3361
3366
  const body = expr.fields[1];
3362
3367
  let tv;
@@ -3392,7 +3397,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3392
3397
  }));
3393
3398
  return [s1_1, tFun, withOpaqueEffect(new OpaqueEffect(live, FSharpSet__get_IsEmpty(created) ? latent : add(1, created, latent), factoryDelay(knownForwarders, body)), asTyped(telemetry, expr, tFun))];
3394
3399
  }
3395
- case 6: {
3400
+ case 8: {
3396
3401
  const span_5 = expr.fields[2];
3397
3402
  const patternInput_7 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3398
3403
  const s1_2 = patternInput_7[0];
@@ -3405,7 +3410,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3405
3410
  const tRes = applyType(s_1, tv_1);
3406
3411
  return [s_1, tRes, asTyped(telemetry, expr, tRes)];
3407
3412
  }
3408
- case 7: {
3413
+ case 9: {
3409
3414
  const span_6 = expr.fields[3];
3410
3415
  const patternInput_9 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3411
3416
  const s1_3 = patternInput_9[0];
@@ -3419,14 +3424,14 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3419
3424
  const tRes_1 = applyType(s_2, tElse);
3420
3425
  return [s_2, tRes_1, asTyped(telemetry, expr, tRes_1)];
3421
3426
  }
3422
- case 8: {
3427
+ case 10: {
3423
3428
  const patternInput_12 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3424
3429
  const s1_4 = patternInput_12[0];
3425
3430
  const s_3 = compose(unify(typeDefs, applyType(s1_4, patternInput_12[1]), Type_1.TString, expr.fields[1]), s1_4);
3426
3431
  const tRes_2 = Types_freshVar();
3427
3432
  return [s_3, tRes_2, asTyped(telemetry, expr, tRes_2)];
3428
3433
  }
3429
- case 9: {
3434
+ case 11: {
3430
3435
  const name_7 = expr.fields[0];
3431
3436
  const body_1 = expr.fields[2];
3432
3437
  const patternInput_13 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[1]);
@@ -3439,7 +3444,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3439
3444
  const s2_3 = patternInput_14[0];
3440
3445
  return [compose(unify(typeDefs, applyType(s2_3, patternInput_14[1]), Type_1.TUnit, Ast_spanOfExpr(body_1)), compose(s2_3, sSource)), Type_1.TUnit, asTyped(telemetry, expr, Type_1.TUnit)];
3441
3446
  }
3442
- case 11: {
3447
+ case 13: {
3443
3448
  const value_5 = expr.fields[1];
3444
3449
  const span_9 = expr.fields[6];
3445
3450
  const name_8 = expr.fields[0];
@@ -3478,7 +3483,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3478
3483
  return [compose(patternInput_19[0], sValue_1), t2_1, asTyped(telemetry, expr, t2_1)];
3479
3484
  }
3480
3485
  }
3481
- case 12: {
3486
+ case 14: {
3482
3487
  const startIndex = currentTelemetryCaptureCount(telemetry) | 0;
3483
3488
  const patternInput_20 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[1]);
3484
3489
  const valueInfo_2 = patternInput_20[2];
@@ -3493,14 +3498,14 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3493
3498
  const tBody_3 = patternInput_22[1];
3494
3499
  return [compose(patternInput_22[0], sValue_2), tBody_3, asTyped(telemetry, expr, tBody_3)];
3495
3500
  }
3496
- case 13: {
3501
+ case 15: {
3497
3502
  const foldedBindings = map_1((tupledArg_2) => {
3498
3503
  const args = tupledArg_2[1];
3499
3504
  const bindingSpan = tupledArg_2[4];
3500
3505
  if (isEmpty_1(args)) {
3501
3506
  throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
3502
3507
  }
3503
- const folded = foldBack((arg_4, acc) => (new Expr(/* ELambda */ 5, [arg_4, acc, bindingSpan])), args, tupledArg_2[3]);
3508
+ const folded = foldBack((arg_4, acc) => (new Expr(/* ELambda */ 7, [arg_4, acc, bindingSpan])), args, tupledArg_2[3]);
3504
3509
  return [tupledArg_2[0], bindingScope(scope, tupledArg_2[2]), folded, length(args), bindingSpan];
3505
3510
  }, expr.fields[0]);
3506
3511
  const freshByName = ofList(map_1((tupledArg_3) => [tupledArg_3[0], Types_freshVar()], foldedBindings), {
@@ -3556,7 +3561,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3556
3561
  const tBody_4 = patternInput_24[1];
3557
3562
  return [compose(patternInput_24[0], sRec), tBody_4, asTyped(telemetry, expr, tBody_4)];
3558
3563
  }
3559
- case 10: {
3564
+ case 12: {
3560
3565
  const cases = expr.fields[1];
3561
3566
  const patternInput_25 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3562
3567
  const tScrut = patternInput_25[1];
@@ -3604,7 +3609,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3604
3609
  const tRes_3 = defaultArg(resultTypeOpt, Types_freshVar());
3605
3610
  return [sAcc_1, tRes_3, asTyped(telemetry, expr, tRes_3)];
3606
3611
  }
3607
- case 14: {
3612
+ case 16: {
3608
3613
  const tv_5 = Types_freshVar();
3609
3614
  let sAcc_2 = emptySubst;
3610
3615
  const enumerator_4 = getEnumerator(expr.fields[0]);
@@ -3623,7 +3628,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3623
3628
  const tRes_4 = new Type_1(/* TList */ 5, [applyType(sAcc_2, tv_5)]);
3624
3629
  return [sAcc_2, tRes_4, asTyped(telemetry, expr, tRes_4)];
3625
3630
  }
3626
- case 15: {
3631
+ case 17: {
3627
3632
  const span_14 = expr.fields[2];
3628
3633
  const patternInput_30 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3629
3634
  const s1_12 = patternInput_30[0];
@@ -3633,7 +3638,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3633
3638
  const tRes_5 = new Type_1(/* TList */ 5, [Type_1.TInt]);
3634
3639
  return [compose(unify(typeDefs, applyType(s3_3, applyType(s2_9, patternInput_31[1])), Type_1.TInt, span_14), compose(s3_3, compose(s2_9, s1_12))), tRes_5, asTyped(telemetry, expr, tRes_5)];
3635
3640
  }
3636
- case 16: {
3641
+ case 18: {
3637
3642
  let sAcc_3 = emptySubst;
3638
3643
  let inferred_3 = empty_2();
3639
3644
  const enumerator_5 = getEnumerator(expr.fields[0]);
@@ -3651,7 +3656,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3651
3656
  const tRes_6 = new Type_1(/* TTuple */ 7, [reverse(inferred_3)]);
3652
3657
  return [sAcc_3, tRes_6, asTyped(telemetry, expr, tRes_6)];
3653
3658
  }
3654
- case 17: {
3659
+ case 19: {
3655
3660
  const span_15 = expr.fields[1];
3656
3661
  let sAcc_4 = emptySubst;
3657
3662
  let inferred_4 = empty({
@@ -3677,7 +3682,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3677
3682
  const tRes_7 = applyType(s_10, expected_1);
3678
3683
  return [s_10, tRes_7, asTyped(telemetry, expr, tRes_7)];
3679
3684
  }
3680
- case 18: {
3685
+ case 20: {
3681
3686
  let sAcc_5 = emptySubst;
3682
3687
  let inferred_5 = empty({
3683
3688
  Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
@@ -3697,7 +3702,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3697
3702
  const tRes_8 = new Type_1(/* TRecord */ 8, [inferred_5]);
3698
3703
  return [sAcc_5, tRes_8, asTyped(telemetry, expr, tRes_8)];
3699
3704
  }
3700
- case 19: {
3705
+ case 21: {
3701
3706
  const ensureSupportedMapKeyType_1 = (t_5) => {
3702
3707
  ensureSupportedMapKeyType(typeDefs, expr.fields[1], t_5);
3703
3708
  };
@@ -3737,7 +3742,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3737
3742
  const tRes_9 = new Type_1(/* TMap */ 9, [applyType(sAcc_6, keyType), applyType(sAcc_6, valueType)]);
3738
3743
  return [sAcc_6, tRes_9, asTyped(telemetry, expr, tRes_9)];
3739
3744
  }
3740
- case 20: {
3745
+ case 22: {
3741
3746
  const span_17 = expr.fields[2];
3742
3747
  const patternInput_38 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3743
3748
  const tBase = patternInput_38[1];
@@ -3848,7 +3853,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3848
3853
  tRes_10 = ((matchValue_10.tag === 13) ? matchValue_10 : (new Type_1(/* TRecord */ 8, [resultFields])));
3849
3854
  return [sAcc_7, tRes_10, asTyped(telemetry, expr, tRes_10)];
3850
3855
  }
3851
- case 21: {
3856
+ case 23: {
3852
3857
  const span_18 = expr.fields[2];
3853
3858
  const patternInput_40 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
3854
3859
  const tBase_1 = patternInput_40[1];
@@ -3951,7 +3956,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
3951
3956
  const tRes_11 = new Type_1(/* TRecord */ 8, [map((_arg_10, t_8) => applyType(sAcc_8, t_8), resultFields_1)]);
3952
3957
  return [sAcc_8, tRes_11, asTyped(telemetry, expr, tRes_11)];
3953
3958
  }
3954
- case 22: {
3959
+ case 24: {
3955
3960
  const target_1 = expr.fields[0];
3956
3961
  const span_19 = expr.fields[2];
3957
3962
  const fieldName = expr.fields[1];
@@ -4083,7 +4088,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
4083
4088
  }
4084
4089
  break;
4085
4090
  }
4086
- case 22: {
4091
+ case 24: {
4087
4092
  matchResult_6 = 2;
4088
4093
  name_27 = _arg_11.fields[1];
4089
4094
  parent_1 = _arg_11.fields[0];
@@ -4133,7 +4138,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
4133
4138
  return [patternInput_46[0], tField_8, asTyped(telemetry, expr, tField_8)];
4134
4139
  }
4135
4140
  }
4136
- case 23: {
4141
+ case 25: {
4137
4142
  const span_20 = expr.fields[2];
4138
4143
  const patternInput_47 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
4139
4144
  const s1_19 = patternInput_47[0];
@@ -4209,7 +4214,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
4209
4214
  throw new TypeException(new TypeError$(concat("Index access requires a ", (keyType_1.tag === 1) ? "list" : ((keyType_1.tag === 4) ? "map" : "list or map"), " target with a compatible index type"), span_20));
4210
4215
  }
4211
4216
  }
4212
- case 26: {
4217
+ case 28: {
4213
4218
  const span_21 = expr.fields[3];
4214
4219
  const op = expr.fields[0];
4215
4220
  const b = expr.fields[2];
@@ -4293,16 +4298,16 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
4293
4298
  }
4294
4299
  }
4295
4300
  }
4296
- case 27: {
4301
+ case 29: {
4297
4302
  const patternInput_59 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
4298
4303
  const t1_11 = patternInput_59[1];
4299
4304
  return [patternInput_59[0], new Type_1(/* TOption */ 10, [t1_11]), asTyped(telemetry, expr, new Type_1(/* TOption */ 10, [t1_11]))];
4300
4305
  }
4301
- case 28: {
4306
+ case 30: {
4302
4307
  const tv_9 = Types_freshVar();
4303
4308
  return [emptySubst, new Type_1(/* TOption */ 10, [tv_9]), asTyped(telemetry, expr, new Type_1(/* TOption */ 10, [tv_9]))];
4304
4309
  }
4305
- case 24: {
4310
+ case 26: {
4306
4311
  const patternInput_60 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
4307
4312
  const t1_12 = patternInput_60[1];
4308
4313
  const s1_25 = patternInput_60[0];
@@ -4312,7 +4317,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
4312
4317
  const tRes_19 = applyType(s_21, new Type_1(/* TList */ 5, [t1_12]));
4313
4318
  return [s_21, tRes_19, asTyped(telemetry, expr, tRes_19)];
4314
4319
  }
4315
- case 25: {
4320
+ case 27: {
4316
4321
  const span_23 = expr.fields[2];
4317
4322
  const patternInput_62 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
4318
4323
  const s1_26 = patternInput_62[0];
@@ -4472,7 +4477,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
4472
4477
  else {
4473
4478
  return empty_2();
4474
4479
  }
4475
- }, append(toList(scriptDefinitions), toList(hostDefinitions))), {
4480
+ }, append(toList(hostDefinitions), toList(scriptDefinitions))), {
4476
4481
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
4477
4482
  });
4478
4483
  const constructorSchemes = map_1((tupledArg_2) => {
@@ -4562,7 +4567,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
4562
4567
  const valueScope = patternInput_2[0];
4563
4568
  const returnAnnotation_1 = patternInput_2[2];
4564
4569
  const explicitParameters = patternInput_2[1];
4565
- const exprVal = foldBack((arg, acc_2) => (new Expr(/* ELambda */ 5, [arg, acc_2, span_3])), args, stmt.fields[3]);
4570
+ const exprVal = foldBack((arg, acc_2) => (new Expr(/* ELambda */ 7, [arg, acc_2, span_3])), args, stmt.fields[3]);
4566
4571
  let startIndex;
4567
4572
  if (telemetry == null) {
4568
4573
  startIndex = 0;
@@ -4652,7 +4657,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
4652
4657
  if (isEmpty_1(args_1)) {
4653
4658
  throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
4654
4659
  }
4655
- const folded = foldBack((arg_1, acc_3) => (new Expr(/* ELambda */ 5, [arg_1, acc_3, bindingSpan])), args_1, tupledArg_5[3]);
4660
+ const folded = foldBack((arg_1, acc_3) => (new Expr(/* ELambda */ 7, [arg_1, acc_3, bindingSpan])), args_1, tupledArg_5[3]);
4656
4661
  return [tupledArg_5[0], bindingScope(scope, tupledArg_5[2]), folded, length(args_1), bindingSpan];
4657
4662
  }, stmt.fields[0]);
4658
4663
  const freshByName = ofList(map_1((tupledArg_6) => [tupledArg_6[0], Types_freshVar()], foldedBindings), {
@@ -4761,8 +4766,229 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
4761
4766
  }
4762
4767
  }
4763
4768
 
4769
+ function annotateEvaluation(expressions, program) {
4770
+ const types = ofList(map_1((item) => [item.Expr, item.Type], expressions), {
4771
+ Compare: (x, y) => (compare(x, y) | 0),
4772
+ });
4773
+ const annotate = (expr) => {
4774
+ let signature_1;
4775
+ const typ = tryFind(expr, types);
4776
+ const fields = (list_1) => map_1((tupledArg) => [tupledArg[0], annotate(tupledArg[1])], list_1);
4777
+ let mapped;
4778
+ switch (expr.tag) {
4779
+ case 7: {
4780
+ const body_1 = annotate(expr.fields[1]);
4781
+ mapped = (new Expr(/* ELambda */ 7, [expr.fields[0], (typ != null) ? (!FSharpSet__get_IsEmpty(Types_ftvType(typ)) ? ((signature_1 = typ, new Expr(/* EClosureSignature */ 5, [body_1, signature_1]))) : body_1) : body_1, expr.fields[2]]));
4782
+ break;
4783
+ }
4784
+ case 3: {
4785
+ mapped = expr;
4786
+ break;
4787
+ }
4788
+ case 6: {
4789
+ mapped = (new Expr(/* EParen */ 6, [annotate(expr.fields[0]), expr.fields[1]]));
4790
+ break;
4791
+ }
4792
+ case 8: {
4793
+ mapped = (new Expr(/* EApply */ 8, [annotate(expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4794
+ break;
4795
+ }
4796
+ case 9: {
4797
+ mapped = (new Expr(/* EIf */ 9, [annotate(expr.fields[0]), annotate(expr.fields[1]), annotate(expr.fields[2]), expr.fields[3]]));
4798
+ break;
4799
+ }
4800
+ case 10: {
4801
+ mapped = (new Expr(/* ERaise */ 10, [annotate(expr.fields[0]), expr.fields[1]]));
4802
+ break;
4803
+ }
4804
+ case 11: {
4805
+ mapped = (new Expr(/* EFor */ 11, [expr.fields[0], annotate(expr.fields[1]), annotate(expr.fields[2]), expr.fields[3]]));
4806
+ break;
4807
+ }
4808
+ case 12: {
4809
+ mapped = (new Expr(/* EMatch */ 12, [annotate(expr.fields[0]), map_1((tupledArg_1) => {
4810
+ let option;
4811
+ return [tupledArg_1[0], (option = tupledArg_1[1], (option != null) ? annotate(option) : undefined), annotate(tupledArg_1[2]), tupledArg_1[3]];
4812
+ }, expr.fields[1]), expr.fields[2]]));
4813
+ break;
4814
+ }
4815
+ case 13: {
4816
+ mapped = (new Expr(/* ELet */ 13, [expr.fields[0], annotate(expr.fields[1]), annotate(expr.fields[2]), expr.fields[3], expr.fields[4], expr.fields[5], expr.fields[6]]));
4817
+ break;
4818
+ }
4819
+ case 14: {
4820
+ mapped = (new Expr(/* ELetPattern */ 14, [expr.fields[0], annotate(expr.fields[1]), annotate(expr.fields[2]), expr.fields[3]]));
4821
+ break;
4822
+ }
4823
+ case 15: {
4824
+ mapped = (new Expr(/* ELetRecGroup */ 15, [map_1((tupledArg_2) => {
4825
+ const at_1 = tupledArg_2[4];
4826
+ return [tupledArg_2[0], empty_2(), tupledArg_2[2], annotate(foldBack_1((parameter_1, inner) => (new Expr(/* ELambda */ 7, [parameter_1, inner, at_1])), tupledArg_2[1], tupledArg_2[3])), at_1];
4827
+ }, expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4828
+ break;
4829
+ }
4830
+ case 16: {
4831
+ mapped = (new Expr(/* EList */ 16, [map_1(annotate, expr.fields[0]), expr.fields[1]]));
4832
+ break;
4833
+ }
4834
+ case 17: {
4835
+ mapped = (new Expr(/* ERange */ 17, [annotate(expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4836
+ break;
4837
+ }
4838
+ case 18: {
4839
+ mapped = (new Expr(/* ETuple */ 18, [map_1(annotate, expr.fields[0]), expr.fields[1]]));
4840
+ break;
4841
+ }
4842
+ case 19: {
4843
+ mapped = (new Expr(/* ERecord */ 19, [fields(expr.fields[0]), expr.fields[1]]));
4844
+ break;
4845
+ }
4846
+ case 20: {
4847
+ mapped = (new Expr(/* EStructuralRecord */ 20, [fields(expr.fields[0]), expr.fields[1]]));
4848
+ break;
4849
+ }
4850
+ case 21: {
4851
+ mapped = (new Expr(/* EMap */ 21, [map_1((_arg) => {
4852
+ if (_arg.tag === 1) {
4853
+ return new MapEntry(/* MESpread */ 1, [annotate(_arg.fields[0])]);
4854
+ }
4855
+ else {
4856
+ return new MapEntry(/* MEKeyValue */ 0, [annotate(_arg.fields[0]), annotate(_arg.fields[1])]);
4857
+ }
4858
+ }, expr.fields[0]), expr.fields[1]]));
4859
+ break;
4860
+ }
4861
+ case 22: {
4862
+ mapped = (new Expr(/* ERecordUpdate */ 22, [annotate(expr.fields[0]), fields(expr.fields[1]), expr.fields[2]]));
4863
+ break;
4864
+ }
4865
+ case 23: {
4866
+ mapped = (new Expr(/* EStructuralRecordUpdate */ 23, [annotate(expr.fields[0]), fields(expr.fields[1]), expr.fields[2]]));
4867
+ break;
4868
+ }
4869
+ case 24: {
4870
+ const value_12 = expr.fields[0];
4871
+ const qualified = (_arg_1_mut) => {
4872
+ qualified:
4873
+ while (true) {
4874
+ const _arg_1 = _arg_1_mut;
4875
+ switch (_arg_1.tag) {
4876
+ case 2:
4877
+ return true;
4878
+ case 24: {
4879
+ _arg_1_mut = _arg_1.fields[0];
4880
+ continue qualified;
4881
+ }
4882
+ default:
4883
+ return false;
4884
+ }
4885
+ break;
4886
+ }
4887
+ };
4888
+ mapped = (new Expr(/* EFieldGet */ 24, [qualified(value_12) ? value_12 : annotate(value_12), expr.fields[1], expr.fields[2]]));
4889
+ break;
4890
+ }
4891
+ case 25: {
4892
+ mapped = (new Expr(/* EIndexGet */ 25, [annotate(expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4893
+ break;
4894
+ }
4895
+ case 26: {
4896
+ mapped = (new Expr(/* ECons */ 26, [annotate(expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4897
+ break;
4898
+ }
4899
+ case 27: {
4900
+ mapped = (new Expr(/* EAppend */ 27, [annotate(expr.fields[0]), annotate(expr.fields[1]), expr.fields[2]]));
4901
+ break;
4902
+ }
4903
+ case 28: {
4904
+ mapped = (new Expr(/* EBinOp */ 28, [expr.fields[0], annotate(expr.fields[1]), annotate(expr.fields[2]), expr.fields[3]]));
4905
+ break;
4906
+ }
4907
+ case 29: {
4908
+ mapped = (new Expr(/* ESome */ 29, [annotate(expr.fields[0]), expr.fields[1]]));
4909
+ break;
4910
+ }
4911
+ case 33: {
4912
+ mapped = (new Expr(/* EInterpolatedString */ 33, [map_1((_arg_2) => {
4913
+ if (_arg_2.tag === 1) {
4914
+ return new InterpolatedPart(/* IPExpr */ 1, [annotate(_arg_2.fields[0])]);
4915
+ }
4916
+ else {
4917
+ return _arg_2;
4918
+ }
4919
+ }, expr.fields[0]), expr.fields[1]]));
4920
+ break;
4921
+ }
4922
+ default:
4923
+ mapped = expr;
4924
+ }
4925
+ let matchResult, signature_2;
4926
+ if (mapped.tag === 7) {
4927
+ matchResult = 0;
4928
+ }
4929
+ else if (typ != null) {
4930
+ if (typ.tag === 11) {
4931
+ matchResult = 1;
4932
+ signature_2 = typ;
4933
+ }
4934
+ else {
4935
+ matchResult = 2;
4936
+ }
4937
+ }
4938
+ else {
4939
+ matchResult = 2;
4940
+ }
4941
+ switch (matchResult) {
4942
+ case 0:
4943
+ return mapped;
4944
+ case 1:
4945
+ return new Expr(/* EEvaluationType */ 4, [mapped, signature_2]);
4946
+ default:
4947
+ return mapped;
4948
+ }
4949
+ };
4950
+ return map_1((_arg_3) => {
4951
+ switch (_arg_3.tag) {
4952
+ case 1:
4953
+ return new TypedStmt(/* TSLet */ 1, [_arg_3.fields[0], annotate(_arg_3.fields[1]), _arg_3.fields[2], _arg_3.fields[3], _arg_3.fields[4], _arg_3.fields[5]]);
4954
+ case 2:
4955
+ return new TypedStmt(/* TSLetPattern */ 2, [_arg_3.fields[0], annotate(_arg_3.fields[1]), _arg_3.fields[2], _arg_3.fields[3], _arg_3.fields[4]]);
4956
+ case 3:
4957
+ return new TypedStmt(/* TSLetRecGroup */ 3, [map_1((tupledArg_3) => [tupledArg_3[0], annotate(tupledArg_3[1]), tupledArg_3[2], tupledArg_3[3]], _arg_3.fields[0]), _arg_3.fields[1], _arg_3.fields[2]]);
4958
+ case 5: {
4959
+ const value_19 = _arg_3.fields[0];
4960
+ return new TypedStmt(/* TSExpr */ 5, [new TypedExpr(annotate(value_19.Expr), value_19.Type, value_19.Span)]);
4961
+ }
4962
+ default:
4963
+ return _arg_3;
4964
+ }
4965
+ }, program);
4966
+ }
4967
+
4968
+ function requiresEvaluationEvidence(registration) {
4969
+ return exists((ext) => (ext.Name === JsonDeserialization_name), registration.Functions);
4970
+ }
4971
+
4972
+ function evaluationProgram(registration, typed, expressions) {
4973
+ if (requiresEvaluationEvidence(registration)) {
4974
+ return annotateEvaluation(expressions, typed);
4975
+ }
4976
+ else {
4977
+ return typed;
4978
+ }
4979
+ }
4980
+
4981
+ function inferForEvaluation(registration, program) {
4982
+ const patternInput = inferProgramWithExternsRawAndLocals(requiresEvaluationEvidence(registration), registration, program);
4983
+ return evaluationProgram(registration, patternInput[0], patternInput[2]);
4984
+ }
4985
+
4986
+ export function specializeEvaluationType(typeDefs, span, template, instance) {
4987
+ return unify(typeDefs, template, instance, span);
4988
+ }
4989
+
4764
4990
  export function inferProgramWithExternsRaw(externs, program) {
4765
- return inferProgramWithExternsRawAndLocals(false, ofExterns(externs), program)[0];
4991
+ return inferForEvaluation(ofExterns(externs), program);
4766
4992
  }
4767
4993
 
4768
4994
  function validateProgramBindings(externs, program) {
@@ -4778,8 +5004,9 @@ function validateProgramBindings(externs, program) {
4778
5004
 
4779
5005
  export function inferProgramWithExternsAndLocalVariableTypes(externs, program) {
4780
5006
  validateProgramBindings(externs, program);
4781
- const patternInput = inferProgramWithExternsRawAndLocals(true, ofExterns(externs), program);
4782
- return [patternInput[0], patternInput[1]];
5007
+ const registration = ofExterns(externs);
5008
+ const patternInput = inferProgramWithExternsRawAndLocals(true, registration, program);
5009
+ return [evaluationProgram(registration, patternInput[0], patternInput[2]), patternInput[1]];
4783
5010
  }
4784
5011
 
4785
5012
  export function inferResolvedProgramWithRegistration(registration, program) {
@@ -5190,71 +5417,81 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5190
5417
  switch (expression_1.tag) {
5191
5418
  case 0:
5192
5419
  case 1:
5193
- case 28: {
5420
+ case 30: {
5194
5421
  matchResult_1 = 21;
5195
5422
  break;
5196
5423
  }
5424
+ case 4: {
5425
+ matchResult_1 = 1;
5426
+ target = expression_1.fields[0];
5427
+ break;
5428
+ }
5429
+ case 5: {
5430
+ matchResult_1 = 1;
5431
+ target = expression_1.fields[0];
5432
+ break;
5433
+ }
5197
5434
  case 3: {
5198
5435
  matchResult_1 = 1;
5199
5436
  target = expression_1.fields[0];
5200
5437
  break;
5201
5438
  }
5202
- case 30: {
5439
+ case 32: {
5203
5440
  matchResult_1 = 2;
5204
5441
  name_14 = expression_1.fields[0];
5205
5442
  span_9 = expression_1.fields[1];
5206
5443
  break;
5207
5444
  }
5208
- case 29: {
5445
+ case 31: {
5209
5446
  matchResult_1 = 3;
5210
5447
  name_15 = expression_1.fields[0];
5211
5448
  span_10 = expression_1.fields[1];
5212
5449
  break;
5213
5450
  }
5214
- case 5: {
5451
+ case 7: {
5215
5452
  matchResult_1 = 4;
5216
5453
  body = expression_1.fields[1];
5217
5454
  parameter = expression_1.fields[0];
5218
5455
  break;
5219
5456
  }
5220
- case 6: {
5457
+ case 8: {
5221
5458
  matchResult_1 = 5;
5222
5459
  argument_2 = expression_1.fields[1];
5223
5460
  fn = expression_1.fields[0];
5224
5461
  break;
5225
5462
  }
5226
- case 26: {
5463
+ case 28: {
5227
5464
  matchResult_1 = 5;
5228
5465
  argument_2 = expression_1.fields[2];
5229
5466
  fn = expression_1.fields[1];
5230
5467
  break;
5231
5468
  }
5232
- case 25: {
5469
+ case 27: {
5233
5470
  matchResult_1 = 5;
5234
5471
  argument_2 = expression_1.fields[1];
5235
5472
  fn = expression_1.fields[0];
5236
5473
  break;
5237
5474
  }
5238
- case 24: {
5475
+ case 26: {
5239
5476
  matchResult_1 = 5;
5240
5477
  argument_2 = expression_1.fields[1];
5241
5478
  fn = expression_1.fields[0];
5242
5479
  break;
5243
5480
  }
5244
- case 23: {
5481
+ case 25: {
5245
5482
  matchResult_1 = 5;
5246
5483
  argument_2 = expression_1.fields[1];
5247
5484
  fn = expression_1.fields[0];
5248
5485
  break;
5249
5486
  }
5250
- case 7: {
5487
+ case 9: {
5251
5488
  matchResult_1 = 6;
5252
5489
  condition = expression_1.fields[0];
5253
5490
  whenFalse = expression_1.fields[2];
5254
5491
  whenTrue = expression_1.fields[1];
5255
5492
  break;
5256
5493
  }
5257
- case 11: {
5494
+ case 13: {
5258
5495
  matchResult_1 = 7;
5259
5496
  binding = expression_1.fields[1];
5260
5497
  body_1 = expression_1.fields[2];
@@ -5263,26 +5500,26 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5263
5500
  span_11 = expression_1.fields[6];
5264
5501
  break;
5265
5502
  }
5266
- case 12: {
5503
+ case 14: {
5267
5504
  matchResult_1 = 8;
5268
5505
  binding_1 = expression_1.fields[1];
5269
5506
  body_2 = expression_1.fields[2];
5270
5507
  pattern_2 = expression_1.fields[0];
5271
5508
  break;
5272
5509
  }
5273
- case 13: {
5510
+ case 15: {
5274
5511
  matchResult_1 = 9;
5275
5512
  bindings_9 = expression_1.fields[0];
5276
5513
  body_3 = expression_1.fields[1];
5277
5514
  break;
5278
5515
  }
5279
- case 10: {
5516
+ case 12: {
5280
5517
  matchResult_1 = 10;
5281
5518
  cases_3 = expression_1.fields[1];
5282
5519
  target_1 = expression_1.fields[0];
5283
5520
  break;
5284
5521
  }
5285
- case 9: {
5522
+ case 11: {
5286
5523
  matchResult_1 = 11;
5287
5524
  body_5 = expression_1.fields[2];
5288
5525
  name_18 = expression_1.fields[0];
@@ -5290,44 +5527,44 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5290
5527
  span_14 = expression_1.fields[3];
5291
5528
  break;
5292
5529
  }
5293
- case 14: {
5530
+ case 16: {
5294
5531
  matchResult_1 = 12;
5295
5532
  items_5 = expression_1.fields[0];
5296
5533
  break;
5297
5534
  }
5298
- case 16: {
5535
+ case 18: {
5299
5536
  matchResult_1 = 12;
5300
5537
  items_5 = expression_1.fields[0];
5301
5538
  break;
5302
5539
  }
5303
- case 17: {
5540
+ case 19: {
5304
5541
  matchResult_1 = 13;
5305
5542
  fields_5 = expression_1.fields[0];
5306
5543
  break;
5307
5544
  }
5308
- case 18: {
5545
+ case 20: {
5309
5546
  matchResult_1 = 13;
5310
5547
  fields_5 = expression_1.fields[0];
5311
5548
  break;
5312
5549
  }
5313
- case 19: {
5550
+ case 21: {
5314
5551
  matchResult_1 = 14;
5315
5552
  entries = expression_1.fields[0];
5316
5553
  break;
5317
5554
  }
5318
- case 20: {
5555
+ case 22: {
5319
5556
  matchResult_1 = 15;
5320
5557
  fields_6 = expression_1.fields[1];
5321
5558
  target_2 = expression_1.fields[0];
5322
5559
  break;
5323
5560
  }
5324
- case 21: {
5561
+ case 23: {
5325
5562
  matchResult_1 = 15;
5326
5563
  fields_6 = expression_1.fields[1];
5327
5564
  target_2 = expression_1.fields[0];
5328
5565
  break;
5329
5566
  }
5330
- case 22: {
5567
+ case 24: {
5331
5568
  if (expression_1.fields[0].tag === 2) {
5332
5569
  if (containsKey(concat(expression_1.fields[0].fields[0], ".", expression_1.fields[1]), environment_2)) {
5333
5570
  matchResult_1 = 16;
@@ -5346,28 +5583,28 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5346
5583
  }
5347
5584
  break;
5348
5585
  }
5349
- case 27: {
5586
+ case 29: {
5350
5587
  matchResult_1 = 18;
5351
5588
  item_14 = expression_1.fields[0];
5352
5589
  break;
5353
5590
  }
5354
- case 4: {
5591
+ case 6: {
5355
5592
  matchResult_1 = 18;
5356
5593
  item_14 = expression_1.fields[0];
5357
5594
  break;
5358
5595
  }
5359
- case 8: {
5596
+ case 10: {
5360
5597
  matchResult_1 = 18;
5361
5598
  item_14 = expression_1.fields[0];
5362
5599
  break;
5363
5600
  }
5364
- case 15: {
5601
+ case 17: {
5365
5602
  matchResult_1 = 19;
5366
5603
  first = expression_1.fields[0];
5367
5604
  last = expression_1.fields[1];
5368
5605
  break;
5369
5606
  }
5370
- case 31: {
5607
+ case 33: {
5371
5608
  matchResult_1 = 20;
5372
5609
  parts = expression_1.fields[0];
5373
5610
  break;
@@ -5436,7 +5673,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5436
5673
  try {
5437
5674
  while (enumerator_10["System.Collections.IEnumerator.MoveNext"]()) {
5438
5675
  const forLoopVar_7 = enumerator_10["System.Collections.Generic.IEnumerator`1.get_Current"]();
5439
- visit(recursiveEnvironment, foldBack((parameter_1, inner) => (new Expr(/* ELambda */ 5, [parameter_1, inner, forLoopVar_7[4]])), forLoopVar_7[1], forLoopVar_7[3]));
5676
+ visit(recursiveEnvironment, foldBack((parameter_1, inner) => (new Expr(/* ELambda */ 7, [parameter_1, inner, forLoopVar_7[4]])), forLoopVar_7[1], forLoopVar_7[3]));
5440
5677
  }
5441
5678
  }
5442
5679
  finally {
@@ -5662,7 +5899,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5662
5899
  const referenceAt = (expression_7) => {
5663
5900
  let x_13;
5664
5901
  const span_23 = Ast_spanOfExpr(expression_7);
5665
- const expectedName = (expression_7.tag === 2) ? expression_7.fields[0] : ((expression_7.tag === 30) ? expression_7.fields[0] : ((expression_7.tag === 29) ? expression_7.fields[0] : ((expression_7.tag === 22) ? ((expression_7.fields[0].tag === 2) ? concat(expression_7.fields[0].fields[0], ".", expression_7.fields[1]) : undefined) : undefined)));
5902
+ const expectedName = (expression_7.tag === 2) ? expression_7.fields[0] : ((expression_7.tag === 32) ? expression_7.fields[0] : ((expression_7.tag === 31) ? expression_7.fields[0] : ((expression_7.tag === 24) ? ((expression_7.fields[0].tag === 2) ? concat(expression_7.fields[0].fields[0], ".", expression_7.fields[1]) : undefined) : undefined)));
5666
5903
  let matchValue_4;
5667
5904
  const cell_1 = new FSharpRef(defaultOf());
5668
5905
  matchValue_4 = [tryGetValue(referenceOccurrences, span_23, cell_1), cell_1.contents];
@@ -5854,7 +6091,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
5854
6091
  const expressionType = finalType(expression_8);
5855
6092
  const reference_2 = (expression_8.tag === 3) ? referenceAt(expression_8.fields[0]) : referenceAt(expression_8);
5856
6093
  let primitive;
5857
- if (expression_8.tag === 26) {
6094
+ if (expression_8.tag === 28) {
5858
6095
  const op = expression_8.fields[0];
5859
6096
  let matchResult_6;
5860
6097
  switch (op) {
@@ -6026,7 +6263,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6026
6263
  matchResult_7 = 2;
6027
6264
  break;
6028
6265
  }
6029
- case 28: {
6266
+ case 30: {
6030
6267
  matchResult_7 = 18;
6031
6268
  break;
6032
6269
  }
@@ -6041,25 +6278,35 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6041
6278
  break;
6042
6279
  }
6043
6280
  case 5: {
6281
+ matchResult_7 = 3;
6282
+ inner_1 = expression_8.fields[0];
6283
+ break;
6284
+ }
6285
+ case 6: {
6286
+ matchResult_7 = 3;
6287
+ inner_1 = expression_8.fields[0];
6288
+ break;
6289
+ }
6290
+ case 7: {
6044
6291
  matchResult_7 = 4;
6045
6292
  body_6 = expression_8.fields[1];
6046
6293
  parameter_2 = expression_8.fields[0];
6047
6294
  break;
6048
6295
  }
6049
- case 6: {
6296
+ case 8: {
6050
6297
  matchResult_7 = 5;
6051
6298
  argument_4 = expression_8.fields[1];
6052
6299
  fn_1 = expression_8.fields[0];
6053
6300
  break;
6054
6301
  }
6055
- case 7: {
6302
+ case 9: {
6056
6303
  matchResult_7 = 6;
6057
6304
  condition_1 = expression_8.fields[0];
6058
6305
  whenFalse_1 = expression_8.fields[2];
6059
6306
  whenTrue_1 = expression_8.fields[1];
6060
6307
  break;
6061
6308
  }
6062
- case 26: {
6309
+ case 28: {
6063
6310
  switch (expression_8.fields[0]) {
6064
6311
  case "|>": {
6065
6312
  matchResult_7 = 7;
@@ -6087,39 +6334,39 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6087
6334
  }
6088
6335
  break;
6089
6336
  }
6090
- case 25: {
6337
+ case 27: {
6091
6338
  matchResult_7 = 9;
6092
6339
  left_2 = expression_8.fields[0];
6093
6340
  right_1 = expression_8.fields[1];
6094
6341
  break;
6095
6342
  }
6096
- case 24: {
6343
+ case 26: {
6097
6344
  matchResult_7 = 11;
6098
6345
  head_3 = expression_8.fields[0];
6099
6346
  tail_5 = expression_8.fields[1];
6100
6347
  break;
6101
6348
  }
6102
- case 16: {
6349
+ case 18: {
6103
6350
  matchResult_7 = 12;
6104
6351
  items_7 = expression_8.fields[0];
6105
6352
  break;
6106
6353
  }
6107
- case 14: {
6354
+ case 16: {
6108
6355
  matchResult_7 = 13;
6109
6356
  items_8 = expression_8.fields[0];
6110
6357
  break;
6111
6358
  }
6112
- case 17: {
6359
+ case 19: {
6113
6360
  matchResult_7 = 14;
6114
6361
  fields_8 = expression_8.fields[0];
6115
6362
  break;
6116
6363
  }
6117
- case 18: {
6364
+ case 20: {
6118
6365
  matchResult_7 = 14;
6119
6366
  fields_8 = expression_8.fields[0];
6120
6367
  break;
6121
6368
  }
6122
- case 22: {
6369
+ case 24: {
6123
6370
  if (reference_2 != null) {
6124
6371
  matchResult_7 = 15;
6125
6372
  }
@@ -6130,12 +6377,12 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6130
6377
  }
6131
6378
  break;
6132
6379
  }
6133
- case 27: {
6380
+ case 29: {
6134
6381
  matchResult_7 = 17;
6135
6382
  item_19 = expression_8.fields[0];
6136
6383
  break;
6137
6384
  }
6138
- case 11: {
6385
+ case 13: {
6139
6386
  matchResult_7 = 19;
6140
6387
  body_7 = expression_8.fields[2];
6141
6388
  name_36 = expression_8.fields[0];
@@ -6144,25 +6391,25 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6144
6391
  value_28 = expression_8.fields[1];
6145
6392
  break;
6146
6393
  }
6147
- case 12: {
6394
+ case 14: {
6148
6395
  matchResult_7 = 20;
6149
6396
  body_8 = expression_8.fields[2];
6150
6397
  pattern_6 = expression_8.fields[0];
6151
6398
  value_29 = expression_8.fields[1];
6152
6399
  break;
6153
6400
  }
6154
- case 13: {
6401
+ case 15: {
6155
6402
  matchResult_7 = 21;
6156
6403
  bindings_12 = expression_8.fields[0];
6157
6404
  body_9 = expression_8.fields[1];
6158
6405
  break;
6159
6406
  }
6160
- case 8: {
6407
+ case 10: {
6161
6408
  matchResult_7 = 22;
6162
6409
  value_31 = expression_8.fields[0];
6163
6410
  break;
6164
6411
  }
6165
- case 9: {
6412
+ case 11: {
6166
6413
  matchResult_7 = 23;
6167
6414
  body_10 = expression_8.fields[2];
6168
6415
  name_38 = expression_8.fields[0];
@@ -6170,52 +6417,52 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6170
6417
  span_27 = expression_8.fields[3];
6171
6418
  break;
6172
6419
  }
6173
- case 10: {
6420
+ case 12: {
6174
6421
  matchResult_7 = 24;
6175
6422
  cases_8 = expression_8.fields[1];
6176
6423
  target_6 = expression_8.fields[0];
6177
6424
  break;
6178
6425
  }
6179
- case 15: {
6426
+ case 17: {
6180
6427
  matchResult_7 = 25;
6181
6428
  first_1 = expression_8.fields[0];
6182
6429
  last_1 = expression_8.fields[1];
6183
6430
  break;
6184
6431
  }
6185
- case 20: {
6432
+ case 22: {
6186
6433
  matchResult_7 = 26;
6187
6434
  fields_9 = expression_8.fields[1];
6188
6435
  target_7 = expression_8.fields[0];
6189
6436
  break;
6190
6437
  }
6191
- case 21: {
6438
+ case 23: {
6192
6439
  matchResult_7 = 27;
6193
6440
  fields_10 = expression_8.fields[1];
6194
6441
  target_8 = expression_8.fields[0];
6195
6442
  break;
6196
6443
  }
6197
- case 23: {
6444
+ case 25: {
6198
6445
  matchResult_7 = 28;
6199
6446
  index_2 = expression_8.fields[1];
6200
6447
  target_9 = expression_8.fields[0];
6201
6448
  break;
6202
6449
  }
6203
- case 30: {
6450
+ case 32: {
6204
6451
  matchResult_7 = 29;
6205
6452
  name_41 = expression_8.fields[0];
6206
6453
  break;
6207
6454
  }
6208
- case 29: {
6455
+ case 31: {
6209
6456
  matchResult_7 = 30;
6210
6457
  name_42 = expression_8.fields[0];
6211
6458
  break;
6212
6459
  }
6213
- case 31: {
6460
+ case 33: {
6214
6461
  matchResult_7 = 31;
6215
6462
  parts_1 = expression_8.fields[0];
6216
6463
  break;
6217
6464
  }
6218
- case 19: {
6465
+ case 21: {
6219
6466
  matchResult_7 = 32;
6220
6467
  entries_1 = expression_8.fields[0];
6221
6468
  break;
@@ -6312,7 +6559,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6312
6559
  case 21: {
6313
6560
  node_1 = (new ResolvedExpressionNode(/* ResolvedLetRecursiveGroup */ 16, [map_1((tupledArg_12) => {
6314
6561
  const span_26 = tupledArg_12[4];
6315
- const resolvedValue_1 = resolveExpression(foldBack((parameter_3, inner_2) => (new Expr(/* ELambda */ 5, [parameter_3, inner_2, span_26])), tupledArg_12[1], tupledArg_12[3]));
6562
+ const resolvedValue_1 = resolveExpression(foldBack((parameter_3, inner_2) => (new Expr(/* ELambda */ 7, [parameter_3, inner_2, span_26])), tupledArg_12[1], tupledArg_12[3]));
6316
6563
  return new ResolvedRecursiveBinding(bindingAt(ResolvedSymbolKind.LocalSymbol, tupledArg_12[0], span_26, resolvedValue_1.Type), resolvedValue_1);
6317
6564
  }, bindings_12), resolveExpression(body_9)]));
6318
6565
  break;
@@ -6538,11 +6785,12 @@ export function inferResolvedProgramWithRegistration(registration, program) {
6538
6785
  Compare: (x_19, y_21) => (compareArrays(x_19, y_21) | 0),
6539
6786
  }), export$, node_2, patterns, resolvedRoots);
6540
6787
  }, patternInput[0], typed);
6541
- return new ResolvedProgram(PurityContractsModule_empty, typed, append(map_1((tupledArg_22) => {
6788
+ const hostStatements = map_1((tupledArg_22) => {
6542
6789
  const name_55 = tupledArg_22[0];
6543
6790
  const definition_11 = tupledArg_22[1];
6544
6791
  return new ResolvedStatement(syntheticSpan, empty_2(), undefined, new ResolvedStatementNode(/* ResolvedTypeDeclaration */ 0, [new ResolvedTypeDeclaration(bindingAt(ResolvedSymbolKind.TypeSymbol, name_55, syntheticSpan, Types_applied(name_55, definition_11)), false, definition_11, (definition_11.tag === 8) ? toList(definition_11.fields[0]) : ((definition_11.tag === 19) ? toList(definition_11.fields[1]) : empty_2()), (definition_11.tag === 15) ? toList(definition_11.fields[1]) : empty_2(), undefined)]), empty_2(), empty_2());
6545
- }, toList(hostDefinitions)), resolvedStatements), expressions, toList_2(symbols), resolvedReferences);
6792
+ }, toList(hostDefinitions));
6793
+ return new ResolvedProgram(PurityContractsModule_empty, evaluationProgram(registration, typed, expressions), append(hostStatements, resolvedStatements), expressions, toList_2(symbols), resolvedReferences);
6546
6794
  }
6547
6795
 
6548
6796
  /**
@@ -6586,7 +6834,7 @@ export function inferProgramWithRegistration(registration, program) {
6586
6834
  if (exists((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))) {
6587
6835
  throw new TypeException(new TypeError$("Top-level binding collides with reserved stdlib symbol", unknownSpan));
6588
6836
  }
6589
- return inferProgramWithExternsRawAndLocals(false, registration, program)[0];
6837
+ return inferForEvaluation(registration, program);
6590
6838
  }
6591
6839
 
6592
6840
  export function inferProgramWithRegistrationAndTypes(registration, program) {
@@ -6596,7 +6844,9 @@ export function inferProgramWithRegistrationAndTypes(registration, program) {
6596
6844
  if (exists((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))) {
6597
6845
  throw new TypeException(new TypeError$("Top-level binding collides with reserved stdlib symbol", unknownSpan));
6598
6846
  }
6599
- return inferProgramWithExternsRawAndLocals(true, registration, program);
6847
+ const patternInput = inferProgramWithExternsRawAndLocals(true, registration, program);
6848
+ const expressions = patternInput[2];
6849
+ return [evaluationProgram(registration, patternInput[0], expressions), patternInput[1], expressions];
6600
6850
  }
6601
6851
 
6602
6852
  export function inferProgramWithRegistrationAndLocalVariableTypes(registration, program) {