@magnusopera/fscript 0.79.0 → 0.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FScript.Language/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +91 -66
- package/dist/FScript.Language/BuiltinSignatures.js +1 -1
- package/dist/FScript.Language/Eval.js +261 -174
- package/dist/FScript.Language/IncludeResolver.js +4 -2
- package/dist/FScript.Language/Parser.js +34 -27
- package/dist/FScript.Language/Pretty.js +1 -1
- package/dist/FScript.Language/TypeInfer.js +188 -61
- package/dist/FScript.Language/Types.js +3 -3
- package/dist/FScript.Language/Value.js +3 -3
- package/dist/Library.js +28 -14
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
|
@@ -372,9 +372,11 @@ function rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tref) {
|
|
|
372
372
|
case 3:
|
|
373
373
|
return new TypeRef(/* TRPostfix */ 3, [rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tref.fields[0]), tref.fields[1]]);
|
|
374
374
|
case 4:
|
|
375
|
-
return new TypeRef(/*
|
|
375
|
+
return new TypeRef(/* TRMap */ 4, [rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tref.fields[0]), rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tref.fields[1])]);
|
|
376
376
|
case 5:
|
|
377
|
-
return new TypeRef(/*
|
|
377
|
+
return new TypeRef(/* TRRecord */ 5, [map((tupledArg) => [tupledArg[0], rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tupledArg[1])], tref.fields[0])]);
|
|
378
|
+
case 6:
|
|
379
|
+
return new TypeRef(/* TRStructuralRecord */ 6, [map((tupledArg_1) => [tupledArg_1[0], rewriteTypeRef(aliases, selfPrefix, selfTypeNames, tupledArg_1[1])], tref.fields[0])]);
|
|
378
380
|
default:
|
|
379
381
|
return new TypeRef(/* TRName */ 0, [rewriteTypeName(aliases, selfPrefix, selfTypeNames, tref.fields[0])]);
|
|
380
382
|
}
|
|
@@ -290,10 +290,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
290
290
|
}
|
|
291
291
|
TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in inline record type");
|
|
292
292
|
if (isStructural) {
|
|
293
|
-
return new TypeRef(/* TRStructuralRecord */
|
|
293
|
+
return new TypeRef(/* TRStructuralRecord */ 6, [toList(fields)]);
|
|
294
294
|
}
|
|
295
295
|
else {
|
|
296
|
-
return new TypeRef(/* TRRecord */
|
|
296
|
+
return new TypeRef(/* TRRecord */ 5, [toList(fields)]);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
case 27: {
|
|
@@ -362,7 +362,14 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
362
362
|
}
|
|
363
363
|
case 2: {
|
|
364
364
|
TokenStream__Next(stream);
|
|
365
|
-
|
|
365
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.LBracket)) {
|
|
366
|
+
const keyType = parseTypeRef();
|
|
367
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' after map key type");
|
|
368
|
+
t = (new TypeRef(/* TRMap */ 4, [keyType, t]));
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
t = (new TypeRef(/* TRPostfix */ 3, [t, "map"]));
|
|
372
|
+
}
|
|
366
373
|
break;
|
|
367
374
|
}
|
|
368
375
|
case 3: {
|
|
@@ -760,7 +767,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
760
767
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_2, rb_2.Span.Start.Line)) {
|
|
761
768
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_2.Span));
|
|
762
769
|
}
|
|
763
|
-
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRStructuralRecord */
|
|
770
|
+
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRStructuralRecord */ 6, [toList(fields_3)]), mkSpanFrom(lb_2.Span, rb_2.Span)]);
|
|
764
771
|
}
|
|
765
772
|
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
|
|
766
773
|
const clauses = [];
|
|
@@ -858,7 +865,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
858
865
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_4, rb_4.Span.Start.Line)) {
|
|
859
866
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb_4.Span));
|
|
860
867
|
}
|
|
861
|
-
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRRecord */
|
|
868
|
+
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRRecord */ 5, [toList(fields_4)]), mkSpanFrom(lb_2.Span, rb_4.Span)]);
|
|
862
869
|
}
|
|
863
870
|
else {
|
|
864
871
|
const fields_5 = [];
|
|
@@ -1221,8 +1228,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1221
1228
|
name_8 = ((matchValue_23.tag === 4) ? matchValue_23.fields[0] : "");
|
|
1222
1229
|
TokenStream__SkipNewlines(stream);
|
|
1223
1230
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record update field");
|
|
1224
|
-
const
|
|
1225
|
-
void (updates.push([name_8,
|
|
1231
|
+
const value_41 = parseEntryExpr();
|
|
1232
|
+
void (updates.push([name_8, value_41]));
|
|
1226
1233
|
};
|
|
1227
1234
|
parseUpdateField();
|
|
1228
1235
|
let keepParsing_1 = true;
|
|
@@ -1250,8 +1257,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1250
1257
|
name_9 = ((matchValue_25.tag === 4) ? matchValue_25.fields[0] : "");
|
|
1251
1258
|
TokenStream__SkipNewlines(stream);
|
|
1252
1259
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record field");
|
|
1253
|
-
const
|
|
1254
|
-
void (fields_6.push([name_9,
|
|
1260
|
+
const value_45 = parseEntryExpr();
|
|
1261
|
+
void (fields_6.push([name_9, value_45]));
|
|
1255
1262
|
};
|
|
1256
1263
|
parseField_3();
|
|
1257
1264
|
let keepParsing_2 = true;
|
|
@@ -1332,8 +1339,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1332
1339
|
name_10 = ((matchValue_26.tag === 4) ? matchValue_26.fields[0] : "");
|
|
1333
1340
|
TokenStream__SkipNewlines(stream);
|
|
1334
1341
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record update field");
|
|
1335
|
-
const
|
|
1336
|
-
void (updates_1.push([name_10,
|
|
1342
|
+
const value_54 = parseEntryExpr();
|
|
1343
|
+
void (updates_1.push([name_10, value_54]));
|
|
1337
1344
|
};
|
|
1338
1345
|
parseUpdateField_1();
|
|
1339
1346
|
let keepParsing_4 = true;
|
|
@@ -1360,8 +1367,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1360
1367
|
name_11 = ((matchValue_28.tag === 4) ? matchValue_28.fields[0] : "");
|
|
1361
1368
|
TokenStream__SkipNewlines(stream);
|
|
1362
1369
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record field");
|
|
1363
|
-
const
|
|
1364
|
-
void (fields_7.push([name_11,
|
|
1370
|
+
const value_57 = parseEntryExpr();
|
|
1371
|
+
void (fields_7.push([name_11, value_57]));
|
|
1365
1372
|
};
|
|
1366
1373
|
parseField_4();
|
|
1367
1374
|
let keepParsing_5 = true;
|
|
@@ -1393,8 +1400,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1393
1400
|
return parseIf();
|
|
1394
1401
|
case 21: {
|
|
1395
1402
|
const raiseTok = TokenStream__Next(stream);
|
|
1396
|
-
const
|
|
1397
|
-
return new Expr(/* ERaise */ 7, [
|
|
1403
|
+
const value_59 = parsePrimary();
|
|
1404
|
+
return new Expr(/* ERaise */ 7, [value_59, mkSpanFrom(raiseTok.Span, Ast_spanOfExpr(value_59))]);
|
|
1398
1405
|
}
|
|
1399
1406
|
case 22:
|
|
1400
1407
|
return parseFor();
|
|
@@ -1840,11 +1847,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1840
1847
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
1841
1848
|
}
|
|
1842
1849
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
1843
|
-
const
|
|
1850
|
+
const value_71 = parseExprOrBlock();
|
|
1844
1851
|
if (isRec_1) {
|
|
1845
1852
|
const bindings = [];
|
|
1846
|
-
const firstSpan = mkSpanFrom(patternInput_2[3], Ast_spanOfExpr(
|
|
1847
|
-
void (bindings.push([bindingName, toList(args_2), returnAnnotation,
|
|
1853
|
+
const firstSpan = mkSpanFrom(patternInput_2[3], Ast_spanOfExpr(value_71));
|
|
1854
|
+
void (bindings.push([bindingName, toList(args_2), returnAnnotation, value_71, firstSpan]));
|
|
1848
1855
|
let doneBindings = false;
|
|
1849
1856
|
while (!doneBindings) {
|
|
1850
1857
|
TokenStream__SkipNewlines(stream);
|
|
@@ -1897,7 +1904,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1897
1904
|
body_3 = parseExprOrBlock();
|
|
1898
1905
|
}
|
|
1899
1906
|
if (bindings.length === 1) {
|
|
1900
|
-
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(/* ELambda */ 4, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2,
|
|
1907
|
+
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(/* ELambda */ 4, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2, value_71), body_3, true, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
1901
1908
|
}
|
|
1902
1909
|
else {
|
|
1903
1910
|
return new Expr(/* ELetRecGroup */ 12, [toList(bindings), body_3, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
@@ -1932,7 +1939,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1932
1939
|
body_4 = parseExprOrBlock();
|
|
1933
1940
|
}
|
|
1934
1941
|
if (tuplePatternOpt == null) {
|
|
1935
|
-
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(/* ELambda */ 4, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2,
|
|
1942
|
+
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(/* ELambda */ 4, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2, value_71), body_4, false, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1936
1943
|
}
|
|
1937
1944
|
else if (args_2.length > 0) {
|
|
1938
1945
|
const pattern_3 = tuplePatternOpt;
|
|
@@ -1940,7 +1947,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1940
1947
|
}
|
|
1941
1948
|
else {
|
|
1942
1949
|
const pattern_4 = tuplePatternOpt;
|
|
1943
|
-
return new Expr(/* ELetPattern */ 11, [pattern_4,
|
|
1950
|
+
return new Expr(/* ELetPattern */ 11, [pattern_4, value_71, body_4, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1944
1951
|
}
|
|
1945
1952
|
}
|
|
1946
1953
|
}
|
|
@@ -2192,11 +2199,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2192
2199
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
2193
2200
|
}
|
|
2194
2201
|
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
2195
|
-
const
|
|
2202
|
+
const value_79 = parseExprOrBlock();
|
|
2196
2203
|
if (isRec_3) {
|
|
2197
2204
|
const bindings_2 = [];
|
|
2198
|
-
const firstSpan_1 = mkSpanFrom(patternInput_3[3], Ast_spanOfExpr(
|
|
2199
|
-
void (bindings_2.push([bindingName_1, toList(args_5), returnAnnotation_2,
|
|
2205
|
+
const firstSpan_1 = mkSpanFrom(patternInput_3[3], Ast_spanOfExpr(value_79));
|
|
2206
|
+
void (bindings_2.push([bindingName_1, toList(args_5), returnAnnotation_2, value_79, firstSpan_1]));
|
|
2200
2207
|
let doneBindings_1 = false;
|
|
2201
2208
|
while (!doneBindings_1) {
|
|
2202
2209
|
TokenStream__SkipNewlines(stream);
|
|
@@ -2224,7 +2231,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2224
2231
|
}
|
|
2225
2232
|
}
|
|
2226
2233
|
if (bindings_2.length === 1) {
|
|
2227
|
-
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2,
|
|
2234
|
+
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_79, true, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
|
|
2228
2235
|
}
|
|
2229
2236
|
else {
|
|
2230
2237
|
const patternInput_4 = item_1(bindings_2.length - 1, bindings_2);
|
|
@@ -2232,7 +2239,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2232
2239
|
}
|
|
2233
2240
|
}
|
|
2234
2241
|
else if (tuplePatternOpt_1 == null) {
|
|
2235
|
-
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2,
|
|
2242
|
+
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_79, false, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
|
|
2236
2243
|
}
|
|
2237
2244
|
else if (args_5.length > 0) {
|
|
2238
2245
|
const pattern_9 = tuplePatternOpt_1;
|
|
@@ -2240,7 +2247,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2240
2247
|
}
|
|
2241
2248
|
else {
|
|
2242
2249
|
const pattern_10 = tuplePatternOpt_1;
|
|
2243
|
-
return new Stmt(/* SLetPattern */ 3, [pattern_10,
|
|
2250
|
+
return new Stmt(/* SLetPattern */ 3, [pattern_10, value_79, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_79))]);
|
|
2244
2251
|
}
|
|
2245
2252
|
};
|
|
2246
2253
|
const parseAttributeName = () => {
|
|
@@ -64,7 +64,7 @@ export function valueToString(v) {
|
|
|
64
64
|
const arg_8 = join("; ", map((tupledArg_1) => {
|
|
65
65
|
let arg_6;
|
|
66
66
|
const key = tupledArg_1[0];
|
|
67
|
-
arg_6 = ((key.tag === 1) ? int64ToString(key.fields[0]) : concat("\"", escapeStringLiteral(key.fields[0]), "\""));
|
|
67
|
+
arg_6 = ((key.tag === 1) ? int64ToString(key.fields[0]) : ((key.tag === 2) ? (key.fields[0] ? "true" : "false") : ((key.tag === 3) ? concat(key.fields[0], ".", key.fields[1]) : concat("\"", escapeStringLiteral(key.fields[0]), "\""))));
|
|
68
68
|
const arg_7 = valueToString(tupledArg_1[1]);
|
|
69
69
|
return toText(printf("%s => %s"))(arg_6)(arg_7);
|
|
70
70
|
}, toList(v.fields[0])));
|