@magnusopera/fscript 0.82.2 → 0.83.1
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.
- package/dist/FScript.Language/BuiltinFunctions.js +1176 -195
- package/dist/FScript.Language/Eval.js +3659 -740
- package/dist/FScript.Language/Execution.js +513 -0
- package/dist/FScript.Language/HostInterop.js +9 -4
- package/dist/FScript.Language/IncludeResolver.js +13 -4
- package/dist/FScript.Language/TaskFunctions.js +50 -0
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import { Span, Position } from "./Span.js";
|
|
3
3
|
import { EvalException, EvalError$ } from "./Error.js";
|
|
4
|
-
import { FSharpMap__Remove,
|
|
4
|
+
import { FSharpMap__Remove, toList, add, FSharpMap__Add, FSharpMap__ContainsKey, FSharpMap__TryFind, empty as empty_1, FSharpMap__get_Item, forAll, FSharpMap__get_Keys, FSharpMap__get_Count, tryFind } from "../fable_modules/fable-library-js.5.13.0/Map.js";
|
|
5
5
|
import { builtinSchemes } from "./BuiltinSignatures.js";
|
|
6
|
-
import { equals as equals_1, compare, comparePrimitives, Exception } from "../fable_modules/fable-library-js.5.13.0/Util.js";
|
|
6
|
+
import { equals as equals_1, compare, comparePrimitives, curry2, defaultOf, Exception } from "../fable_modules/fable-library-js.5.13.0/Util.js";
|
|
7
7
|
import { endsWith, split, join, substring, indexOf, replace, format, concat } from "../fable_modules/fable-library-js.5.13.0/String.js";
|
|
8
|
-
import {
|
|
8
|
+
import { Dictionary } from "../fable_modules/fable-library-js.5.13.0/MutableMap.js";
|
|
9
|
+
import { HashIdentity_Reference } from "../fable_modules/fable-library-js.5.13.0/FSharp.Collections.js";
|
|
10
|
+
import { Execution_fold, Execution_execution, Execution_Builder__For_Z3A5BE4A, Execution$1__get_IsImmediate, Execution_map, Execution$1, Execution_run } from "./Execution.js";
|
|
11
|
+
import { Value, MapKey, ExternalFunction } from "./Value.js";
|
|
12
|
+
import { tryGetValue, addToDict } from "../fable_modules/fable-library-js.5.13.0/MapUtil.js";
|
|
9
13
|
import { FSharpRef } from "../fable_modules/fable-library-js.5.13.0/Types.js";
|
|
14
|
+
import { tryParse } from "../fable_modules/fable-library-js.5.13.0/Long.js";
|
|
10
15
|
import { tryParse as tryParse_1 } from "../fable_modules/fable-library-js.5.13.0/Double.js";
|
|
11
|
-
import { append, tryHead,
|
|
12
|
-
import { ExternalFunction, Value as Value_1, MapKey } from "./Value.js";
|
|
16
|
+
import { append, tryHead, concat as concat_1, choose, ofArray, map, exists, fold, forAll2, length as length_1, empty, reverse, cons, tail as tail_1, head as head_1, isEmpty } from "../fable_modules/fable-library-js.5.13.0/List.js";
|
|
13
17
|
import { compare as compare_1, op_Addition, toInt32_unchecked, fromInt32, toInt64_unchecked, equals } from "../fable_modules/fable-library-js.5.13.0/BigInt.js";
|
|
14
18
|
import { ofSeq } from "../fable_modules/fable-library-js.5.13.0/Set.js";
|
|
15
19
|
import { $007CRecordFields$007C_$007C } from "./HostInterop.js";
|
|
@@ -32,6 +36,28 @@ function scheme(name) {
|
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
const implementations = new Dictionary([], HashIdentity_Reference());
|
|
40
|
+
|
|
41
|
+
function resumable(name, arity, implementation) {
|
|
42
|
+
const descriptor = new ExternalFunction(name, scheme(name), (context, arguments$) => Execution_run(implementation((f) => ((a) => (new Execution$1(context.Apply(f, a), defaultOf()))), arguments$)), arity);
|
|
43
|
+
addToDict(implementations, descriptor, curry2(implementation));
|
|
44
|
+
return descriptor;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function tryExecution(descriptor) {
|
|
48
|
+
let matchValue;
|
|
49
|
+
let outArg = defaultOf();
|
|
50
|
+
matchValue = [tryGetValue(implementations, descriptor, new FSharpRef(() => outArg, (v) => {
|
|
51
|
+
outArg = curry2(v);
|
|
52
|
+
})), outArg];
|
|
53
|
+
if (matchValue[0]) {
|
|
54
|
+
return matchValue[1];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
35
61
|
function tryParseInt64(text) {
|
|
36
62
|
let matchValue;
|
|
37
63
|
let outArg = 0n;
|
|
@@ -231,13 +257,13 @@ function asStringList(functionName, values) {
|
|
|
231
257
|
function mapKeyToValue(key) {
|
|
232
258
|
switch (key.tag) {
|
|
233
259
|
case 1:
|
|
234
|
-
return new
|
|
260
|
+
return new Value(/* VInt */ 1, [key.fields[0]]);
|
|
235
261
|
case 2:
|
|
236
|
-
return new
|
|
262
|
+
return new Value(/* VBool */ 3, [key.fields[0]]);
|
|
237
263
|
case 3:
|
|
238
|
-
return new
|
|
264
|
+
return new Value(/* VUnionCase */ 10, [key.fields[0], key.fields[1], undefined]);
|
|
239
265
|
default:
|
|
240
|
-
return new
|
|
266
|
+
return new Value(/* VString */ 4, [key.fields[0]]);
|
|
241
267
|
}
|
|
242
268
|
}
|
|
243
269
|
|
|
@@ -667,16 +693,16 @@ function distinctValues(values) {
|
|
|
667
693
|
}, empty(), values));
|
|
668
694
|
}
|
|
669
695
|
|
|
670
|
-
const builtinIgnore = new ExternalFunction("ignore", scheme("ignore"), (_arg, _arg_1) =>
|
|
696
|
+
const builtinIgnore = new ExternalFunction("ignore", scheme("ignore"), (_arg, _arg_1) => Value.VUnit, 1);
|
|
671
697
|
|
|
672
698
|
const builtinIntTryParse = new ExternalFunction("Int.tryParse", scheme("Int.tryParse"), (_arg, args) => {
|
|
673
699
|
const matchValue = tryParseInt64(expectString("Int.tryParse", args));
|
|
674
|
-
return (matchValue == null) ? (new
|
|
700
|
+
return (matchValue == null) ? (new Value(/* VOption */ 9, [undefined])) : (new Value(/* VOption */ 9, [new Value(/* VInt */ 1, [matchValue])]));
|
|
675
701
|
}, 1);
|
|
676
702
|
|
|
677
703
|
const builtinFloatTryParse = new ExternalFunction("Float.tryParse", scheme("Float.tryParse"), (_arg, args) => {
|
|
678
704
|
const matchValue = tryParseDouble(expectString("Float.tryParse", args));
|
|
679
|
-
return (matchValue == null) ? (new
|
|
705
|
+
return (matchValue == null) ? (new Value(/* VOption */ 9, [undefined])) : (new Value(/* VOption */ 9, [new Value(/* VFloat */ 2, [matchValue])]));
|
|
680
706
|
}, 1);
|
|
681
707
|
|
|
682
708
|
const builtinBoolTryParse = new ExternalFunction("Bool.tryParse", scheme("Bool.tryParse"), (_arg, args) => {
|
|
@@ -685,10 +711,10 @@ const builtinBoolTryParse = new ExternalFunction("Bool.tryParse", scheme("Bool.t
|
|
|
685
711
|
matchValue = [tryParse_2(expectString("Bool.tryParse", args), new FSharpRef(() => outArg, (v) => {
|
|
686
712
|
outArg = v;
|
|
687
713
|
})), outArg];
|
|
688
|
-
return matchValue[0] ? (new
|
|
714
|
+
return matchValue[0] ? (new Value(/* VOption */ 9, [new Value(/* VBool */ 3, [matchValue[1]])])) : (new Value(/* VOption */ 9, [undefined]));
|
|
689
715
|
}, 1);
|
|
690
716
|
|
|
691
|
-
const builtinIntToString = new ExternalFunction("Int.toString", scheme("Int.toString"), (_arg, args) => (new
|
|
717
|
+
const builtinIntToString = new ExternalFunction("Int.toString", scheme("Int.toString"), (_arg, args) => (new Value(/* VString */ 4, [String(expectInt("Int.toString", args))])), 1);
|
|
692
718
|
|
|
693
719
|
const builtinFloatToString = new ExternalFunction("Float.toString", scheme("Float.toString"), (_arg, args) => {
|
|
694
720
|
let matchResult, value;
|
|
@@ -711,13 +737,13 @@ const builtinFloatToString = new ExternalFunction("Float.toString", scheme("Floa
|
|
|
711
737
|
}
|
|
712
738
|
switch (matchResult) {
|
|
713
739
|
case 0:
|
|
714
|
-
return new
|
|
740
|
+
return new Value(/* VString */ 4, [format('{0:' + "G17" + '}', value)]);
|
|
715
741
|
default:
|
|
716
742
|
return fail("Float.toString expects (float)");
|
|
717
743
|
}
|
|
718
744
|
}, 1);
|
|
719
745
|
|
|
720
|
-
const builtinBoolToString = new ExternalFunction("Bool.toString", scheme("Bool.toString"), (_arg, args) => (new
|
|
746
|
+
const builtinBoolToString = new ExternalFunction("Bool.toString", scheme("Bool.toString"), (_arg, args) => (new Value(/* VString */ 4, [expectBool("Bool.toString", args) ? "true" : "false"])), 1);
|
|
721
747
|
|
|
722
748
|
const builtinStringReplace = new ExternalFunction("String.replace", scheme("String.replace"), (_arg, args) => {
|
|
723
749
|
let matchResult, newValue, oldValue, source;
|
|
@@ -762,7 +788,7 @@ const builtinStringReplace = new ExternalFunction("String.replace", scheme("Stri
|
|
|
762
788
|
}
|
|
763
789
|
switch (matchResult) {
|
|
764
790
|
case 0:
|
|
765
|
-
return new
|
|
791
|
+
return new Value(/* VString */ 4, [replace(source, oldValue, newValue)]);
|
|
766
792
|
default:
|
|
767
793
|
return fail("String.replace expects (string, string, string)");
|
|
768
794
|
}
|
|
@@ -801,7 +827,7 @@ const builtinStringIndexOf = new ExternalFunction("String.indexOf", scheme("Stri
|
|
|
801
827
|
switch (matchResult) {
|
|
802
828
|
case 0: {
|
|
803
829
|
const index = indexOf(source, value, 4) | 0;
|
|
804
|
-
return (index >= 0) ? (new
|
|
830
|
+
return (index >= 0) ? (new Value(/* VOption */ 9, [new Value(/* VInt */ 1, [toInt64_unchecked(fromInt32(index))])])) : (new Value(/* VOption */ 9, [undefined]));
|
|
805
831
|
}
|
|
806
832
|
default:
|
|
807
833
|
return fail("String.indexOf expects (string, string)");
|
|
@@ -810,12 +836,12 @@ const builtinStringIndexOf = new ExternalFunction("String.indexOf", scheme("Stri
|
|
|
810
836
|
|
|
811
837
|
const builtinStringToLower = new ExternalFunction("String.toLower", scheme("String.toLower"), (_arg, args) => {
|
|
812
838
|
const source = expectString("String.toLower", args);
|
|
813
|
-
return new
|
|
839
|
+
return new Value(/* VString */ 4, [source.toLowerCase()]);
|
|
814
840
|
}, 1);
|
|
815
841
|
|
|
816
842
|
const builtinStringToUpper = new ExternalFunction("String.toUpper", scheme("String.toUpper"), (_arg, args) => {
|
|
817
843
|
const source = expectString("String.toUpper", args);
|
|
818
|
-
return new
|
|
844
|
+
return new Value(/* VString */ 4, [source.toUpperCase()]);
|
|
819
845
|
}, 1);
|
|
820
846
|
|
|
821
847
|
const builtinStringSubstring = new ExternalFunction("String.substring", scheme("String.substring"), (_arg, args) => {
|
|
@@ -863,7 +889,7 @@ const builtinStringSubstring = new ExternalFunction("String.substring", scheme("
|
|
|
863
889
|
case 0: {
|
|
864
890
|
const startIndex = ~~toInt32_unchecked(start) | 0;
|
|
865
891
|
const sliceLength = ~~toInt32_unchecked(length) | 0;
|
|
866
|
-
return ((((startIndex < 0) ? true : (sliceLength < 0)) ? true : (startIndex > source.length)) ? true : ((startIndex + sliceLength) > source.length)) ? (new
|
|
892
|
+
return ((((startIndex < 0) ? true : (sliceLength < 0)) ? true : (startIndex > source.length)) ? true : ((startIndex + sliceLength) > source.length)) ? (new Value(/* VOption */ 9, [undefined])) : (new Value(/* VOption */ 9, [new Value(/* VString */ 4, [substring(source, startIndex, sliceLength)])]));
|
|
867
893
|
}
|
|
868
894
|
default:
|
|
869
895
|
return fail("String.substring expects (string, int, int)");
|
|
@@ -902,7 +928,7 @@ const builtinStringConcat = new ExternalFunction("String.concat", scheme("String
|
|
|
902
928
|
}
|
|
903
929
|
switch (matchResult) {
|
|
904
930
|
case 0:
|
|
905
|
-
return new
|
|
931
|
+
return new Value(/* VString */ 4, [join(separator, asStringList("String.concat", values))]);
|
|
906
932
|
default:
|
|
907
933
|
return fail("String.concat expects (string, string list)");
|
|
908
934
|
}
|
|
@@ -940,7 +966,7 @@ const builtinStringSplit = new ExternalFunction("String.split", scheme("String.s
|
|
|
940
966
|
}
|
|
941
967
|
switch (matchResult) {
|
|
942
968
|
case 0:
|
|
943
|
-
return new
|
|
969
|
+
return new Value(/* VList */ 5, [map((Item) => (new Value(/* VString */ 4, [Item])), ofArray(split(source, [separator], undefined, 0)))]);
|
|
944
970
|
default:
|
|
945
971
|
return fail("String.split expects (string, string)");
|
|
946
972
|
}
|
|
@@ -978,15 +1004,15 @@ const builtinStringEndsWith = new ExternalFunction("String.endsWith", scheme("St
|
|
|
978
1004
|
}
|
|
979
1005
|
switch (matchResult) {
|
|
980
1006
|
case 0:
|
|
981
|
-
return new
|
|
1007
|
+
return new Value(/* VBool */ 3, [endsWith(source, suffix, 4)]);
|
|
982
1008
|
default:
|
|
983
1009
|
return fail("String.endsWith expects (string, string)");
|
|
984
1010
|
}
|
|
985
1011
|
}, 2);
|
|
986
1012
|
|
|
987
|
-
const builtinListEmpty = new ExternalFunction("List.empty", scheme("List.empty"), (_arg, _arg_1) => (new
|
|
1013
|
+
const builtinListEmpty = new ExternalFunction("List.empty", scheme("List.empty"), (_arg, _arg_1) => (new Value(/* VList */ 5, [empty()])), 0);
|
|
988
1014
|
|
|
989
|
-
const builtinListMap =
|
|
1015
|
+
const builtinListMap = resumable("List.map", 2, (apply, args) => {
|
|
990
1016
|
let matchResult, mapper, values;
|
|
991
1017
|
if (!isEmpty(args)) {
|
|
992
1018
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1012,14 +1038,35 @@ const builtinListMap = new ExternalFunction("List.map", scheme("List.map"), (ctx
|
|
|
1012
1038
|
matchResult = 1;
|
|
1013
1039
|
}
|
|
1014
1040
|
switch (matchResult) {
|
|
1015
|
-
case 0:
|
|
1016
|
-
|
|
1041
|
+
case 0: {
|
|
1042
|
+
const body_1 = Execution_map(apply(mapper), values);
|
|
1043
|
+
return Execution$1__get_IsImmediate(body_1) ? (new Execution$1(new Value(/* VList */ 5, [body_1.Value]), defaultOf())) : (new Execution$1(defaultOf(), (continuation) => {
|
|
1044
|
+
const execution_1 = body_1;
|
|
1045
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1046
|
+
const execution = new Execution$1(new Value(/* VList */ 5, [execution_1.Value]), defaultOf());
|
|
1047
|
+
const continuation_1 = continuation;
|
|
1048
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1049
|
+
return continuation_1(execution.Value);
|
|
1050
|
+
}
|
|
1051
|
+
else {
|
|
1052
|
+
return execution.Resume(continuation_1);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
return execution_1.Resume((value_2) => {
|
|
1057
|
+
const execution = new Execution$1(new Value(/* VList */ 5, [value_2]), defaultOf());
|
|
1058
|
+
const continuation_1 = continuation;
|
|
1059
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
}));
|
|
1063
|
+
}
|
|
1017
1064
|
default:
|
|
1018
|
-
return fail("List.map expects (mapper, values)");
|
|
1065
|
+
return new Execution$1(fail("List.map expects (mapper, values)"), defaultOf());
|
|
1019
1066
|
}
|
|
1020
|
-
}
|
|
1067
|
+
});
|
|
1021
1068
|
|
|
1022
|
-
const builtinListIter =
|
|
1069
|
+
const builtinListIter = resumable("List.iter", 2, (apply, args) => {
|
|
1023
1070
|
let matchResult, iterator, values;
|
|
1024
1071
|
if (!isEmpty(args)) {
|
|
1025
1072
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1046,24 +1093,71 @@ const builtinListIter = new ExternalFunction("List.iter", scheme("List.iter"), (
|
|
|
1046
1093
|
}
|
|
1047
1094
|
switch (matchResult) {
|
|
1048
1095
|
case 0: {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1096
|
+
const second = () => (new Execution$1(Value.VUnit, defaultOf()));
|
|
1097
|
+
const body_2 = Execution_Builder__For_Z3A5BE4A(Execution_execution, values, (_arg) => {
|
|
1098
|
+
const body_1 = apply(iterator)(_arg);
|
|
1099
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
1100
|
+
return new Execution$1(undefined, defaultOf());
|
|
1101
|
+
}
|
|
1102
|
+
else {
|
|
1103
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1104
|
+
const execution_1 = body_1;
|
|
1105
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1106
|
+
let execution;
|
|
1107
|
+
execution = (new Execution$1(undefined, defaultOf()));
|
|
1108
|
+
const continuation_1 = continuation;
|
|
1109
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1110
|
+
return continuation_1(execution.Value);
|
|
1111
|
+
}
|
|
1112
|
+
else {
|
|
1113
|
+
return execution.Resume(continuation_1);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
else {
|
|
1117
|
+
return execution_1.Resume((value_2) => {
|
|
1118
|
+
let execution;
|
|
1119
|
+
execution = (new Execution$1(undefined, defaultOf()));
|
|
1120
|
+
const continuation_1 = continuation;
|
|
1121
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
return Execution$1__get_IsImmediate(body_2) ? second() : (new Execution$1(defaultOf(), (continuation_3) => {
|
|
1128
|
+
const execution_3 = body_2;
|
|
1129
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
1130
|
+
const execution_2 = second();
|
|
1131
|
+
const continuation_4 = continuation_3;
|
|
1132
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
1133
|
+
return continuation_4(execution_2.Value);
|
|
1134
|
+
}
|
|
1135
|
+
else {
|
|
1136
|
+
return execution_2.Resume(continuation_4);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
else {
|
|
1140
|
+
return execution_3.Resume((value_5) => {
|
|
1141
|
+
const execution_2 = second();
|
|
1142
|
+
const continuation_4 = continuation_3;
|
|
1143
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
}));
|
|
1053
1147
|
}
|
|
1054
1148
|
default:
|
|
1055
|
-
return fail("List.iter expects (iterator, values)");
|
|
1149
|
+
return new Execution$1(fail("List.iter expects (iterator, values)"), defaultOf());
|
|
1056
1150
|
}
|
|
1057
|
-
}
|
|
1151
|
+
});
|
|
1058
1152
|
|
|
1059
|
-
const builtinListChoose =
|
|
1060
|
-
let matchResult,
|
|
1153
|
+
const builtinListChoose = resumable("List.choose", 2, (apply, args) => {
|
|
1154
|
+
let matchResult, callback, values;
|
|
1061
1155
|
if (!isEmpty(args)) {
|
|
1062
1156
|
if (!isEmpty(tail_1(args))) {
|
|
1063
1157
|
if (head_1(tail_1(args)).tag === 5) {
|
|
1064
1158
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
1065
1159
|
matchResult = 0;
|
|
1066
|
-
|
|
1160
|
+
callback = head_1(args);
|
|
1067
1161
|
values = head_1(tail_1(args)).fields[0];
|
|
1068
1162
|
}
|
|
1069
1163
|
else {
|
|
@@ -1082,29 +1176,74 @@ const builtinListChoose = new ExternalFunction("List.choose", scheme("List.choos
|
|
|
1082
1176
|
matchResult = 1;
|
|
1083
1177
|
}
|
|
1084
1178
|
switch (matchResult) {
|
|
1085
|
-
case 0:
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1088
|
-
if (
|
|
1089
|
-
|
|
1179
|
+
case 0: {
|
|
1180
|
+
const body_3 = Execution_map((value) => {
|
|
1181
|
+
const body_1 = apply(callback)(value);
|
|
1182
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
1183
|
+
const result = body_1.Value;
|
|
1184
|
+
return (result.tag === 9) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.choose chooser must return option"), defaultOf()));
|
|
1090
1185
|
}
|
|
1091
1186
|
else {
|
|
1092
|
-
return
|
|
1187
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1188
|
+
const execution_1 = body_1;
|
|
1189
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1190
|
+
let execution;
|
|
1191
|
+
const result = execution_1.Value;
|
|
1192
|
+
execution = ((result.tag === 9) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.choose chooser must return option"), defaultOf())));
|
|
1193
|
+
const continuation_1 = continuation;
|
|
1194
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1195
|
+
return continuation_1(execution.Value);
|
|
1196
|
+
}
|
|
1197
|
+
else {
|
|
1198
|
+
return execution.Resume(continuation_1);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
return execution_1.Resume((value_5) => {
|
|
1203
|
+
let execution;
|
|
1204
|
+
const result = value_5;
|
|
1205
|
+
execution = ((result.tag === 9) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.choose chooser must return option"), defaultOf())));
|
|
1206
|
+
const continuation_1 = continuation;
|
|
1207
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1093
1211
|
}
|
|
1094
|
-
}, values)
|
|
1212
|
+
}, values);
|
|
1213
|
+
return Execution$1__get_IsImmediate(body_3) ? (new Execution$1(new Value(/* VList */ 5, [choose((x) => x, body_3.Value)]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_3) => {
|
|
1214
|
+
const execution_3 = body_3;
|
|
1215
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
1216
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [choose((x) => x, execution_3.Value)]), defaultOf());
|
|
1217
|
+
const continuation_4 = continuation_3;
|
|
1218
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
1219
|
+
return continuation_4(execution_2.Value);
|
|
1220
|
+
}
|
|
1221
|
+
else {
|
|
1222
|
+
return execution_2.Resume(continuation_4);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
return execution_3.Resume((value_8) => {
|
|
1227
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [choose((x) => x, value_8)]), defaultOf());
|
|
1228
|
+
const continuation_4 = continuation_3;
|
|
1229
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
}));
|
|
1233
|
+
}
|
|
1095
1234
|
default:
|
|
1096
|
-
return fail("List.choose expects (
|
|
1235
|
+
return new Execution$1(fail("List.choose expects (callback, values)"), defaultOf());
|
|
1097
1236
|
}
|
|
1098
|
-
}
|
|
1237
|
+
});
|
|
1099
1238
|
|
|
1100
|
-
const builtinListCollect =
|
|
1101
|
-
let matchResult,
|
|
1239
|
+
const builtinListCollect = resumable("List.collect", 2, (apply, args) => {
|
|
1240
|
+
let matchResult, callback, values;
|
|
1102
1241
|
if (!isEmpty(args)) {
|
|
1103
1242
|
if (!isEmpty(tail_1(args))) {
|
|
1104
1243
|
if (head_1(tail_1(args)).tag === 5) {
|
|
1105
1244
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
1106
1245
|
matchResult = 0;
|
|
1107
|
-
|
|
1246
|
+
callback = head_1(args);
|
|
1108
1247
|
values = head_1(tail_1(args)).fields[0];
|
|
1109
1248
|
}
|
|
1110
1249
|
else {
|
|
@@ -1123,22 +1262,67 @@ const builtinListCollect = new ExternalFunction("List.collect", scheme("List.col
|
|
|
1123
1262
|
matchResult = 1;
|
|
1124
1263
|
}
|
|
1125
1264
|
switch (matchResult) {
|
|
1126
|
-
case 0:
|
|
1127
|
-
|
|
1128
|
-
const
|
|
1129
|
-
if (
|
|
1130
|
-
|
|
1265
|
+
case 0: {
|
|
1266
|
+
const body_3 = Execution_map((value) => {
|
|
1267
|
+
const body_1 = apply(callback)(value);
|
|
1268
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
1269
|
+
const result = body_1.Value;
|
|
1270
|
+
return (result.tag === 5) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.collect collector must return list"), defaultOf()));
|
|
1131
1271
|
}
|
|
1132
1272
|
else {
|
|
1133
|
-
return
|
|
1273
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1274
|
+
const execution_1 = body_1;
|
|
1275
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1276
|
+
let execution;
|
|
1277
|
+
const result = execution_1.Value;
|
|
1278
|
+
execution = ((result.tag === 5) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.collect collector must return list"), defaultOf())));
|
|
1279
|
+
const continuation_1 = continuation;
|
|
1280
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1281
|
+
return continuation_1(execution.Value);
|
|
1282
|
+
}
|
|
1283
|
+
else {
|
|
1284
|
+
return execution.Resume(continuation_1);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
return execution_1.Resume((value_5) => {
|
|
1289
|
+
let execution;
|
|
1290
|
+
const result = value_5;
|
|
1291
|
+
execution = ((result.tag === 5) ? (new Execution$1(result.fields[0], defaultOf())) : (new Execution$1(fail("List.collect collector must return list"), defaultOf())));
|
|
1292
|
+
const continuation_1 = continuation;
|
|
1293
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1134
1297
|
}
|
|
1135
|
-
}, values)
|
|
1298
|
+
}, values);
|
|
1299
|
+
return Execution$1__get_IsImmediate(body_3) ? (new Execution$1(new Value(/* VList */ 5, [concat_1(body_3.Value)]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_3) => {
|
|
1300
|
+
const execution_3 = body_3;
|
|
1301
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
1302
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [concat_1(execution_3.Value)]), defaultOf());
|
|
1303
|
+
const continuation_4 = continuation_3;
|
|
1304
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
1305
|
+
return continuation_4(execution_2.Value);
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
return execution_2.Resume(continuation_4);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
return execution_3.Resume((value_8) => {
|
|
1313
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [concat_1(value_8)]), defaultOf());
|
|
1314
|
+
const continuation_4 = continuation_3;
|
|
1315
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
}));
|
|
1319
|
+
}
|
|
1136
1320
|
default:
|
|
1137
|
-
return fail("List.collect expects (
|
|
1321
|
+
return new Execution$1(fail("List.collect expects (callback, values)"), defaultOf());
|
|
1138
1322
|
}
|
|
1139
|
-
}
|
|
1323
|
+
});
|
|
1140
1324
|
|
|
1141
|
-
const builtinListExists =
|
|
1325
|
+
const builtinListExists = resumable("List.exists", 2, (apply, args) => {
|
|
1142
1326
|
let matchResult, predicate, values;
|
|
1143
1327
|
if (!isEmpty(args)) {
|
|
1144
1328
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1164,20 +1348,69 @@ const builtinListExists = new ExternalFunction("List.exists", scheme("List.exist
|
|
|
1164
1348
|
matchResult = 1;
|
|
1165
1349
|
}
|
|
1166
1350
|
switch (matchResult) {
|
|
1167
|
-
case 0:
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1351
|
+
case 0: {
|
|
1352
|
+
const find = (index_mut, remaining_mut) => {
|
|
1353
|
+
find:
|
|
1354
|
+
while (true) {
|
|
1355
|
+
const index = index_mut, remaining = remaining_mut;
|
|
1356
|
+
if (!isEmpty(remaining)) {
|
|
1357
|
+
const tail = tail_1(remaining);
|
|
1358
|
+
const body_2 = apply(predicate)(head_1(remaining));
|
|
1359
|
+
if (Execution$1__get_IsImmediate(body_2)) {
|
|
1360
|
+
const result = body_2.Value;
|
|
1361
|
+
if (result.tag === 3) {
|
|
1362
|
+
if (result.fields[0]) {
|
|
1363
|
+
return new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf());
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
index_mut = toInt64_unchecked(op_Addition(index, 1n));
|
|
1367
|
+
remaining_mut = tail;
|
|
1368
|
+
continue find;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
return new Execution$1(fail("List.exists predicate must return bool"), defaultOf());
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1377
|
+
const execution_1 = body_2;
|
|
1378
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1379
|
+
let execution;
|
|
1380
|
+
const result = execution_1.Value;
|
|
1381
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.exists predicate must return bool"), defaultOf())));
|
|
1382
|
+
const continuation_1 = continuation;
|
|
1383
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1384
|
+
return continuation_1(execution.Value);
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
return execution.Resume(continuation_1);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
return execution_1.Resume((value_6) => {
|
|
1392
|
+
let execution;
|
|
1393
|
+
const result = value_6;
|
|
1394
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.exists predicate must return bool"), defaultOf())));
|
|
1395
|
+
const continuation_1 = continuation;
|
|
1396
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
else {
|
|
1403
|
+
return new Execution$1(new Value(/* VBool */ 3, [false]), defaultOf());
|
|
1404
|
+
}
|
|
1405
|
+
break;
|
|
1175
1406
|
}
|
|
1176
|
-
}
|
|
1407
|
+
};
|
|
1408
|
+
return find(0n, values);
|
|
1409
|
+
}
|
|
1177
1410
|
default:
|
|
1178
|
-
return fail("List.exists expects (predicate, values)");
|
|
1411
|
+
return new Execution$1(fail("List.exists expects (predicate, values)"), defaultOf());
|
|
1179
1412
|
}
|
|
1180
|
-
}
|
|
1413
|
+
});
|
|
1181
1414
|
|
|
1182
1415
|
const builtinListContains = new ExternalFunction("List.contains", scheme("List.contains"), (_arg, args) => {
|
|
1183
1416
|
let matchResult, needle, values;
|
|
@@ -1206,7 +1439,7 @@ const builtinListContains = new ExternalFunction("List.contains", scheme("List.c
|
|
|
1206
1439
|
}
|
|
1207
1440
|
switch (matchResult) {
|
|
1208
1441
|
case 0:
|
|
1209
|
-
return new
|
|
1442
|
+
return new Value(/* VBool */ 3, [exists((value) => {
|
|
1210
1443
|
let matchResult_1, x, y, x_1, y_1, x_2, y_2, x_3, y_3;
|
|
1211
1444
|
switch (value.tag) {
|
|
1212
1445
|
case 0: {
|
|
@@ -1285,11 +1518,11 @@ const builtinListContains = new ExternalFunction("List.contains", scheme("List.c
|
|
|
1285
1518
|
}
|
|
1286
1519
|
}, 2);
|
|
1287
1520
|
|
|
1288
|
-
const builtinListRev = new ExternalFunction("List.rev", scheme("List.rev"), (_arg, args) => (new
|
|
1521
|
+
const builtinListRev = new ExternalFunction("List.rev", scheme("List.rev"), (_arg, args) => (new Value(/* VList */ 5, [reverse(expectList("List.rev", args))])), 1);
|
|
1289
1522
|
|
|
1290
|
-
const builtinListDistinct = new ExternalFunction("List.distinct", scheme("List.distinct"), (_arg, args) => (new
|
|
1523
|
+
const builtinListDistinct = new ExternalFunction("List.distinct", scheme("List.distinct"), (_arg, args) => (new Value(/* VList */ 5, [distinctValues(expectList("List.distinct", args))])), 1);
|
|
1291
1524
|
|
|
1292
|
-
const builtinListFold =
|
|
1525
|
+
const builtinListFold = resumable("List.fold", 3, (apply, args) => {
|
|
1293
1526
|
let matchResult, folder, state, values;
|
|
1294
1527
|
if (!isEmpty(args)) {
|
|
1295
1528
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1322,13 +1555,40 @@ const builtinListFold = new ExternalFunction("List.fold", scheme("List.fold"), (
|
|
|
1322
1555
|
}
|
|
1323
1556
|
switch (matchResult) {
|
|
1324
1557
|
case 0:
|
|
1325
|
-
return
|
|
1558
|
+
return Execution_fold((acc, value) => {
|
|
1559
|
+
const body_2 = apply(folder)(acc);
|
|
1560
|
+
if (Execution$1__get_IsImmediate(body_2)) {
|
|
1561
|
+
return apply(body_2.Value)(value);
|
|
1562
|
+
}
|
|
1563
|
+
else {
|
|
1564
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1565
|
+
const execution_1 = body_2;
|
|
1566
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1567
|
+
const execution = apply(execution_1.Value)(value);
|
|
1568
|
+
const continuation_1 = continuation;
|
|
1569
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1570
|
+
return continuation_1(execution.Value);
|
|
1571
|
+
}
|
|
1572
|
+
else {
|
|
1573
|
+
return execution.Resume(continuation_1);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
else {
|
|
1577
|
+
return execution_1.Resume((value_1) => {
|
|
1578
|
+
const execution = apply(value_1)(value);
|
|
1579
|
+
const continuation_1 = continuation;
|
|
1580
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}, state, values);
|
|
1326
1586
|
default:
|
|
1327
|
-
return fail("List.fold expects (folder, state, values)");
|
|
1587
|
+
return new Execution$1(fail("List.fold expects (folder, state, values)"), defaultOf());
|
|
1328
1588
|
}
|
|
1329
|
-
}
|
|
1589
|
+
});
|
|
1330
1590
|
|
|
1331
|
-
const builtinListFilter =
|
|
1591
|
+
const builtinListFilter = resumable("List.filter", 2, (apply, args) => {
|
|
1332
1592
|
let matchResult, predicate, values;
|
|
1333
1593
|
if (!isEmpty(args)) {
|
|
1334
1594
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1354,24 +1614,74 @@ const builtinListFilter = new ExternalFunction("List.filter", scheme("List.filte
|
|
|
1354
1614
|
matchResult = 1;
|
|
1355
1615
|
}
|
|
1356
1616
|
switch (matchResult) {
|
|
1357
|
-
case 0:
|
|
1358
|
-
|
|
1359
|
-
const
|
|
1360
|
-
if (
|
|
1361
|
-
|
|
1617
|
+
case 0: {
|
|
1618
|
+
const body_3 = Execution_map((value) => {
|
|
1619
|
+
const body_1 = apply(predicate)(value);
|
|
1620
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
1621
|
+
const result = body_1.Value;
|
|
1622
|
+
if (result.tag === 3) {
|
|
1623
|
+
return new Execution$1(result.fields[0] ? value : undefined, defaultOf());
|
|
1624
|
+
}
|
|
1625
|
+
else {
|
|
1626
|
+
return new Execution$1(fail("List.filter predicate must return bool"), defaultOf());
|
|
1627
|
+
}
|
|
1362
1628
|
}
|
|
1363
1629
|
else {
|
|
1364
|
-
return
|
|
1630
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1631
|
+
const execution_1 = body_1;
|
|
1632
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1633
|
+
let execution;
|
|
1634
|
+
const result = execution_1.Value;
|
|
1635
|
+
execution = ((result.tag === 3) ? (new Execution$1(result.fields[0] ? value : undefined, defaultOf())) : (new Execution$1(fail("List.filter predicate must return bool"), defaultOf())));
|
|
1636
|
+
const continuation_1 = continuation;
|
|
1637
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1638
|
+
return continuation_1(execution.Value);
|
|
1639
|
+
}
|
|
1640
|
+
else {
|
|
1641
|
+
return execution.Resume(continuation_1);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
else {
|
|
1645
|
+
return execution_1.Resume((value_5) => {
|
|
1646
|
+
let execution;
|
|
1647
|
+
const result = value_5;
|
|
1648
|
+
execution = ((result.tag === 3) ? (new Execution$1(result.fields[0] ? value : undefined, defaultOf())) : (new Execution$1(fail("List.filter predicate must return bool"), defaultOf())));
|
|
1649
|
+
const continuation_1 = continuation;
|
|
1650
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1365
1654
|
}
|
|
1366
|
-
}, values)
|
|
1655
|
+
}, values);
|
|
1656
|
+
return Execution$1__get_IsImmediate(body_3) ? (new Execution$1(new Value(/* VList */ 5, [choose((x) => x, body_3.Value)]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_3) => {
|
|
1657
|
+
const execution_3 = body_3;
|
|
1658
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
1659
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [choose((x) => x, execution_3.Value)]), defaultOf());
|
|
1660
|
+
const continuation_4 = continuation_3;
|
|
1661
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
1662
|
+
return continuation_4(execution_2.Value);
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
return execution_2.Resume(continuation_4);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
else {
|
|
1669
|
+
return execution_3.Resume((value_8) => {
|
|
1670
|
+
const execution_2 = new Execution$1(new Value(/* VList */ 5, [choose((x) => x, value_8)]), defaultOf());
|
|
1671
|
+
const continuation_4 = continuation_3;
|
|
1672
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
}));
|
|
1676
|
+
}
|
|
1367
1677
|
default:
|
|
1368
|
-
return fail("List.filter expects (predicate, values)");
|
|
1678
|
+
return new Execution$1(fail("List.filter expects (predicate, values)"), defaultOf());
|
|
1369
1679
|
}
|
|
1370
|
-
}
|
|
1680
|
+
});
|
|
1371
1681
|
|
|
1372
|
-
const builtinListLength = new ExternalFunction("List.length", scheme("List.length"), (_arg, args) => (new
|
|
1682
|
+
const builtinListLength = new ExternalFunction("List.length", scheme("List.length"), (_arg, args) => (new Value(/* VInt */ 1, [toInt64_unchecked(fromInt32(length_1(expectList("List.length", args))))])), 1);
|
|
1373
1683
|
|
|
1374
|
-
const builtinListTryFind =
|
|
1684
|
+
const builtinListTryFind = resumable("List.tryFind", 2, (apply, args) => {
|
|
1375
1685
|
let matchResult, predicate, values;
|
|
1376
1686
|
if (!isEmpty(args)) {
|
|
1377
1687
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1397,23 +1707,72 @@ const builtinListTryFind = new ExternalFunction("List.tryFind", scheme("List.try
|
|
|
1397
1707
|
matchResult = 1;
|
|
1398
1708
|
}
|
|
1399
1709
|
switch (matchResult) {
|
|
1400
|
-
case 0:
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1710
|
+
case 0: {
|
|
1711
|
+
const find = (index_mut, remaining_mut) => {
|
|
1712
|
+
find:
|
|
1713
|
+
while (true) {
|
|
1714
|
+
const index = index_mut, remaining = remaining_mut;
|
|
1715
|
+
if (!isEmpty(remaining)) {
|
|
1716
|
+
const tail = tail_1(remaining);
|
|
1717
|
+
const head = head_1(remaining);
|
|
1718
|
+
const body_2 = apply(predicate)(head);
|
|
1719
|
+
if (Execution$1__get_IsImmediate(body_2)) {
|
|
1720
|
+
const result = body_2.Value;
|
|
1721
|
+
if (result.tag === 3) {
|
|
1722
|
+
if (result.fields[0]) {
|
|
1723
|
+
return new Execution$1(new Value(/* VOption */ 9, [head]), defaultOf());
|
|
1724
|
+
}
|
|
1725
|
+
else {
|
|
1726
|
+
index_mut = toInt64_unchecked(op_Addition(index, 1n));
|
|
1727
|
+
remaining_mut = tail;
|
|
1728
|
+
continue find;
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
else {
|
|
1732
|
+
return new Execution$1(fail("List.tryFind predicate must return bool"), defaultOf());
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
else {
|
|
1736
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1737
|
+
const execution_1 = body_2;
|
|
1738
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1739
|
+
let execution;
|
|
1740
|
+
const result = execution_1.Value;
|
|
1741
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VOption */ 9, [head]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.tryFind predicate must return bool"), defaultOf())));
|
|
1742
|
+
const continuation_1 = continuation;
|
|
1743
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1744
|
+
return continuation_1(execution.Value);
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
return execution.Resume(continuation_1);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
return execution_1.Resume((value_6) => {
|
|
1752
|
+
let execution;
|
|
1753
|
+
const result = value_6;
|
|
1754
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VOption */ 9, [head]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.tryFind predicate must return bool"), defaultOf())));
|
|
1755
|
+
const continuation_1 = continuation;
|
|
1756
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
return new Execution$1(new Value(/* VOption */ 9, [undefined]), defaultOf());
|
|
1764
|
+
}
|
|
1765
|
+
break;
|
|
1408
1766
|
}
|
|
1409
|
-
}
|
|
1767
|
+
};
|
|
1768
|
+
return find(0n, values);
|
|
1769
|
+
}
|
|
1410
1770
|
default:
|
|
1411
|
-
return fail("List.tryFind expects (predicate, values)");
|
|
1771
|
+
return new Execution$1(fail("List.tryFind expects (predicate, values)"), defaultOf());
|
|
1412
1772
|
}
|
|
1413
|
-
}
|
|
1773
|
+
});
|
|
1414
1774
|
|
|
1415
|
-
const builtinListTryGet =
|
|
1416
|
-
let option_1;
|
|
1775
|
+
const builtinListTryGet = resumable("List.tryGet", 2, (apply, args) => {
|
|
1417
1776
|
let matchResult, predicate, values;
|
|
1418
1777
|
if (!isEmpty(args)) {
|
|
1419
1778
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1439,20 +1798,69 @@ const builtinListTryGet = new ExternalFunction("List.tryGet", scheme("List.tryGe
|
|
|
1439
1798
|
matchResult = 1;
|
|
1440
1799
|
}
|
|
1441
1800
|
switch (matchResult) {
|
|
1442
|
-
case 0:
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1801
|
+
case 0: {
|
|
1802
|
+
const find = (index_mut, remaining_mut) => {
|
|
1803
|
+
find:
|
|
1804
|
+
while (true) {
|
|
1805
|
+
const index = index_mut, remaining = remaining_mut;
|
|
1806
|
+
if (!isEmpty(remaining)) {
|
|
1807
|
+
const tail = tail_1(remaining);
|
|
1808
|
+
const body_2 = apply(predicate)(head_1(remaining));
|
|
1809
|
+
if (Execution$1__get_IsImmediate(body_2)) {
|
|
1810
|
+
const result = body_2.Value;
|
|
1811
|
+
if (result.tag === 3) {
|
|
1812
|
+
if (result.fields[0]) {
|
|
1813
|
+
return new Execution$1(new Value(/* VOption */ 9, [new Value(/* VInt */ 1, [index])]), defaultOf());
|
|
1814
|
+
}
|
|
1815
|
+
else {
|
|
1816
|
+
index_mut = toInt64_unchecked(op_Addition(index, 1n));
|
|
1817
|
+
remaining_mut = tail;
|
|
1818
|
+
continue find;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
else {
|
|
1822
|
+
return new Execution$1(fail("List.tryGet predicate must return bool"), defaultOf());
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
else {
|
|
1826
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
1827
|
+
const execution_1 = body_2;
|
|
1828
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1829
|
+
let execution;
|
|
1830
|
+
const result = execution_1.Value;
|
|
1831
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VOption */ 9, [new Value(/* VInt */ 1, [index])]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.tryGet predicate must return bool"), defaultOf())));
|
|
1832
|
+
const continuation_1 = continuation;
|
|
1833
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
1834
|
+
return continuation_1(execution.Value);
|
|
1835
|
+
}
|
|
1836
|
+
else {
|
|
1837
|
+
return execution.Resume(continuation_1);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
return execution_1.Resume((value_6) => {
|
|
1842
|
+
let execution;
|
|
1843
|
+
const result = value_6;
|
|
1844
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(new Value(/* VOption */ 9, [new Value(/* VInt */ 1, [index])]), defaultOf())) : find(toInt64_unchecked(op_Addition(index, 1n)), tail)) : (new Execution$1(fail("List.tryGet predicate must return bool"), defaultOf())));
|
|
1845
|
+
const continuation_1 = continuation;
|
|
1846
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
else {
|
|
1853
|
+
return new Execution$1(new Value(/* VOption */ 9, [undefined]), defaultOf());
|
|
1854
|
+
}
|
|
1855
|
+
break;
|
|
1450
1856
|
}
|
|
1451
|
-
}
|
|
1857
|
+
};
|
|
1858
|
+
return find(0n, values);
|
|
1859
|
+
}
|
|
1452
1860
|
default:
|
|
1453
|
-
return fail("List.tryGet expects (predicate, values)");
|
|
1861
|
+
return new Execution$1(fail("List.tryGet expects (predicate, values)"), defaultOf());
|
|
1454
1862
|
}
|
|
1455
|
-
}
|
|
1863
|
+
});
|
|
1456
1864
|
|
|
1457
1865
|
const builtinListTryItem = new ExternalFunction("List.tryItem", scheme("List.tryItem"), (_arg, args) => {
|
|
1458
1866
|
let matchResult, index, values;
|
|
@@ -1506,18 +1914,18 @@ const builtinListTryItem = new ExternalFunction("List.tryItem", scheme("List.try
|
|
|
1506
1914
|
break;
|
|
1507
1915
|
}
|
|
1508
1916
|
};
|
|
1509
|
-
return (compare_1(index, 0n) < 0) ? (new
|
|
1917
|
+
return (compare_1(index, 0n) < 0) ? (new Value(/* VOption */ 9, [undefined])) : (new Value(/* VOption */ 9, [loop(values, 0n)]));
|
|
1510
1918
|
}
|
|
1511
1919
|
default:
|
|
1512
1920
|
return fail("List.tryItem expects (index, values)");
|
|
1513
1921
|
}
|
|
1514
1922
|
}, 2);
|
|
1515
1923
|
|
|
1516
|
-
const builtinListTryHead = new ExternalFunction("List.tryHead", scheme("List.tryHead"), (_arg, args) => (new
|
|
1924
|
+
const builtinListTryHead = new ExternalFunction("List.tryHead", scheme("List.tryHead"), (_arg, args) => (new Value(/* VOption */ 9, [tryHead(expectList("List.tryHead", args))])), 1);
|
|
1517
1925
|
|
|
1518
1926
|
const builtinListTail = new ExternalFunction("List.tail", scheme("List.tail"), (_arg, args) => {
|
|
1519
1927
|
const matchValue = expectList("List.tail", args);
|
|
1520
|
-
return !isEmpty(matchValue) ? (new
|
|
1928
|
+
return !isEmpty(matchValue) ? (new Value(/* VList */ 5, [tail_1(matchValue)])) : fail("List.tail expects a non-empty list");
|
|
1521
1929
|
}, 1);
|
|
1522
1930
|
|
|
1523
1931
|
const builtinListAppend = new ExternalFunction("List.append", scheme("List.append"), (_arg, args) => {
|
|
@@ -1552,7 +1960,7 @@ const builtinListAppend = new ExternalFunction("List.append", scheme("List.appen
|
|
|
1552
1960
|
}
|
|
1553
1961
|
switch (matchResult) {
|
|
1554
1962
|
case 0:
|
|
1555
|
-
return new
|
|
1963
|
+
return new Value(/* VList */ 5, [append(left, right)]);
|
|
1556
1964
|
default:
|
|
1557
1965
|
return fail("List.append expects (left, right)");
|
|
1558
1966
|
}
|
|
@@ -1602,15 +2010,15 @@ const builtinOptionDefaultValue = new ExternalFunction("Option.defaultValue", sc
|
|
|
1602
2010
|
}
|
|
1603
2011
|
}, 2);
|
|
1604
2012
|
|
|
1605
|
-
const builtinOptionDefaultWith =
|
|
1606
|
-
let matchResult, current, fallback
|
|
2013
|
+
const builtinOptionDefaultWith = resumable("Option.defaultWith", 2, (apply, args) => {
|
|
2014
|
+
let matchResult, current, fallback;
|
|
1607
2015
|
if (!isEmpty(args)) {
|
|
1608
2016
|
if (!isEmpty(tail_1(args))) {
|
|
1609
2017
|
if (head_1(tail_1(args)).tag === 9) {
|
|
1610
2018
|
if (head_1(tail_1(args)).fields[0] == null) {
|
|
1611
2019
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
1612
2020
|
matchResult = 1;
|
|
1613
|
-
|
|
2021
|
+
fallback = head_1(args);
|
|
1614
2022
|
}
|
|
1615
2023
|
else {
|
|
1616
2024
|
matchResult = 2;
|
|
@@ -1619,7 +2027,6 @@ const builtinOptionDefaultWith = new ExternalFunction("Option.defaultWith", sche
|
|
|
1619
2027
|
else if (isEmpty(tail_1(tail_1(args)))) {
|
|
1620
2028
|
matchResult = 0;
|
|
1621
2029
|
current = head_1(tail_1(args)).fields[0];
|
|
1622
|
-
fallback = head_1(args);
|
|
1623
2030
|
}
|
|
1624
2031
|
else {
|
|
1625
2032
|
matchResult = 2;
|
|
@@ -1638,13 +2045,13 @@ const builtinOptionDefaultWith = new ExternalFunction("Option.defaultWith", sche
|
|
|
1638
2045
|
}
|
|
1639
2046
|
switch (matchResult) {
|
|
1640
2047
|
case 0:
|
|
1641
|
-
return current;
|
|
2048
|
+
return new Execution$1(current, defaultOf());
|
|
1642
2049
|
case 1:
|
|
1643
|
-
return
|
|
2050
|
+
return apply(fallback)(Value.VUnit);
|
|
1644
2051
|
default:
|
|
1645
|
-
return fail("Option.defaultWith expects (fallback, value)");
|
|
2052
|
+
return new Execution$1(fail("Option.defaultWith expects (fallback, value)"), defaultOf());
|
|
1646
2053
|
}
|
|
1647
|
-
}
|
|
2054
|
+
});
|
|
1648
2055
|
|
|
1649
2056
|
const builtinOptionIsNone = new ExternalFunction("Option.isNone", scheme("Option.isNone"), (_arg, args) => {
|
|
1650
2057
|
let matchResult;
|
|
@@ -1674,9 +2081,9 @@ const builtinOptionIsNone = new ExternalFunction("Option.isNone", scheme("Option
|
|
|
1674
2081
|
}
|
|
1675
2082
|
switch (matchResult) {
|
|
1676
2083
|
case 0:
|
|
1677
|
-
return new
|
|
2084
|
+
return new Value(/* VBool */ 3, [true]);
|
|
1678
2085
|
case 1:
|
|
1679
|
-
return new
|
|
2086
|
+
return new Value(/* VBool */ 3, [false]);
|
|
1680
2087
|
default:
|
|
1681
2088
|
return fail("Option.isNone expects (value)");
|
|
1682
2089
|
}
|
|
@@ -1710,15 +2117,15 @@ const builtinOptionIsSome = new ExternalFunction("Option.isSome", scheme("Option
|
|
|
1710
2117
|
}
|
|
1711
2118
|
switch (matchResult) {
|
|
1712
2119
|
case 0:
|
|
1713
|
-
return new
|
|
2120
|
+
return new Value(/* VBool */ 3, [false]);
|
|
1714
2121
|
case 1:
|
|
1715
|
-
return new
|
|
2122
|
+
return new Value(/* VBool */ 3, [true]);
|
|
1716
2123
|
default:
|
|
1717
2124
|
return fail("Option.isSome expects (value)");
|
|
1718
2125
|
}
|
|
1719
2126
|
}, 1);
|
|
1720
2127
|
|
|
1721
|
-
const builtinOptionMap =
|
|
2128
|
+
const builtinOptionMap = resumable("Option.map", 2, (apply, args) => {
|
|
1722
2129
|
let matchResult, current, mapper;
|
|
1723
2130
|
if (!isEmpty(args)) {
|
|
1724
2131
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1752,16 +2159,37 @@ const builtinOptionMap = new ExternalFunction("Option.map", scheme("Option.map")
|
|
|
1752
2159
|
matchResult = 2;
|
|
1753
2160
|
}
|
|
1754
2161
|
switch (matchResult) {
|
|
1755
|
-
case 0:
|
|
1756
|
-
|
|
2162
|
+
case 0: {
|
|
2163
|
+
const body_1 = apply(mapper)(current);
|
|
2164
|
+
return Execution$1__get_IsImmediate(body_1) ? (new Execution$1(new Value(/* VOption */ 9, [body_1.Value]), defaultOf())) : (new Execution$1(defaultOf(), (continuation) => {
|
|
2165
|
+
const execution_1 = body_1;
|
|
2166
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2167
|
+
const execution = new Execution$1(new Value(/* VOption */ 9, [execution_1.Value]), defaultOf());
|
|
2168
|
+
const continuation_1 = continuation;
|
|
2169
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2170
|
+
return continuation_1(execution.Value);
|
|
2171
|
+
}
|
|
2172
|
+
else {
|
|
2173
|
+
return execution.Resume(continuation_1);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
else {
|
|
2177
|
+
return execution_1.Resume((value_2) => {
|
|
2178
|
+
const execution = new Execution$1(new Value(/* VOption */ 9, [value_2]), defaultOf());
|
|
2179
|
+
const continuation_1 = continuation;
|
|
2180
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
}));
|
|
2184
|
+
}
|
|
1757
2185
|
case 1:
|
|
1758
|
-
return new
|
|
2186
|
+
return new Execution$1(new Value(/* VOption */ 9, [undefined]), defaultOf());
|
|
1759
2187
|
default:
|
|
1760
|
-
return fail("Option.map expects (mapper, value)");
|
|
2188
|
+
return new Execution$1(fail("Option.map expects (mapper, value)"), defaultOf());
|
|
1761
2189
|
}
|
|
1762
|
-
}
|
|
2190
|
+
});
|
|
1763
2191
|
|
|
1764
|
-
const builtinMapEmpty = new ExternalFunction("Map.empty", scheme("Map.empty"), (_arg, _arg_1) => (new
|
|
2192
|
+
const builtinMapEmpty = new ExternalFunction("Map.empty", scheme("Map.empty"), (_arg, _arg_1) => (new Value(/* VMap */ 8, [empty_1({
|
|
1765
2193
|
Compare: (x, y) => (compare(x, y) | 0),
|
|
1766
2194
|
})])), 0);
|
|
1767
2195
|
|
|
@@ -1792,7 +2220,7 @@ const builtinMapTryGet = new ExternalFunction("Map.tryGet", scheme("Map.tryGet")
|
|
|
1792
2220
|
}
|
|
1793
2221
|
switch (matchResult) {
|
|
1794
2222
|
case 0:
|
|
1795
|
-
return new
|
|
2223
|
+
return new Value(/* VOption */ 9, [FSharpMap__TryFind(values, valueToMapKey("Map.tryGet", key))]);
|
|
1796
2224
|
default:
|
|
1797
2225
|
return fail("Map.tryGet expects (key, values)");
|
|
1798
2226
|
}
|
|
@@ -1825,7 +2253,7 @@ const builtinMapContainsKey = new ExternalFunction("Map.containsKey", scheme("Ma
|
|
|
1825
2253
|
}
|
|
1826
2254
|
switch (matchResult) {
|
|
1827
2255
|
case 0:
|
|
1828
|
-
return new
|
|
2256
|
+
return new Value(/* VBool */ 3, [FSharpMap__ContainsKey(values, valueToMapKey("Map.containsKey", key))]);
|
|
1829
2257
|
default:
|
|
1830
2258
|
return fail("Map.containsKey expects (key, values)");
|
|
1831
2259
|
}
|
|
@@ -1864,7 +2292,7 @@ const builtinMapAdd = new ExternalFunction("Map.add", scheme("Map.add"), (_arg,
|
|
|
1864
2292
|
}
|
|
1865
2293
|
switch (matchResult) {
|
|
1866
2294
|
case 0:
|
|
1867
|
-
return new
|
|
2295
|
+
return new Value(/* VMap */ 8, [FSharpMap__Add(values, valueToMapKey("Map.add", key), value)]);
|
|
1868
2296
|
default:
|
|
1869
2297
|
return fail("Map.add expects (key, value, values)");
|
|
1870
2298
|
}
|
|
@@ -1891,7 +2319,7 @@ const builtinMapOfList = new ExternalFunction("Map.ofList", scheme("Map.ofList")
|
|
|
1891
2319
|
}
|
|
1892
2320
|
switch (matchResult) {
|
|
1893
2321
|
case 0:
|
|
1894
|
-
return new
|
|
2322
|
+
return new Value(/* VMap */ 8, [fold((state, entry) => {
|
|
1895
2323
|
let matchResult_1, key, value;
|
|
1896
2324
|
if (entry.tag === 6) {
|
|
1897
2325
|
if (!isEmpty(entry.fields[0])) {
|
|
@@ -1930,7 +2358,7 @@ const builtinMapOfList = new ExternalFunction("Map.ofList", scheme("Map.ofList")
|
|
|
1930
2358
|
}
|
|
1931
2359
|
}, 1);
|
|
1932
2360
|
|
|
1933
|
-
const builtinMapFold =
|
|
2361
|
+
const builtinMapFold = resumable("Map.fold", 3, (apply, args) => {
|
|
1934
2362
|
let matchResult, folder, state, values;
|
|
1935
2363
|
if (!isEmpty(args)) {
|
|
1936
2364
|
if (!isEmpty(tail_1(args))) {
|
|
@@ -1963,22 +2391,118 @@ const builtinMapFold = new ExternalFunction("Map.fold", scheme("Map.fold"), (ctx
|
|
|
1963
2391
|
}
|
|
1964
2392
|
switch (matchResult) {
|
|
1965
2393
|
case 0:
|
|
1966
|
-
return
|
|
2394
|
+
return Execution_fold((acc, tupledArg) => {
|
|
2395
|
+
const key = tupledArg[0];
|
|
2396
|
+
const value = tupledArg[1];
|
|
2397
|
+
const body_4 = apply(folder)(acc);
|
|
2398
|
+
if (Execution$1__get_IsImmediate(body_4)) {
|
|
2399
|
+
const body_2 = apply(body_4.Value)(mapKeyToValue(key));
|
|
2400
|
+
if (Execution$1__get_IsImmediate(body_2)) {
|
|
2401
|
+
return apply(body_2.Value)(value);
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
2405
|
+
const execution_1 = body_2;
|
|
2406
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2407
|
+
const execution = apply(execution_1.Value)(value);
|
|
2408
|
+
const continuation_1 = continuation;
|
|
2409
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2410
|
+
return continuation_1(execution.Value);
|
|
2411
|
+
}
|
|
2412
|
+
else {
|
|
2413
|
+
return execution.Resume(continuation_1);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
else {
|
|
2417
|
+
return execution_1.Resume((value_1) => {
|
|
2418
|
+
const execution = apply(value_1)(value);
|
|
2419
|
+
const continuation_1 = continuation;
|
|
2420
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
else {
|
|
2427
|
+
return new Execution$1(defaultOf(), (continuation_3) => {
|
|
2428
|
+
const execution_3 = body_4;
|
|
2429
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
2430
|
+
let execution_2;
|
|
2431
|
+
const body_2 = apply(execution_3.Value)(mapKeyToValue(key));
|
|
2432
|
+
execution_2 = (Execution$1__get_IsImmediate(body_2) ? apply(body_2.Value)(value) : (new Execution$1(defaultOf(), (continuation) => {
|
|
2433
|
+
const execution_1 = body_2;
|
|
2434
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2435
|
+
const execution = apply(execution_1.Value)(value);
|
|
2436
|
+
const continuation_1 = continuation;
|
|
2437
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2438
|
+
return continuation_1(execution.Value);
|
|
2439
|
+
}
|
|
2440
|
+
else {
|
|
2441
|
+
return execution.Resume(continuation_1);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
else {
|
|
2445
|
+
return execution_1.Resume((value_1) => {
|
|
2446
|
+
const execution = apply(value_1)(value);
|
|
2447
|
+
const continuation_1 = continuation;
|
|
2448
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
})));
|
|
2452
|
+
const continuation_4 = continuation_3;
|
|
2453
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
2454
|
+
return continuation_4(execution_2.Value);
|
|
2455
|
+
}
|
|
2456
|
+
else {
|
|
2457
|
+
return execution_2.Resume(continuation_4);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2461
|
+
return execution_3.Resume((value_2) => {
|
|
2462
|
+
let execution_2;
|
|
2463
|
+
const body_2 = apply(value_2)(mapKeyToValue(key));
|
|
2464
|
+
execution_2 = (Execution$1__get_IsImmediate(body_2) ? apply(body_2.Value)(value) : (new Execution$1(defaultOf(), (continuation) => {
|
|
2465
|
+
const execution_1 = body_2;
|
|
2466
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2467
|
+
const execution = apply(execution_1.Value)(value);
|
|
2468
|
+
const continuation_1 = continuation;
|
|
2469
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2470
|
+
return continuation_1(execution.Value);
|
|
2471
|
+
}
|
|
2472
|
+
else {
|
|
2473
|
+
return execution.Resume(continuation_1);
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
else {
|
|
2477
|
+
return execution_1.Resume((value_1) => {
|
|
2478
|
+
const execution = apply(value_1)(value);
|
|
2479
|
+
const continuation_1 = continuation;
|
|
2480
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
})));
|
|
2484
|
+
const continuation_4 = continuation_3;
|
|
2485
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
}, state, toList(values));
|
|
1967
2491
|
default:
|
|
1968
|
-
return fail("Map.fold expects (folder, state, values)");
|
|
2492
|
+
return new Execution$1(fail("Map.fold expects (folder, state, values)"), defaultOf());
|
|
1969
2493
|
}
|
|
1970
|
-
}
|
|
2494
|
+
});
|
|
1971
2495
|
|
|
1972
|
-
const builtinMapCount = new ExternalFunction("Map.count", scheme("Map.count"), (_arg, args) => (new
|
|
2496
|
+
const builtinMapCount = new ExternalFunction("Map.count", scheme("Map.count"), (_arg, args) => (new Value(/* VInt */ 1, [toInt64_unchecked(fromInt32(FSharpMap__get_Count(expectMap("Map.count", args))))])), 1);
|
|
1973
2497
|
|
|
1974
|
-
const builtinMapFilter =
|
|
1975
|
-
let matchResult,
|
|
2498
|
+
const builtinMapFilter = resumable("Map.filter", 2, (apply, args) => {
|
|
2499
|
+
let matchResult, callback, values;
|
|
1976
2500
|
if (!isEmpty(args)) {
|
|
1977
2501
|
if (!isEmpty(tail_1(args))) {
|
|
1978
2502
|
if (head_1(tail_1(args)).tag === 8) {
|
|
1979
2503
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
1980
2504
|
matchResult = 0;
|
|
1981
|
-
|
|
2505
|
+
callback = head_1(args);
|
|
1982
2506
|
values = head_1(tail_1(args)).fields[0];
|
|
1983
2507
|
}
|
|
1984
2508
|
else {
|
|
@@ -1997,36 +2521,177 @@ const builtinMapFilter = new ExternalFunction("Map.filter", scheme("Map.filter")
|
|
|
1997
2521
|
matchResult = 1;
|
|
1998
2522
|
}
|
|
1999
2523
|
switch (matchResult) {
|
|
2000
|
-
case 0:
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2524
|
+
case 0: {
|
|
2525
|
+
let body_5;
|
|
2526
|
+
const items = toList(values);
|
|
2527
|
+
body_5 = Execution_fold((acc, tupledArg) => {
|
|
2528
|
+
const key = tupledArg[0];
|
|
2529
|
+
const value = tupledArg[1];
|
|
2530
|
+
const body_3 = apply(callback)(mapKeyToValue(key));
|
|
2531
|
+
if (Execution$1__get_IsImmediate(body_3)) {
|
|
2532
|
+
const body_1 = apply(body_3.Value)(value);
|
|
2533
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2534
|
+
const result = body_1.Value;
|
|
2535
|
+
if (result.tag === 3) {
|
|
2536
|
+
if (result.fields[0]) {
|
|
2537
|
+
return new Execution$1(add(key, value, acc), defaultOf());
|
|
2538
|
+
}
|
|
2539
|
+
else {
|
|
2540
|
+
return new Execution$1(acc, defaultOf());
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
else {
|
|
2544
|
+
return new Execution$1(fail("Map.filter predicate must return bool"), defaultOf());
|
|
2545
|
+
}
|
|
2006
2546
|
}
|
|
2007
2547
|
else {
|
|
2008
|
-
return
|
|
2548
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
2549
|
+
const execution_1 = body_1;
|
|
2550
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2551
|
+
let execution;
|
|
2552
|
+
const result = execution_1.Value;
|
|
2553
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2554
|
+
const continuation_1 = continuation;
|
|
2555
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2556
|
+
return continuation_1(execution.Value);
|
|
2557
|
+
}
|
|
2558
|
+
else {
|
|
2559
|
+
return execution.Resume(continuation_1);
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
else {
|
|
2563
|
+
return execution_1.Resume((value_7) => {
|
|
2564
|
+
let execution;
|
|
2565
|
+
const result = value_7;
|
|
2566
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2567
|
+
const continuation_1 = continuation;
|
|
2568
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
});
|
|
2009
2572
|
}
|
|
2010
2573
|
}
|
|
2011
2574
|
else {
|
|
2012
|
-
return
|
|
2575
|
+
return new Execution$1(defaultOf(), (continuation_3) => {
|
|
2576
|
+
const execution_3 = body_3;
|
|
2577
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
2578
|
+
let execution_2;
|
|
2579
|
+
const body_1 = apply(execution_3.Value)(value);
|
|
2580
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2581
|
+
const result = body_1.Value;
|
|
2582
|
+
execution_2 = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2583
|
+
}
|
|
2584
|
+
else {
|
|
2585
|
+
execution_2 = (new Execution$1(defaultOf(), (continuation) => {
|
|
2586
|
+
const execution_1 = body_1;
|
|
2587
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2588
|
+
let execution;
|
|
2589
|
+
const result = execution_1.Value;
|
|
2590
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2591
|
+
const continuation_1 = continuation;
|
|
2592
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2593
|
+
return continuation_1(execution.Value);
|
|
2594
|
+
}
|
|
2595
|
+
else {
|
|
2596
|
+
return execution.Resume(continuation_1);
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
else {
|
|
2600
|
+
return execution_1.Resume((value_7) => {
|
|
2601
|
+
let execution;
|
|
2602
|
+
const result = value_7;
|
|
2603
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2604
|
+
const continuation_1 = continuation;
|
|
2605
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
}));
|
|
2609
|
+
}
|
|
2610
|
+
const continuation_4 = continuation_3;
|
|
2611
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
2612
|
+
return continuation_4(execution_2.Value);
|
|
2613
|
+
}
|
|
2614
|
+
else {
|
|
2615
|
+
return execution_2.Resume(continuation_4);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
else {
|
|
2619
|
+
return execution_3.Resume((value_8) => {
|
|
2620
|
+
let execution_2;
|
|
2621
|
+
const body_1 = apply(value_8)(value);
|
|
2622
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2623
|
+
const result = body_1.Value;
|
|
2624
|
+
execution_2 = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2625
|
+
}
|
|
2626
|
+
else {
|
|
2627
|
+
execution_2 = (new Execution$1(defaultOf(), (continuation) => {
|
|
2628
|
+
const execution_1 = body_1;
|
|
2629
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2630
|
+
let execution;
|
|
2631
|
+
const result = execution_1.Value;
|
|
2632
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2633
|
+
const continuation_1 = continuation;
|
|
2634
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2635
|
+
return continuation_1(execution.Value);
|
|
2636
|
+
}
|
|
2637
|
+
else {
|
|
2638
|
+
return execution.Resume(continuation_1);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
else {
|
|
2642
|
+
return execution_1.Resume((value_7) => {
|
|
2643
|
+
let execution;
|
|
2644
|
+
const result = value_7;
|
|
2645
|
+
execution = ((result.tag === 3) ? (result.fields[0] ? (new Execution$1(add(key, value, acc), defaultOf())) : (new Execution$1(acc, defaultOf()))) : (new Execution$1(fail("Map.filter predicate must return bool"), defaultOf())));
|
|
2646
|
+
const continuation_1 = continuation;
|
|
2647
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
}));
|
|
2651
|
+
}
|
|
2652
|
+
const continuation_4 = continuation_3;
|
|
2653
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
});
|
|
2013
2657
|
}
|
|
2014
2658
|
}, empty_1({
|
|
2015
2659
|
Compare: (x, y) => (compare(x, y) | 0),
|
|
2016
|
-
}),
|
|
2660
|
+
}), items);
|
|
2661
|
+
return Execution$1__get_IsImmediate(body_5) ? (new Execution$1(new Value(/* VMap */ 8, [body_5.Value]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_6) => {
|
|
2662
|
+
const execution_5 = body_5;
|
|
2663
|
+
if (Execution$1__get_IsImmediate(execution_5)) {
|
|
2664
|
+
const execution_4 = new Execution$1(new Value(/* VMap */ 8, [execution_5.Value]), defaultOf());
|
|
2665
|
+
const continuation_7 = continuation_6;
|
|
2666
|
+
if (Execution$1__get_IsImmediate(execution_4)) {
|
|
2667
|
+
return continuation_7(execution_4.Value);
|
|
2668
|
+
}
|
|
2669
|
+
else {
|
|
2670
|
+
return execution_4.Resume(continuation_7);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
else {
|
|
2674
|
+
return execution_5.Resume((value_11) => {
|
|
2675
|
+
const execution_4 = new Execution$1(new Value(/* VMap */ 8, [value_11]), defaultOf());
|
|
2676
|
+
const continuation_7 = continuation_6;
|
|
2677
|
+
return Execution$1__get_IsImmediate(execution_4) ? continuation_7(execution_4.Value) : execution_4.Resume(continuation_7);
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
}));
|
|
2681
|
+
}
|
|
2017
2682
|
default:
|
|
2018
|
-
return fail("Map.filter expects (
|
|
2683
|
+
return new Execution$1(fail("Map.filter expects (callback, values)"), defaultOf());
|
|
2019
2684
|
}
|
|
2020
|
-
}
|
|
2685
|
+
});
|
|
2021
2686
|
|
|
2022
|
-
const builtinMapChoose =
|
|
2023
|
-
let matchResult,
|
|
2687
|
+
const builtinMapChoose = resumable("Map.choose", 2, (apply, args) => {
|
|
2688
|
+
let matchResult, callback, values;
|
|
2024
2689
|
if (!isEmpty(args)) {
|
|
2025
2690
|
if (!isEmpty(tail_1(args))) {
|
|
2026
2691
|
if (head_1(tail_1(args)).tag === 8) {
|
|
2027
2692
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
2028
2693
|
matchResult = 0;
|
|
2029
|
-
|
|
2694
|
+
callback = head_1(args);
|
|
2030
2695
|
values = head_1(tail_1(args)).fields[0];
|
|
2031
2696
|
}
|
|
2032
2697
|
else {
|
|
@@ -2045,37 +2710,186 @@ const builtinMapChoose = new ExternalFunction("Map.choose", scheme("Map.choose")
|
|
|
2045
2710
|
matchResult = 1;
|
|
2046
2711
|
}
|
|
2047
2712
|
switch (matchResult) {
|
|
2048
|
-
case 0:
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2713
|
+
case 0: {
|
|
2714
|
+
let body_5;
|
|
2715
|
+
const items = toList(values);
|
|
2716
|
+
body_5 = Execution_fold((acc, tupledArg) => {
|
|
2717
|
+
const key = tupledArg[0];
|
|
2718
|
+
const value = tupledArg[1];
|
|
2719
|
+
const body_3 = apply(callback)(mapKeyToValue(key));
|
|
2720
|
+
if (Execution$1__get_IsImmediate(body_3)) {
|
|
2721
|
+
const body_1 = apply(body_3.Value)(value);
|
|
2722
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2723
|
+
const result = body_1.Value;
|
|
2724
|
+
if (result.tag === 9) {
|
|
2725
|
+
if (result.fields[0] == null) {
|
|
2726
|
+
return new Execution$1(acc, defaultOf());
|
|
2727
|
+
}
|
|
2728
|
+
else {
|
|
2729
|
+
const chosen = result.fields[0];
|
|
2730
|
+
return new Execution$1(add(key, chosen, acc), defaultOf());
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
else {
|
|
2734
|
+
return new Execution$1(fail("Map.choose chooser must return option"), defaultOf());
|
|
2735
|
+
}
|
|
2054
2736
|
}
|
|
2055
2737
|
else {
|
|
2056
|
-
|
|
2057
|
-
|
|
2738
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
2739
|
+
let chosen;
|
|
2740
|
+
const execution_1 = body_1;
|
|
2741
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2742
|
+
let execution;
|
|
2743
|
+
const result = execution_1.Value;
|
|
2744
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2745
|
+
const continuation_1 = continuation;
|
|
2746
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2747
|
+
return continuation_1(execution.Value);
|
|
2748
|
+
}
|
|
2749
|
+
else {
|
|
2750
|
+
return execution.Resume(continuation_1);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
else {
|
|
2754
|
+
return execution_1.Resume((value_7) => {
|
|
2755
|
+
let chosen;
|
|
2756
|
+
let execution;
|
|
2757
|
+
const result = value_7;
|
|
2758
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2759
|
+
const continuation_1 = continuation;
|
|
2760
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2761
|
+
});
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2058
2764
|
}
|
|
2059
2765
|
}
|
|
2060
2766
|
else {
|
|
2061
|
-
return
|
|
2767
|
+
return new Execution$1(defaultOf(), (continuation_3) => {
|
|
2768
|
+
let chosen;
|
|
2769
|
+
const execution_3 = body_3;
|
|
2770
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
2771
|
+
let execution_2;
|
|
2772
|
+
const body_1 = apply(execution_3.Value)(value);
|
|
2773
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2774
|
+
const result = body_1.Value;
|
|
2775
|
+
execution_2 = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2776
|
+
}
|
|
2777
|
+
else {
|
|
2778
|
+
execution_2 = (new Execution$1(defaultOf(), (continuation) => {
|
|
2779
|
+
let chosen;
|
|
2780
|
+
const execution_1 = body_1;
|
|
2781
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2782
|
+
let execution;
|
|
2783
|
+
const result = execution_1.Value;
|
|
2784
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2785
|
+
const continuation_1 = continuation;
|
|
2786
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2787
|
+
return continuation_1(execution.Value);
|
|
2788
|
+
}
|
|
2789
|
+
else {
|
|
2790
|
+
return execution.Resume(continuation_1);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
else {
|
|
2794
|
+
return execution_1.Resume((value_7) => {
|
|
2795
|
+
let chosen;
|
|
2796
|
+
let execution;
|
|
2797
|
+
const result = value_7;
|
|
2798
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2799
|
+
const continuation_1 = continuation;
|
|
2800
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
}));
|
|
2804
|
+
}
|
|
2805
|
+
const continuation_4 = continuation_3;
|
|
2806
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
2807
|
+
return continuation_4(execution_2.Value);
|
|
2808
|
+
}
|
|
2809
|
+
else {
|
|
2810
|
+
return execution_2.Resume(continuation_4);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
else {
|
|
2814
|
+
return execution_3.Resume((value_8) => {
|
|
2815
|
+
let chosen;
|
|
2816
|
+
let execution_2;
|
|
2817
|
+
const body_1 = apply(value_8)(value);
|
|
2818
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2819
|
+
const result = body_1.Value;
|
|
2820
|
+
execution_2 = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2821
|
+
}
|
|
2822
|
+
else {
|
|
2823
|
+
execution_2 = (new Execution$1(defaultOf(), (continuation) => {
|
|
2824
|
+
let chosen;
|
|
2825
|
+
const execution_1 = body_1;
|
|
2826
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2827
|
+
let execution;
|
|
2828
|
+
const result = execution_1.Value;
|
|
2829
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2830
|
+
const continuation_1 = continuation;
|
|
2831
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2832
|
+
return continuation_1(execution.Value);
|
|
2833
|
+
}
|
|
2834
|
+
else {
|
|
2835
|
+
return execution.Resume(continuation_1);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
else {
|
|
2839
|
+
return execution_1.Resume((value_7) => {
|
|
2840
|
+
let chosen;
|
|
2841
|
+
let execution;
|
|
2842
|
+
const result = value_7;
|
|
2843
|
+
execution = ((result.tag === 9) ? ((result.fields[0] == null) ? (new Execution$1(acc, defaultOf())) : ((chosen = result.fields[0], new Execution$1(add(key, chosen, acc), defaultOf())))) : (new Execution$1(fail("Map.choose chooser must return option"), defaultOf())));
|
|
2844
|
+
const continuation_1 = continuation;
|
|
2845
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
}));
|
|
2849
|
+
}
|
|
2850
|
+
const continuation_4 = continuation_3;
|
|
2851
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
2852
|
+
});
|
|
2853
|
+
}
|
|
2854
|
+
});
|
|
2062
2855
|
}
|
|
2063
2856
|
}, empty_1({
|
|
2064
2857
|
Compare: (x, y) => (compare(x, y) | 0),
|
|
2065
|
-
}),
|
|
2858
|
+
}), items);
|
|
2859
|
+
return Execution$1__get_IsImmediate(body_5) ? (new Execution$1(new Value(/* VMap */ 8, [body_5.Value]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_6) => {
|
|
2860
|
+
const execution_5 = body_5;
|
|
2861
|
+
if (Execution$1__get_IsImmediate(execution_5)) {
|
|
2862
|
+
const execution_4 = new Execution$1(new Value(/* VMap */ 8, [execution_5.Value]), defaultOf());
|
|
2863
|
+
const continuation_7 = continuation_6;
|
|
2864
|
+
if (Execution$1__get_IsImmediate(execution_4)) {
|
|
2865
|
+
return continuation_7(execution_4.Value);
|
|
2866
|
+
}
|
|
2867
|
+
else {
|
|
2868
|
+
return execution_4.Resume(continuation_7);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
else {
|
|
2872
|
+
return execution_5.Resume((value_11) => {
|
|
2873
|
+
const execution_4 = new Execution$1(new Value(/* VMap */ 8, [value_11]), defaultOf());
|
|
2874
|
+
const continuation_7 = continuation_6;
|
|
2875
|
+
return Execution$1__get_IsImmediate(execution_4) ? continuation_7(execution_4.Value) : execution_4.Resume(continuation_7);
|
|
2876
|
+
});
|
|
2877
|
+
}
|
|
2878
|
+
}));
|
|
2879
|
+
}
|
|
2066
2880
|
default:
|
|
2067
|
-
return fail("Map.choose expects (
|
|
2881
|
+
return new Execution$1(fail("Map.choose expects (callback, values)"), defaultOf());
|
|
2068
2882
|
}
|
|
2069
|
-
}
|
|
2883
|
+
});
|
|
2070
2884
|
|
|
2071
|
-
const builtinMapMap =
|
|
2072
|
-
let matchResult,
|
|
2885
|
+
const builtinMapMap = resumable("Map.map", 2, (apply, args) => {
|
|
2886
|
+
let matchResult, callback, values;
|
|
2073
2887
|
if (!isEmpty(args)) {
|
|
2074
2888
|
if (!isEmpty(tail_1(args))) {
|
|
2075
2889
|
if (head_1(tail_1(args)).tag === 8) {
|
|
2076
2890
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
2077
2891
|
matchResult = 0;
|
|
2078
|
-
|
|
2892
|
+
callback = head_1(args);
|
|
2079
2893
|
values = head_1(tail_1(args)).fields[0];
|
|
2080
2894
|
}
|
|
2081
2895
|
else {
|
|
@@ -2094,23 +2908,74 @@ const builtinMapMap = new ExternalFunction("Map.map", scheme("Map.map"), (ctx, a
|
|
|
2094
2908
|
matchResult = 1;
|
|
2095
2909
|
}
|
|
2096
2910
|
switch (matchResult) {
|
|
2097
|
-
case 0:
|
|
2098
|
-
|
|
2911
|
+
case 0: {
|
|
2912
|
+
let body_3;
|
|
2913
|
+
const items = toList(values);
|
|
2914
|
+
body_3 = Execution_fold((acc, tupledArg) => {
|
|
2915
|
+
const key = tupledArg[0];
|
|
2916
|
+
const body_1 = apply(callback)(tupledArg[1]);
|
|
2917
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2918
|
+
return new Execution$1(add(key, body_1.Value, acc), defaultOf());
|
|
2919
|
+
}
|
|
2920
|
+
else {
|
|
2921
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
2922
|
+
const execution_1 = body_1;
|
|
2923
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2924
|
+
const execution = new Execution$1(add(key, execution_1.Value, acc), defaultOf());
|
|
2925
|
+
const continuation_1 = continuation;
|
|
2926
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
2927
|
+
return continuation_1(execution.Value);
|
|
2928
|
+
}
|
|
2929
|
+
else {
|
|
2930
|
+
return execution.Resume(continuation_1);
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
else {
|
|
2934
|
+
return execution_1.Resume((value_3) => {
|
|
2935
|
+
const execution = new Execution$1(add(key, value_3, acc), defaultOf());
|
|
2936
|
+
const continuation_1 = continuation;
|
|
2937
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
}, empty_1({
|
|
2099
2943
|
Compare: (x, y) => (compare(x, y) | 0),
|
|
2100
|
-
}),
|
|
2944
|
+
}), items);
|
|
2945
|
+
return Execution$1__get_IsImmediate(body_3) ? (new Execution$1(new Value(/* VMap */ 8, [body_3.Value]), defaultOf())) : (new Execution$1(defaultOf(), (continuation_3) => {
|
|
2946
|
+
const execution_3 = body_3;
|
|
2947
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
2948
|
+
const execution_2 = new Execution$1(new Value(/* VMap */ 8, [execution_3.Value]), defaultOf());
|
|
2949
|
+
const continuation_4 = continuation_3;
|
|
2950
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
2951
|
+
return continuation_4(execution_2.Value);
|
|
2952
|
+
}
|
|
2953
|
+
else {
|
|
2954
|
+
return execution_2.Resume(continuation_4);
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
else {
|
|
2958
|
+
return execution_3.Resume((value_6) => {
|
|
2959
|
+
const execution_2 = new Execution$1(new Value(/* VMap */ 8, [value_6]), defaultOf());
|
|
2960
|
+
const continuation_4 = continuation_3;
|
|
2961
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
}));
|
|
2965
|
+
}
|
|
2101
2966
|
default:
|
|
2102
|
-
return fail("Map.map expects (
|
|
2967
|
+
return new Execution$1(fail("Map.map expects (callback, values)"), defaultOf());
|
|
2103
2968
|
}
|
|
2104
|
-
}
|
|
2969
|
+
});
|
|
2105
2970
|
|
|
2106
|
-
const builtinMapIter =
|
|
2107
|
-
let matchResult,
|
|
2971
|
+
const builtinMapIter = resumable("Map.iter", 2, (apply, args) => {
|
|
2972
|
+
let matchResult, callback, values;
|
|
2108
2973
|
if (!isEmpty(args)) {
|
|
2109
2974
|
if (!isEmpty(tail_1(args))) {
|
|
2110
2975
|
if (head_1(tail_1(args)).tag === 8) {
|
|
2111
2976
|
if (isEmpty(tail_1(tail_1(args)))) {
|
|
2112
2977
|
matchResult = 0;
|
|
2113
|
-
|
|
2978
|
+
callback = head_1(args);
|
|
2114
2979
|
values = head_1(tail_1(args)).fields[0];
|
|
2115
2980
|
}
|
|
2116
2981
|
else {
|
|
@@ -2130,15 +2995,131 @@ const builtinMapIter = new ExternalFunction("Map.iter", scheme("Map.iter"), (ctx
|
|
|
2130
2995
|
}
|
|
2131
2996
|
switch (matchResult) {
|
|
2132
2997
|
case 0: {
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2998
|
+
let body_5;
|
|
2999
|
+
const items = toList(values);
|
|
3000
|
+
body_5 = Execution_fold((acc, tupledArg) => {
|
|
3001
|
+
const value = tupledArg[1];
|
|
3002
|
+
const body_3 = apply(callback)(mapKeyToValue(tupledArg[0]));
|
|
3003
|
+
if (Execution$1__get_IsImmediate(body_3)) {
|
|
3004
|
+
const body_1 = apply(body_3.Value)(value);
|
|
3005
|
+
if (Execution$1__get_IsImmediate(body_1)) {
|
|
3006
|
+
return new Execution$1(acc, defaultOf());
|
|
3007
|
+
}
|
|
3008
|
+
else {
|
|
3009
|
+
return new Execution$1(defaultOf(), (continuation) => {
|
|
3010
|
+
const execution_1 = body_1;
|
|
3011
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
3012
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3013
|
+
const continuation_1 = continuation;
|
|
3014
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
3015
|
+
return continuation_1(execution.Value);
|
|
3016
|
+
}
|
|
3017
|
+
else {
|
|
3018
|
+
return execution.Resume(continuation_1);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
else {
|
|
3022
|
+
return execution_1.Resume((value_3) => {
|
|
3023
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3024
|
+
const continuation_1 = continuation;
|
|
3025
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
3026
|
+
});
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
else {
|
|
3032
|
+
return new Execution$1(defaultOf(), (continuation_3) => {
|
|
3033
|
+
const execution_3 = body_3;
|
|
3034
|
+
if (Execution$1__get_IsImmediate(execution_3)) {
|
|
3035
|
+
let execution_2;
|
|
3036
|
+
const body_1 = apply(execution_3.Value)(value);
|
|
3037
|
+
execution_2 = (Execution$1__get_IsImmediate(body_1) ? (new Execution$1(acc, defaultOf())) : (new Execution$1(defaultOf(), (continuation) => {
|
|
3038
|
+
const execution_1 = body_1;
|
|
3039
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
3040
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3041
|
+
const continuation_1 = continuation;
|
|
3042
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
3043
|
+
return continuation_1(execution.Value);
|
|
3044
|
+
}
|
|
3045
|
+
else {
|
|
3046
|
+
return execution.Resume(continuation_1);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
else {
|
|
3050
|
+
return execution_1.Resume((value_3) => {
|
|
3051
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3052
|
+
const continuation_1 = continuation;
|
|
3053
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
})));
|
|
3057
|
+
const continuation_4 = continuation_3;
|
|
3058
|
+
if (Execution$1__get_IsImmediate(execution_2)) {
|
|
3059
|
+
return continuation_4(execution_2.Value);
|
|
3060
|
+
}
|
|
3061
|
+
else {
|
|
3062
|
+
return execution_2.Resume(continuation_4);
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
else {
|
|
3066
|
+
return execution_3.Resume((value_4) => {
|
|
3067
|
+
let execution_2;
|
|
3068
|
+
const body_1 = apply(value_4)(value);
|
|
3069
|
+
execution_2 = (Execution$1__get_IsImmediate(body_1) ? (new Execution$1(acc, defaultOf())) : (new Execution$1(defaultOf(), (continuation) => {
|
|
3070
|
+
const execution_1 = body_1;
|
|
3071
|
+
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
3072
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3073
|
+
const continuation_1 = continuation;
|
|
3074
|
+
if (Execution$1__get_IsImmediate(execution)) {
|
|
3075
|
+
return continuation_1(execution.Value);
|
|
3076
|
+
}
|
|
3077
|
+
else {
|
|
3078
|
+
return execution.Resume(continuation_1);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
else {
|
|
3082
|
+
return execution_1.Resume((value_3) => {
|
|
3083
|
+
const execution = new Execution$1(acc, defaultOf());
|
|
3084
|
+
const continuation_1 = continuation;
|
|
3085
|
+
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
3086
|
+
});
|
|
3087
|
+
}
|
|
3088
|
+
})));
|
|
3089
|
+
const continuation_4 = continuation_3;
|
|
3090
|
+
return Execution$1__get_IsImmediate(execution_2) ? continuation_4(execution_2.Value) : execution_2.Resume(continuation_4);
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
}, empty_1({
|
|
3096
|
+
Compare: (x, y) => (compare(x, y) | 0),
|
|
3097
|
+
}), items);
|
|
3098
|
+
return Execution$1__get_IsImmediate(body_5) ? (new Execution$1(Value.VUnit, defaultOf())) : (new Execution$1(defaultOf(), (continuation_6) => {
|
|
3099
|
+
const execution_5 = body_5;
|
|
3100
|
+
if (Execution$1__get_IsImmediate(execution_5)) {
|
|
3101
|
+
const execution_4 = new Execution$1(Value.VUnit, defaultOf());
|
|
3102
|
+
const continuation_7 = continuation_6;
|
|
3103
|
+
if (Execution$1__get_IsImmediate(execution_4)) {
|
|
3104
|
+
return continuation_7(execution_4.Value);
|
|
3105
|
+
}
|
|
3106
|
+
else {
|
|
3107
|
+
return execution_4.Resume(continuation_7);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
else {
|
|
3111
|
+
return execution_5.Resume((value_7) => {
|
|
3112
|
+
const execution_4 = new Execution$1(Value.VUnit, defaultOf());
|
|
3113
|
+
const continuation_7 = continuation_6;
|
|
3114
|
+
return Execution$1__get_IsImmediate(execution_4) ? continuation_7(execution_4.Value) : execution_4.Resume(continuation_7);
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
}));
|
|
2137
3118
|
}
|
|
2138
3119
|
default:
|
|
2139
|
-
return fail("Map.iter expects (
|
|
3120
|
+
return new Execution$1(fail("Map.iter expects (callback, values)"), defaultOf());
|
|
2140
3121
|
}
|
|
2141
|
-
}
|
|
3122
|
+
});
|
|
2142
3123
|
|
|
2143
3124
|
const builtinMapRemove = new ExternalFunction("Map.remove", scheme("Map.remove"), (_arg, args) => {
|
|
2144
3125
|
let matchResult, key, values;
|
|
@@ -2167,7 +3148,7 @@ const builtinMapRemove = new ExternalFunction("Map.remove", scheme("Map.remove")
|
|
|
2167
3148
|
}
|
|
2168
3149
|
switch (matchResult) {
|
|
2169
3150
|
case 0:
|
|
2170
|
-
return new
|
|
3151
|
+
return new Value(/* VMap */ 8, [FSharpMap__Remove(values, valueToMapKey("Map.remove", key))]);
|
|
2171
3152
|
default:
|
|
2172
3153
|
return fail("Map.remove expects (key, values)");
|
|
2173
3154
|
}
|