@magnusopera/fscript 0.77.1 → 0.78.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/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +68 -67
- package/dist/FScript.Language/BuiltinSignatures.js +7 -7
- package/dist/FScript.Language/BuiltinTypes.js +3 -3
- package/dist/FScript.Language/Error.js +2 -2
- package/dist/FScript.Language/Eval.js +305 -213
- package/dist/FScript.Language/IncludeResolver.js +97 -79
- package/dist/FScript.Language/Interactive.js +149 -0
- package/dist/FScript.Language/Lexer.js +77 -77
- package/dist/FScript.Language/Parser.js +274 -272
- package/dist/FScript.Language/Pretty.js +4 -4
- package/dist/FScript.Language/Span.js +2 -2
- package/dist/FScript.Language/Token.js +59 -2
- package/dist/FScript.Language/TypeInfer.js +452 -348
- package/dist/FScript.Language/Types.js +22 -10
- package/dist/FScript.Language/Value.js +3 -2
- package/dist/Library.js +91 -79
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Array.js +36 -35
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Async.js +52 -23
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/AsyncBuilder.js +23 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BigInt.js +33 -32
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BitConverter.js +2 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CHANGELOG.md +80 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Date.js +8 -15
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOffset.js +8 -17
- package/dist/fable_modules/fable-library-js.5.13.0/Directory.js +11 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Double.js +8 -2
- package/dist/fable_modules/fable-library-js.5.13.0/Environment.js +3 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Event.js +10 -1
- package/dist/fable_modules/fable-library-js.5.13.0/File.js +27 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/List.js +35 -21
- package/dist/fable_modules/fable-library-js.5.13.0/Long.js +38 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MailboxProcessor.js +11 -5
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Map.js +8 -4
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableMap.js +2 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableSet.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Observable.js +5 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Option.js +1 -18
- package/dist/fable_modules/fable-library-js.5.13.0/Path.js +31 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Reflection.js +13 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/RegExp.js +53 -24
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq.js +109 -22
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Set.js +16 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/String.js +28 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.js +15 -9
- package/dist/fable_modules/fable-library-js.5.13.0/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.13.0/TaskBuilder.js +72 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Types.js +12 -12
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Util.js +15 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/package.json +1 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/quotation.js +25 -8
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/dist/fable_modules/fable-library-js.5.2.0/Long.js +0 -47
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CollectionUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Decimal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Global.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Int32.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Numeric.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Random.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Range.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq2.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Collections.Generic.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Text.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/lib/big.js +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { Union } from "../fable_modules/fable-library-js.5.
|
|
3
|
-
import { union_type, int32_type, option_type, class_type, string_type, list_type } from "../fable_modules/fable-library-js.5.
|
|
4
|
-
import { fold, map } from "../fable_modules/fable-library-js.5.
|
|
5
|
-
import { toList, ofList, difference, singleton, empty, union } from "../fable_modules/fable-library-js.5.
|
|
6
|
-
import { comparePrimitives } from "../fable_modules/fable-library-js.5.
|
|
7
|
-
import { fold as fold_1, map as map_1 } from "../fable_modules/fable-library-js.5.
|
|
8
|
-
import { toList as toList_1, values } from "../fable_modules/fable-library-js.5.
|
|
9
|
-
import { join, printf, toText } from "../fable_modules/fable-library-js.5.
|
|
2
|
+
import { Union } from "../fable_modules/fable-library-js.5.13.0/Types.js";
|
|
3
|
+
import { union_type, int32_type, option_type, class_type, string_type, list_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
|
|
4
|
+
import { empty as empty_1, fold, map } from "../fable_modules/fable-library-js.5.13.0/List.js";
|
|
5
|
+
import { toList, isEmpty, ofList, difference, singleton, empty, union } from "../fable_modules/fable-library-js.5.13.0/Set.js";
|
|
6
|
+
import { comparePrimitives } from "../fable_modules/fable-library-js.5.13.0/Util.js";
|
|
7
|
+
import { fold as fold_1, map as map_1 } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
|
|
8
|
+
import { toList as toList_1, values } from "../fable_modules/fable-library-js.5.13.0/Map.js";
|
|
9
|
+
import { join, printf, toText } from "../fable_modules/fable-library-js.5.13.0/String.js";
|
|
10
10
|
|
|
11
11
|
export class Type extends Union {
|
|
12
12
|
constructor(tag, fields) {
|
|
@@ -17,6 +17,12 @@ export class Type extends Union {
|
|
|
17
17
|
cases() {
|
|
18
18
|
return ["TUnit", "TInt", "TFloat", "TBool", "TString", "TList", "TTask", "TTuple", "TRecord", "TMap", "TOption", "TFun", "TNamed", "TUnion", "TTypeToken", "TVar"];
|
|
19
19
|
}
|
|
20
|
+
static TUnit = new Type(0, []);
|
|
21
|
+
static TInt = new Type(1, []);
|
|
22
|
+
static TFloat = new Type(2, []);
|
|
23
|
+
static TBool = new Type(3, []);
|
|
24
|
+
static TString = new Type(4, []);
|
|
25
|
+
static TTypeToken = new Type(14, []);
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export function Type_$reflection() {
|
|
@@ -43,7 +49,7 @@ let Types_nextId = 0;
|
|
|
43
49
|
export function Types_freshVar() {
|
|
44
50
|
const id = Types_nextId | 0;
|
|
45
51
|
Types_nextId = ((Types_nextId + 1) | 0);
|
|
46
|
-
return new Type(15, [id]);
|
|
52
|
+
return new Type(/* TVar */ 15, [id]);
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
export function Types_ftvType(t_mut) {
|
|
@@ -112,7 +118,13 @@ export function Types_ftvEnv(env) {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
export function Types_generalize(env, t) {
|
|
115
|
-
|
|
121
|
+
const typeVariables = Types_ftvType(t);
|
|
122
|
+
if (isEmpty(typeVariables)) {
|
|
123
|
+
return new Scheme(empty_1(), t);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return new Scheme(toList(difference(typeVariables, Types_ftvEnv(env))), t);
|
|
127
|
+
}
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
export function Types_typeToString(t) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { Record, FSharpRef, Union } from "../fable_modules/fable-library-js.5.
|
|
3
|
-
import { int32_type, unit_type, lambda_type, record_type, option_type, class_type, list_type, bool_type, float64_type, union_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.
|
|
2
|
+
import { Record, FSharpRef, Union } from "../fable_modules/fable-library-js.5.13.0/Types.js";
|
|
3
|
+
import { int32_type, unit_type, lambda_type, record_type, option_type, class_type, list_type, bool_type, float64_type, union_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
|
|
4
4
|
import { Scheme_$reflection, Type_$reflection } from "./Types.js";
|
|
5
5
|
import { Expr_$reflection } from "./Ast.js";
|
|
6
6
|
import { EvalError$_$reflection } from "./Error.js";
|
|
@@ -29,6 +29,7 @@ export class Value extends Union {
|
|
|
29
29
|
cases() {
|
|
30
30
|
return ["VUnit", "VInt", "VFloat", "VBool", "VString", "VList", "VTuple", "VRecord", "VMap", "VOption", "VUnionCase", "VUnionCtor", "VTypeToken", "VTask", "VClosure", "VExternal"];
|
|
31
31
|
}
|
|
32
|
+
static VUnit = new Value(0, []);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export function Value_$reflection() {
|
package/dist/Library.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
|
|
2
|
-
import { Record } from "./fable_modules/fable-library-js.5.
|
|
3
|
-
import { obj_type, class_type, record_type, list_type, string_type } from "./fable_modules/fable-library-js.5.
|
|
2
|
+
import { Record } from "./fable_modules/fable-library-js.5.13.0/Types.js";
|
|
3
|
+
import { obj_type, class_type, record_type, list_type, string_type } from "./fable_modules/fable-library-js.5.13.0/Reflection.js";
|
|
4
4
|
import { Stmt_$reflection } from "./FScript.Language/Ast.js";
|
|
5
5
|
import { ExternalFunction, MapKey, Value, Value_$reflection, ExternalFunction_$reflection } from "./FScript.Language/Value.js";
|
|
6
6
|
import { inferProgramWithExterns, TypedStmt_$reflection } from "./FScript.Language/TypeInfer.js";
|
|
7
7
|
import { Scheme, Type, Types_typeToString, Type_$reflection } from "./FScript.Language/Types.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { submit as submit_1, create, Session_$reflection } from "./FScript.Language/Interactive.js";
|
|
9
|
+
import { defaultArg, value as value_18, some } from "./fable_modules/fable-library-js.5.13.0/Option.js";
|
|
10
|
+
import { stringHash, compare, comparePrimitives, createObj, Exception } from "./fable_modules/fable-library-js.5.13.0/Util.js";
|
|
11
|
+
import { concat } from "./fable_modules/fable-library-js.5.13.0/String.js";
|
|
11
12
|
import { EvalError$, EvalException, TypeException, ParseException } from "./FScript.Language/Error.js";
|
|
12
|
-
import { toInt32_unchecked, fromFloat64, toInt64_unchecked } from "./fable_modules/fable-library-js.5.
|
|
13
|
-
import { parse as parse_1 } from "./fable_modules/fable-library-js.5.
|
|
14
|
-
import { parse as parse_2 } from "./fable_modules/fable-library-js.5.
|
|
15
|
-
import {
|
|
16
|
-
import { FSharpMap__get_Item, FSharpMap__TryFind, ofList, toList } from "./fable_modules/fable-library-js.5.
|
|
13
|
+
import { toInt32_unchecked, fromFloat64, toInt64_unchecked } from "./fable_modules/fable-library-js.5.13.0/BigInt.js";
|
|
14
|
+
import { parse as parse_1 } from "./fable_modules/fable-library-js.5.13.0/Long.js";
|
|
15
|
+
import { parse as parse_2 } from "./fable_modules/fable-library-js.5.13.0/Int32.js";
|
|
16
|
+
import { choose, filter, sort, exists, singleton, collect, empty, ofArray, length, map, toArray } from "./fable_modules/fable-library-js.5.13.0/List.js";
|
|
17
|
+
import { FSharpMap__get_Item, FSharpMap__TryFind, ofList, toList } from "./fable_modules/fable-library-js.5.13.0/Map.js";
|
|
17
18
|
import { parseProgramFromSourceWithIncludesResolver } from "./FScript.Language/IncludeResolver.js";
|
|
18
19
|
import { invokeValue, evalProgramWithExterns, evalProgramWithExternsState } from "./FScript.Language/Eval.js";
|
|
19
|
-
import { List_distinct } from "./fable_modules/fable-library-js.5.
|
|
20
|
-
import { FSharpSet__Contains, ofList as ofList_1 } from "./fable_modules/fable-library-js.5.
|
|
20
|
+
import { List_distinct } from "./fable_modules/fable-library-js.5.13.0/Seq2.js";
|
|
21
|
+
import { FSharpSet__Contains, ofList as ofList_1 } from "./fable_modules/fable-library-js.5.13.0/Set.js";
|
|
21
22
|
import { valueToString } from "./FScript.Language/Pretty.js";
|
|
22
23
|
import { Span, Position } from "./FScript.Language/Span.js";
|
|
23
24
|
|
|
@@ -69,17 +70,17 @@ export function LoadedScriptHandle_$reflection() {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
export class SessionHandle extends Record {
|
|
72
|
-
constructor(kind,
|
|
73
|
+
constructor(kind, interactiveSession, options, externs) {
|
|
73
74
|
super();
|
|
74
75
|
this.kind = kind;
|
|
75
|
-
this.
|
|
76
|
+
this.interactiveSession = interactiveSession;
|
|
76
77
|
this.options = options;
|
|
77
78
|
this.externs = externs;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export function SessionHandle_$reflection() {
|
|
82
|
-
return record_type("FScript.JavaScript.SessionHandle", [], SessionHandle, () => [["kind", string_type], ["
|
|
83
|
+
return record_type("FScript.JavaScript.SessionHandle", [], SessionHandle, () => [["kind", string_type], ["interactiveSession", Session_$reflection()], ["options", obj_type], ["externs", list_type(ExternalFunction_$reflection())]]);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
function tryGetProperty(name, value) {
|
|
@@ -118,8 +119,9 @@ function isFScriptError(value) {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
function positionToObj(position) {
|
|
122
|
+
let option_1;
|
|
121
123
|
return {
|
|
122
|
-
file: defaultArg(
|
|
124
|
+
file: defaultArg((option_1 = position.File, (option_1 != null) ? some(option_1) : undefined), null),
|
|
123
125
|
line: position.Line,
|
|
124
126
|
column: position.Column,
|
|
125
127
|
};
|
|
@@ -227,6 +229,7 @@ function mapKeyToTagged(key) {
|
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
function valueToTagged(value) {
|
|
232
|
+
let option_1;
|
|
230
233
|
switch (value.tag) {
|
|
231
234
|
case 1:
|
|
232
235
|
return {
|
|
@@ -251,22 +254,22 @@ function valueToTagged(value) {
|
|
|
251
254
|
case 5:
|
|
252
255
|
return {
|
|
253
256
|
kind: "list",
|
|
254
|
-
values: toArray(
|
|
257
|
+
values: toArray(map(valueToTagged, value.fields[0])),
|
|
255
258
|
};
|
|
256
259
|
case 6:
|
|
257
260
|
return {
|
|
258
261
|
kind: "tuple",
|
|
259
|
-
values: toArray(
|
|
262
|
+
values: toArray(map(valueToTagged, value.fields[0])),
|
|
260
263
|
};
|
|
261
264
|
case 7:
|
|
262
265
|
return {
|
|
263
266
|
kind: "record",
|
|
264
|
-
fields: createObj(
|
|
267
|
+
fields: createObj(map((tupledArg) => [tupledArg[0], valueToTagged(tupledArg[1])], toList(value.fields[0]))),
|
|
265
268
|
};
|
|
266
269
|
case 8:
|
|
267
270
|
return {
|
|
268
271
|
kind: "map",
|
|
269
|
-
entries: toArray(
|
|
272
|
+
entries: toArray(map((tupledArg_1) => ({
|
|
270
273
|
key: mapKeyToTagged(tupledArg_1[0]),
|
|
271
274
|
value: valueToTagged(tupledArg_1[1]),
|
|
272
275
|
}), toList(value.fields[0]))),
|
|
@@ -290,7 +293,7 @@ function valueToTagged(value) {
|
|
|
290
293
|
kind: "union",
|
|
291
294
|
typeName: value.fields[0],
|
|
292
295
|
caseName: value.fields[1],
|
|
293
|
-
value: defaultArg(
|
|
296
|
+
value: defaultArg((option_1 = value.fields[2], (option_1 != null) ? some(valueToTagged(option_1)) : undefined), null),
|
|
294
297
|
};
|
|
295
298
|
case 11:
|
|
296
299
|
return {
|
|
@@ -332,31 +335,31 @@ function valueToTagged(value) {
|
|
|
332
335
|
function valueFromJs(value) {
|
|
333
336
|
let optionValue, payloadValue, payloadValue_1, payloadValue_2;
|
|
334
337
|
if (typeof value === 'undefined' || value === null) {
|
|
335
|
-
return
|
|
338
|
+
return Value.VUnit;
|
|
336
339
|
}
|
|
337
340
|
else if (Array.isArray(value)) {
|
|
338
|
-
return new Value(5, [
|
|
341
|
+
return new Value(/* VList */ 5, [map(valueFromJs, ofArray(value))]);
|
|
339
342
|
}
|
|
340
343
|
else {
|
|
341
344
|
const matchValue = typeof value;
|
|
342
345
|
switch (matchValue) {
|
|
343
346
|
case "boolean":
|
|
344
|
-
return new Value(3, [value]);
|
|
347
|
+
return new Value(/* VBool */ 3, [value]);
|
|
345
348
|
case "bigint":
|
|
346
|
-
return new Value(1, [value]);
|
|
349
|
+
return new Value(/* VInt */ 1, [value]);
|
|
347
350
|
case "number":
|
|
348
351
|
if ((Number.isInteger(value)) && (Number.isSafeInteger(value))) {
|
|
349
|
-
return new Value(1, [toInt64_unchecked(fromFloat64(value))]);
|
|
352
|
+
return new Value(/* VInt */ 1, [toInt64_unchecked(fromFloat64(value))]);
|
|
350
353
|
}
|
|
351
354
|
else {
|
|
352
|
-
return new Value(2, [value]);
|
|
355
|
+
return new Value(/* VFloat */ 2, [value]);
|
|
353
356
|
}
|
|
354
357
|
case "string":
|
|
355
|
-
return new Value(4, [value]);
|
|
358
|
+
return new Value(/* VString */ 4, [value]);
|
|
356
359
|
case "object": {
|
|
357
360
|
const matchValue_1 = tryGetProperty("kind", value);
|
|
358
361
|
if (matchValue_1 == null) {
|
|
359
|
-
return new Value(7, [ofList(
|
|
362
|
+
return new Value(/* VRecord */ 7, [ofList(map((name_1) => [name_1, valueFromJs(value[name_1])], ofArray(Object.keys(value))), {
|
|
360
363
|
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
361
364
|
})]);
|
|
362
365
|
}
|
|
@@ -364,29 +367,29 @@ function valueFromJs(value) {
|
|
|
364
367
|
const matchValue_2 = value_18(matchValue_1);
|
|
365
368
|
switch (matchValue_2) {
|
|
366
369
|
case "unit":
|
|
367
|
-
return
|
|
370
|
+
return Value.VUnit;
|
|
368
371
|
case "int":
|
|
369
|
-
return new Value(1, [int64FromObj(getRequiredProperty("value", value))]);
|
|
372
|
+
return new Value(/* VInt */ 1, [int64FromObj(getRequiredProperty("value", value))]);
|
|
370
373
|
case "float":
|
|
371
|
-
return new Value(2, [getRequiredProperty("value", value)]);
|
|
374
|
+
return new Value(/* VFloat */ 2, [getRequiredProperty("value", value)]);
|
|
372
375
|
case "bool":
|
|
373
|
-
return new Value(3, [getRequiredProperty("value", value)]);
|
|
376
|
+
return new Value(/* VBool */ 3, [getRequiredProperty("value", value)]);
|
|
374
377
|
case "string":
|
|
375
|
-
return new Value(4, [getRequiredProperty("value", value)]);
|
|
378
|
+
return new Value(/* VString */ 4, [getRequiredProperty("value", value)]);
|
|
376
379
|
case "list":
|
|
377
|
-
return new Value(5, [
|
|
380
|
+
return new Value(/* VList */ 5, [map(valueFromJs, ofArray(getRequiredProperty("values", value)))]);
|
|
378
381
|
case "tuple":
|
|
379
|
-
return new Value(6, [
|
|
382
|
+
return new Value(/* VTuple */ 6, [map(valueFromJs, ofArray(getRequiredProperty("values", value)))]);
|
|
380
383
|
case "record": {
|
|
381
384
|
const fields = getRequiredProperty("fields", value);
|
|
382
|
-
return new Value(7, [ofList(
|
|
385
|
+
return new Value(/* VRecord */ 7, [ofList(map((name) => [name, valueFromJs(fields[name])], ofArray(Object.keys(fields))), {
|
|
383
386
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
384
387
|
})]);
|
|
385
388
|
}
|
|
386
389
|
case "map":
|
|
387
|
-
return new Value(8, [ofList(
|
|
390
|
+
return new Value(/* VMap */ 8, [ofList(map((entry) => {
|
|
388
391
|
const keyValue = valueFromJs(getRequiredProperty("key", entry));
|
|
389
|
-
return [(keyValue.tag === 4) ? (new MapKey(0, [keyValue.fields[0]])) : ((keyValue.tag === 1) ? (new MapKey(1, [keyValue.fields[0]])) : (() => {
|
|
392
|
+
return [(keyValue.tag === 4) ? (new MapKey(/* MKString */ 0, [keyValue.fields[0]])) : ((keyValue.tag === 1) ? (new MapKey(/* MKInt */ 1, [keyValue.fields[0]])) : (() => {
|
|
390
393
|
throw new Exception("Map key must be string or int");
|
|
391
394
|
})()), valueFromJs(getRequiredProperty("value", entry))];
|
|
392
395
|
}, ofArray(getRequiredProperty("entries", value))), {
|
|
@@ -397,22 +400,22 @@ function valueFromJs(value) {
|
|
|
397
400
|
if (matchValue_3 != null) {
|
|
398
401
|
if ((optionValue = value_18(matchValue_3), typeof optionValue === 'undefined' || optionValue === null)) {
|
|
399
402
|
const optionValue_1 = value_18(matchValue_3);
|
|
400
|
-
return new Value(9, [undefined]);
|
|
403
|
+
return new Value(/* VOption */ 9, [undefined]);
|
|
401
404
|
}
|
|
402
405
|
else {
|
|
403
406
|
const optionValue_2 = value_18(matchValue_3);
|
|
404
|
-
return new Value(9, [valueFromJs(optionValue_2)]);
|
|
407
|
+
return new Value(/* VOption */ 9, [valueFromJs(optionValue_2)]);
|
|
405
408
|
}
|
|
406
409
|
}
|
|
407
410
|
else {
|
|
408
|
-
return new Value(9, [undefined]);
|
|
411
|
+
return new Value(/* VOption */ 9, [undefined]);
|
|
409
412
|
}
|
|
410
413
|
}
|
|
411
414
|
case "union": {
|
|
412
415
|
let payload;
|
|
413
416
|
const matchValue_4 = tryGetProperty("value", value);
|
|
414
417
|
payload = ((matchValue_4 != null) ? (((payloadValue = value_18(matchValue_4), typeof payloadValue === 'undefined' || payloadValue === null)) ? ((payloadValue_1 = value_18(matchValue_4), undefined)) : ((payloadValue_2 = value_18(matchValue_4), valueFromJs(payloadValue_2)))) : undefined);
|
|
415
|
-
return new Value(10, [getRequiredProperty("typeName", value), getRequiredProperty("caseName", value), payload]);
|
|
418
|
+
return new Value(/* VUnionCase */ 10, [getRequiredProperty("typeName", value), getRequiredProperty("caseName", value), payload]);
|
|
416
419
|
}
|
|
417
420
|
default:
|
|
418
421
|
throw new Exception(concat("Unsupported FScript tagged value kind \'", matchValue_2, "\'"));
|
|
@@ -524,7 +527,7 @@ function declaredExportedNames(program) {
|
|
|
524
527
|
case 0:
|
|
525
528
|
return singleton(name_1);
|
|
526
529
|
case 1:
|
|
527
|
-
return
|
|
530
|
+
return map((tupledArg) => tupledArg[0], bindings_1);
|
|
528
531
|
default:
|
|
529
532
|
return empty();
|
|
530
533
|
}
|
|
@@ -542,17 +545,6 @@ function hasExpression(statements) {
|
|
|
542
545
|
}, statements);
|
|
543
546
|
}
|
|
544
547
|
|
|
545
|
-
function retainedStatements(statements) {
|
|
546
|
-
return filter((_arg) => {
|
|
547
|
-
if (_arg.tag === 5) {
|
|
548
|
-
return false;
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
return true;
|
|
552
|
-
}
|
|
553
|
-
}, statements);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
548
|
function loadTyped(typed, externs) {
|
|
557
549
|
const state = evalProgramWithExternsState(externs, typed);
|
|
558
550
|
const exportedNames = sort(List_distinct(declaredExportedNames(typed), {
|
|
@@ -573,7 +565,15 @@ function loadTyped(typed, externs) {
|
|
|
573
565
|
const functionSet = ofList_1(functionNames, {
|
|
574
566
|
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
575
567
|
});
|
|
576
|
-
const functions = ofList(choose((name_1) =>
|
|
568
|
+
const functions = ofList(choose((name_1) => {
|
|
569
|
+
const option_1 = FSharpMap__TryFind(state.Env, name_1);
|
|
570
|
+
if (option_1 != null) {
|
|
571
|
+
return [name_1, option_1];
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
}, functionNames), {
|
|
577
577
|
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
578
578
|
});
|
|
579
579
|
const valueNames = filter((name_2) => {
|
|
@@ -587,7 +587,15 @@ function loadTyped(typed, externs) {
|
|
|
587
587
|
}, exportedNames);
|
|
588
588
|
return new LoadedScriptHandle("loaded", state.TypeDefs, state.Env, functionNames, functionSet, functions, valueNames, ofList_1(valueNames, {
|
|
589
589
|
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
590
|
-
}), ofList(choose((name_3) =>
|
|
590
|
+
}), ofList(choose((name_3) => {
|
|
591
|
+
const option_3 = FSharpMap__TryFind(state.Env, name_3);
|
|
592
|
+
if (option_3 != null) {
|
|
593
|
+
return [name_3, option_3];
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
}, valueNames), {
|
|
591
599
|
Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
|
|
592
600
|
}), state.LastValue, externs);
|
|
593
601
|
}
|
|
@@ -623,13 +631,16 @@ export function run(source, options) {
|
|
|
623
631
|
}
|
|
624
632
|
|
|
625
633
|
export function createSession(options) {
|
|
626
|
-
return withStructuredErrors(() =>
|
|
634
|
+
return withStructuredErrors(() => {
|
|
635
|
+
const externs = externsFromOptions(options);
|
|
636
|
+
return new SessionHandle("session", create(externs), options, externs);
|
|
637
|
+
});
|
|
627
638
|
}
|
|
628
639
|
|
|
629
640
|
export function resetSession(session) {
|
|
630
641
|
return withStructuredErrors(() => {
|
|
631
642
|
const session_1 = session;
|
|
632
|
-
session_1.
|
|
643
|
+
session_1.interactiveSession = create(session_1.externs);
|
|
633
644
|
return session_1;
|
|
634
645
|
});
|
|
635
646
|
}
|
|
@@ -638,15 +649,16 @@ export function submit(session, source) {
|
|
|
638
649
|
return withStructuredErrors(() => {
|
|
639
650
|
const session_1 = session;
|
|
640
651
|
const parsed = parseSource(source, session_1.options, session_1.externs);
|
|
641
|
-
const
|
|
652
|
+
const submission = submit_1(session_1.interactiveSession, parsed.program);
|
|
653
|
+
session_1.interactiveSession = submission.Session;
|
|
654
|
+
const state = submission.State;
|
|
642
655
|
const submittedHasExpression = hasExpression(parsed.program);
|
|
643
|
-
session_1.retainedProgram = append(session_1.retainedProgram, retainedStatements(parsed.program));
|
|
644
656
|
return {
|
|
645
657
|
kind: "session-result",
|
|
646
658
|
hasValue: submittedHasExpression,
|
|
647
659
|
value: submittedHasExpression ? valueToTagged(state.LastValue) : (null),
|
|
648
660
|
text: submittedHasExpression ? valueToString(state.LastValue) : "",
|
|
649
|
-
retainedCount:
|
|
661
|
+
retainedCount: submission.RetainedCount,
|
|
650
662
|
};
|
|
651
663
|
});
|
|
652
664
|
}
|
|
@@ -680,7 +692,7 @@ export function invoke(loaded, name, args) {
|
|
|
680
692
|
throw new EvalException(new EvalError$(concat("Unknown exported function \'", name, "\'"), new Span(new Position(undefined, 0, 0), new Position(undefined, 0, 0))));
|
|
681
693
|
}
|
|
682
694
|
}
|
|
683
|
-
return valueToTagged(invokeValue(loaded_1.typeDefs, FSharpMap__get_Item(loaded_1.exportedFunctions, name), (typeof args === 'undefined' || args === null) ? empty() :
|
|
695
|
+
return valueToTagged(invokeValue(loaded_1.typeDefs, FSharpMap__get_Item(loaded_1.exportedFunctions, name), (typeof args === 'undefined' || args === null) ? empty() : map(valueFromJs, ofArray(args))));
|
|
684
696
|
});
|
|
685
697
|
}
|
|
686
698
|
|
|
@@ -697,24 +709,24 @@ export function fromJs(value, _expectedType) {
|
|
|
697
709
|
}
|
|
698
710
|
|
|
699
711
|
export const T = {
|
|
700
|
-
unit:
|
|
701
|
-
int:
|
|
702
|
-
float:
|
|
703
|
-
bool:
|
|
704
|
-
string:
|
|
705
|
-
typeToken:
|
|
706
|
-
var: (value) => (new Type(15, [intFromObj(value)])),
|
|
707
|
-
list: (value_1) => (new Type(5, [value_1])),
|
|
708
|
-
task: (value_2) => (new Type(6, [value_2])),
|
|
709
|
-
option: (value_3) => (new Type(10, [value_3])),
|
|
710
|
-
map: (value_4) => (new Type(9, [
|
|
711
|
-
tuple: (values) => (new Type(7, [
|
|
712
|
-
record: (fields) => (new Type(8, [ofList(
|
|
712
|
+
unit: Type.TUnit,
|
|
713
|
+
int: Type.TInt,
|
|
714
|
+
float: Type.TFloat,
|
|
715
|
+
bool: Type.TBool,
|
|
716
|
+
string: Type.TString,
|
|
717
|
+
typeToken: Type.TTypeToken,
|
|
718
|
+
var: (value) => (new Type(/* TVar */ 15, [intFromObj(value)])),
|
|
719
|
+
list: (value_1) => (new Type(/* TList */ 5, [value_1])),
|
|
720
|
+
task: (value_2) => (new Type(/* TTask */ 6, [value_2])),
|
|
721
|
+
option: (value_3) => (new Type(/* TOption */ 10, [value_3])),
|
|
722
|
+
map: (value_4) => (new Type(/* TMap */ 9, [Type.TString, value_4])),
|
|
723
|
+
tuple: (values) => (new Type(/* TTuple */ 7, [map((value_6) => value_6, ofArray(values))])),
|
|
724
|
+
record: (fields) => (new Type(/* TRecord */ 8, [ofList(map((name) => [name, fields[name]], ofArray(Object.keys(fields))), {
|
|
713
725
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
714
726
|
})])),
|
|
715
|
-
func: (left, right) => (new Type(11, [left, right])),
|
|
727
|
+
func: (left, right) => (new Type(/* TFun */ 11, [left, right])),
|
|
716
728
|
scheme: (value_8) => (new Scheme(empty(), value_8)),
|
|
717
|
-
forall: (vars, value_9) => (new Scheme(
|
|
729
|
+
forall: (vars, value_9) => (new Scheme(map((value_11) => (intFromObj(value_11) | 0), ofArray(vars)), value_9)),
|
|
718
730
|
};
|
|
719
731
|
|
|
720
732
|
export function extern(definition) {
|
|
@@ -725,7 +737,7 @@ export function extern(definition) {
|
|
|
725
737
|
const invoke_1 = getRequiredProperty("invoke", definition);
|
|
726
738
|
return new ExternalFunction(name, scheme, (_arg, args) => {
|
|
727
739
|
let _arg_1;
|
|
728
|
-
return valueFromJs((_arg_1 = toArray(
|
|
740
|
+
return valueFromJs((_arg_1 = toArray(map(valueToTagged, args)), invoke_1(_arg_1)));
|
|
729
741
|
}, arity);
|
|
730
742
|
});
|
|
731
743
|
}
|