firefly-compiler 0.5.13 → 0.5.14
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/compiler/JsEmitter.ff +18 -6
- package/output/js/ff/compiler/Deriver.mjs +2 -2
- package/output/js/ff/compiler/Inference.mjs +26 -26
- package/output/js/ff/compiler/JsEmitter.mjs +74 -34
- package/output/js/ff/compiler/Parser.mjs +52 -52
- package/output/js/ff/compiler/Patterns.mjs +4 -4
- package/output/js/ff/compiler/Tokenizer.mjs +2 -2
- package/output/js/ff/compiler/Unification.mjs +2 -2
- package/output/js/ff/compiler/Workspace.mjs +14 -14
- package/output/js/ff/core/Array.mjs +8 -8
- package/output/js/ff/core/List.mjs +38 -38
- package/output/js/ff/core/Ordering.mjs +4 -4
- package/output/js/ff/core/Random.mjs +8 -8
- package/output/js/ff/core/Serializable.mjs +8 -8
- package/output/js/ff/core/Task.mjs +2 -2
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/compiler/JsEmitter.ff
CHANGED
|
@@ -516,15 +516,27 @@ extend self: JsEmitter {
|
|
|
516
516
|
Some("(" + operator + self.emitTerm(value, async) + ")")
|
|
517
517
|
| operator {!operator.grabFirst().isAsciiLetter()} {arguments | [left, right]} =>
|
|
518
518
|
Some("(" + self.emitTerm(left, async) + " " + operator + " " + self.emitTerm(right, async) + ")")
|
|
519
|
-
| "ff:core/List.List_grab" {arguments | [
|
|
519
|
+
| "ff:core/List.List_grab" {arguments | [e1, e2]} {noSideEffects(e1) && noSideEffects(e2)} =>
|
|
520
|
+
let code1 = self.emitTerm(e1, async)
|
|
521
|
+
let code2 = self.emitTerm(e2, async)
|
|
520
522
|
Some(
|
|
521
|
-
"(" +
|
|
522
|
-
"ff_core_List.internalGrab_(" +
|
|
523
|
+
"(" + code1 + "[" + code2 + "] ?? " +
|
|
524
|
+
"ff_core_List.internalGrab_(" + code1 + ", " + code2 + "))"
|
|
523
525
|
)
|
|
524
|
-
| "ff:core/Array.Array_grab" {arguments | [
|
|
526
|
+
| "ff:core/Array.Array_grab" {arguments | [e1, e2]} =>
|
|
527
|
+
let code1 = self.emitTerm(e1, async)
|
|
528
|
+
let code2 = self.emitTerm(e2, async)
|
|
525
529
|
Some(
|
|
526
|
-
"(" +
|
|
527
|
-
"ff_core_Array.internalGrab_(" +
|
|
530
|
+
"(" + code1 + ".array[" + code2 + "] ?? " +
|
|
531
|
+
"ff_core_Array.internalGrab_(" + code1 + ", " + code2 + "))"
|
|
532
|
+
)
|
|
533
|
+
| "ff:core/List.List_size" {arguments | [e]} =>
|
|
534
|
+
Some(
|
|
535
|
+
self.emitTerm(e, async) + ".length"
|
|
536
|
+
)
|
|
537
|
+
| "ff:core/Array.Array_size" {arguments | [e]} =>
|
|
538
|
+
Some(
|
|
539
|
+
self.emitTerm(e, async) + ".array.length"
|
|
528
540
|
)
|
|
529
541
|
| "ff:core/Equal.equals" {arguments | [left, right]} {dictionaries | [Dictionary(_, _, _, typeName, [])]} {
|
|
530
542
|
primitiveTypes.contains(typeName) || typeName == "ff:core/Ordering.Ordering"
|
|
@@ -203,7 +203,7 @@ const variants_ = _1;
|
|
|
203
203
|
return ff_core_List.List_map(variants_, ((variant_) => {
|
|
204
204
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
205
205
|
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
206
|
-
const strings_ = ((
|
|
206
|
+
const strings_ = ((fields_.length === 0)
|
|
207
207
|
? []
|
|
208
208
|
: [ff_compiler_Syntax.EString(at_, "\"(\""), ...ff_core_List.List_separate(ff_core_List.List_map(fields_, ((field_) => {
|
|
209
209
|
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_)], [])
|
|
@@ -605,7 +605,7 @@ const variants_ = _1;
|
|
|
605
605
|
return ff_core_List.List_map(variants_, ((variant_) => {
|
|
606
606
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
607
607
|
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
608
|
-
const strings_ = ((
|
|
608
|
+
const strings_ = ((fields_.length === 0)
|
|
609
609
|
? []
|
|
610
610
|
: [ff_compiler_Syntax.EString(at_, "\"(\""), ...ff_core_List.List_separate(ff_core_List.List_map(fields_, ((field_) => {
|
|
611
611
|
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_)], [])
|
|
@@ -213,8 +213,8 @@ const traitName_ = definition_.traitName_;
|
|
|
213
213
|
const traitDefinition_ = ff_core_Option.Option_else(ff_core_Map.Map_get(environment_.traits_, traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
214
214
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
215
215
|
}));
|
|
216
|
-
if((
|
|
217
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (
|
|
216
|
+
if((traitDefinition_.generics_.length !== definition_.typeArguments_.length)) {
|
|
217
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (traitDefinition_.generics_.length - 1)) + ", got ") + (definition_.typeArguments_.length - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
218
218
|
};
|
|
219
219
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
220
220
|
for(let for_i = 0, for_a = traitDefinition_.methods_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
@@ -252,11 +252,11 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
252
252
|
}
|
|
253
253
|
}));
|
|
254
254
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
255
|
-
for(let for_i = Math.max(
|
|
255
|
+
for(let for_i = Math.max(parameters_.length, 0), for_a = instanceFunction_.signature_.parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
256
256
|
const instanceParameter_ = for_a[for_i];
|
|
257
257
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
258
258
|
};
|
|
259
|
-
for(let for_i = Math.max(
|
|
259
|
+
for(let for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0), for_a = parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
260
260
|
const traitParameter_ = for_a[for_i];
|
|
261
261
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
262
262
|
};
|
|
@@ -353,7 +353,7 @@ return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_add
|
|
|
353
353
|
const parameterTypes_ = ff_core_List.List_map(parameters_, ((_w1) => {
|
|
354
354
|
return _w1.second_.signature_.returnType_
|
|
355
355
|
}));
|
|
356
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(definition_.at_, ("Function$" +
|
|
356
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(definition_.at_, ("Function$" + parameterTypes_.length), [definition_.signature_.effect_, ...parameterTypes_, definition_.signature_.returnType_]);
|
|
357
357
|
const instances_ = ff_compiler_Inference.constraintsToInstances_(definition_.signature_.constraints_);
|
|
358
358
|
return ff_compiler_Unification.Unification_withLocalInstances(self_.unification_, instances_, (() => {
|
|
359
359
|
{
|
|
@@ -424,7 +424,7 @@ const parameterTypes_ = ff_core_List.List_map(case_.patterns_, ((_w1) => {
|
|
|
424
424
|
return ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, _w1.at_)
|
|
425
425
|
}));
|
|
426
426
|
const returnType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, case_.at_);
|
|
427
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(case_.at_, ("Function$" +
|
|
427
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(case_.at_, ("Function$" + case_.patterns_.length), [environment_.effect_, ...parameterTypes_, returnType_]);
|
|
428
428
|
ff_compiler_Unification.Unification_unify(self_.unification_, case_.at_, expected_, functionType_);
|
|
429
429
|
const environment1_ = ff_core_List.List_foldLeft(ff_core_List.List_zip(parameterTypes_, case_.patterns_), environment_, ((_1, _2) => {
|
|
430
430
|
{
|
|
@@ -608,8 +608,8 @@ const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference
|
|
|
608
608
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
609
609
|
}));
|
|
610
610
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, instantiated_.scheme_.signature_.returnType_);
|
|
611
|
-
if(((
|
|
612
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (((("Wrong number of subpatterns, expected " +
|
|
611
|
+
if(((patterns_.length !== instantiated_.scheme_.signature_.parameters_.length) && (!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)))) {
|
|
612
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (((("Wrong number of subpatterns, expected " + instantiated_.scheme_.signature_.parameters_.length) + ", got ") + patterns_.length) + ".")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
613
613
|
};
|
|
614
614
|
return ff_core_List.List_foldLeft(ff_core_List.List_map(ff_core_List.List_zip(patterns_, instantiated_.scheme_.signature_.parameters_), ((_1) => {
|
|
615
615
|
{
|
|
@@ -737,7 +737,7 @@ if((!instantiated_.scheme_.isVariable_)) {
|
|
|
737
737
|
const signature_ = (((_c) => {
|
|
738
738
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, ff_core_List.List_dropFirst(instantiated_.scheme_.signature_.parameters_, 1), _c.returnType_, _c.effect_)
|
|
739
739
|
}))(instantiated_.scheme_.signature_);
|
|
740
|
-
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, ff_core_List.
|
|
740
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.internalGrab_(instantiated_.scheme_.signature_.parameters_, 0)).valueType_);
|
|
741
741
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
742
742
|
}
|
|
743
743
|
}
|
|
@@ -1497,7 +1497,7 @@ const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(sel
|
|
|
1497
1497
|
const argumentTypes_ = ff_core_List.List_map(e_.arguments_, ((_w1) => {
|
|
1498
1498
|
return ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, _w1.at_)
|
|
1499
1499
|
}));
|
|
1500
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(e_.at_, ("Function$" +
|
|
1500
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(e_.at_, ("Function$" + e_.arguments_.length), [effect_, ...argumentTypes_, expected_]);
|
|
1501
1501
|
const function_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, functionType_, call_.function_);
|
|
1502
1502
|
const arguments_ = ff_core_List.List_map(ff_core_List.List_zip(e_.arguments_, argumentTypes_), ((_1) => {
|
|
1503
1503
|
{
|
|
@@ -1962,9 +1962,9 @@ return (_w1 === "Q$")
|
|
|
1962
1962
|
})))
|
|
1963
1963
|
? [ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_), ...typeArguments_]
|
|
1964
1964
|
: typeArguments_);
|
|
1965
|
-
if(((
|
|
1966
|
-
const extra_ = (
|
|
1967
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("Wrong number of type arguments for " + symbol_) + ", expected ") + (
|
|
1965
|
+
if(((scheme_.signature_.generics_.length !== newTypeArguments_.length) && (!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)))) {
|
|
1966
|
+
const extra_ = (newTypeArguments_.length - typeArguments_.length);
|
|
1967
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("Wrong number of type arguments for " + symbol_) + ", expected ") + (scheme_.signature_.generics_.length - extra_)) + ", got ") + (newTypeArguments_.length - extra_))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1968
1968
|
};
|
|
1969
1969
|
return ff_core_List.List_zip(scheme_.signature_.generics_, newTypeArguments_)
|
|
1970
1970
|
})()
|
|
@@ -2065,8 +2065,8 @@ const traitName_ = definition_.traitName_;
|
|
|
2065
2065
|
const traitDefinition_ = ff_core_Option.Option_else(ff_core_Map.Map_get(environment_.traits_, traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
2066
2066
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2067
2067
|
}));
|
|
2068
|
-
if((
|
|
2069
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (
|
|
2068
|
+
if((traitDefinition_.generics_.length !== definition_.typeArguments_.length)) {
|
|
2069
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (traitDefinition_.generics_.length - 1)) + ", got ") + (definition_.typeArguments_.length - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2070
2070
|
};
|
|
2071
2071
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2072
2072
|
for(let for_i = 0, for_a = traitDefinition_.methods_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
@@ -2104,11 +2104,11 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
2104
2104
|
}
|
|
2105
2105
|
}));
|
|
2106
2106
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
2107
|
-
for(let for_i = Math.max(
|
|
2107
|
+
for(let for_i = Math.max(parameters_.length, 0), for_a = instanceFunction_.signature_.parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2108
2108
|
const instanceParameter_ = for_a[for_i];
|
|
2109
2109
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2110
2110
|
};
|
|
2111
|
-
for(let for_i = Math.max(
|
|
2111
|
+
for(let for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0), for_a = parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2112
2112
|
const traitParameter_ = for_a[for_i];
|
|
2113
2113
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2114
2114
|
};
|
|
@@ -2205,7 +2205,7 @@ return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_add
|
|
|
2205
2205
|
const parameterTypes_ = ff_core_List.List_map(parameters_, ((_w1) => {
|
|
2206
2206
|
return _w1.second_.signature_.returnType_
|
|
2207
2207
|
}));
|
|
2208
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(definition_.at_, ("Function$" +
|
|
2208
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(definition_.at_, ("Function$" + parameterTypes_.length), [definition_.signature_.effect_, ...parameterTypes_, definition_.signature_.returnType_]);
|
|
2209
2209
|
const instances_ = ff_compiler_Inference.constraintsToInstances_(definition_.signature_.constraints_);
|
|
2210
2210
|
return ff_compiler_Unification.Unification_withLocalInstances(self_.unification_, instances_, (() => {
|
|
2211
2211
|
{
|
|
@@ -2276,7 +2276,7 @@ const parameterTypes_ = ff_core_List.List_map(case_.patterns_, ((_w1) => {
|
|
|
2276
2276
|
return ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, _w1.at_)
|
|
2277
2277
|
}));
|
|
2278
2278
|
const returnType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, case_.at_);
|
|
2279
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(case_.at_, ("Function$" +
|
|
2279
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(case_.at_, ("Function$" + case_.patterns_.length), [environment_.effect_, ...parameterTypes_, returnType_]);
|
|
2280
2280
|
ff_compiler_Unification.Unification_unify(self_.unification_, case_.at_, expected_, functionType_);
|
|
2281
2281
|
const environment1_ = ff_core_List.List_foldLeft(ff_core_List.List_zip(parameterTypes_, case_.patterns_), environment_, ((_1, _2) => {
|
|
2282
2282
|
{
|
|
@@ -2460,8 +2460,8 @@ const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference
|
|
|
2460
2460
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2461
2461
|
}));
|
|
2462
2462
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, instantiated_.scheme_.signature_.returnType_);
|
|
2463
|
-
if(((
|
|
2464
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (((("Wrong number of subpatterns, expected " +
|
|
2463
|
+
if(((patterns_.length !== instantiated_.scheme_.signature_.parameters_.length) && (!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)))) {
|
|
2464
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (((("Wrong number of subpatterns, expected " + instantiated_.scheme_.signature_.parameters_.length) + ", got ") + patterns_.length) + ".")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2465
2465
|
};
|
|
2466
2466
|
return ff_core_List.List_foldLeft(ff_core_List.List_map(ff_core_List.List_zip(patterns_, instantiated_.scheme_.signature_.parameters_), ((_1) => {
|
|
2467
2467
|
{
|
|
@@ -2589,7 +2589,7 @@ if((!instantiated_.scheme_.isVariable_)) {
|
|
|
2589
2589
|
const signature_ = (((_c) => {
|
|
2590
2590
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, ff_core_List.List_dropFirst(instantiated_.scheme_.signature_.parameters_, 1), _c.returnType_, _c.effect_)
|
|
2591
2591
|
}))(instantiated_.scheme_.signature_);
|
|
2592
|
-
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, ff_core_List.
|
|
2592
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.internalGrab_(instantiated_.scheme_.signature_.parameters_, 0)).valueType_);
|
|
2593
2593
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
@@ -3349,7 +3349,7 @@ const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(sel
|
|
|
3349
3349
|
const argumentTypes_ = ff_core_List.List_map(e_.arguments_, ((_w1) => {
|
|
3350
3350
|
return ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, _w1.at_)
|
|
3351
3351
|
}));
|
|
3352
|
-
const functionType_ = ff_compiler_Syntax.TConstructor(e_.at_, ("Function$" +
|
|
3352
|
+
const functionType_ = ff_compiler_Syntax.TConstructor(e_.at_, ("Function$" + e_.arguments_.length), [effect_, ...argumentTypes_, expected_]);
|
|
3353
3353
|
const function_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, functionType_, call_.function_);
|
|
3354
3354
|
const arguments_ = ff_core_List.List_map(ff_core_List.List_zip(e_.arguments_, argumentTypes_), ((_1) => {
|
|
3355
3355
|
{
|
|
@@ -3814,9 +3814,9 @@ return (_w1 === "Q$")
|
|
|
3814
3814
|
})))
|
|
3815
3815
|
? [ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_), ...typeArguments_]
|
|
3816
3816
|
: typeArguments_);
|
|
3817
|
-
if(((
|
|
3818
|
-
const extra_ = (
|
|
3819
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("Wrong number of type arguments for " + symbol_) + ", expected ") + (
|
|
3817
|
+
if(((scheme_.signature_.generics_.length !== newTypeArguments_.length) && (!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)))) {
|
|
3818
|
+
const extra_ = (newTypeArguments_.length - typeArguments_.length);
|
|
3819
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("Wrong number of type arguments for " + symbol_) + ", expected ") + (scheme_.signature_.generics_.length - extra_)) + ", got ") + (newTypeArguments_.length - extra_))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3820
3820
|
};
|
|
3821
3821
|
return ff_core_List.List_zip(scheme_.signature_.generics_, newTypeArguments_)
|
|
3822
3822
|
})()
|
|
@@ -931,7 +931,7 @@ return ff_compiler_JsEmitter.escapeKeyword_(_w1.name_)
|
|
|
931
931
|
})), ", ");
|
|
932
932
|
if(ff_core_List.List_isEmpty(allFields_)) {
|
|
933
933
|
return ((((((((((((("const " + definition_.name_) + "$ = {") + definition_.name_) + ": true};\n") + "export function ") + definition_.name_) + "(") + fields_) + ") {\n") + "return ") + definition_.name_) + "$;\n") + "}")
|
|
934
|
-
} else if((
|
|
934
|
+
} else if((typeDefinition_.variants_.length === 1)) {
|
|
935
935
|
return (((((((("export function " + definition_.name_) + "(") + fields_) + ") {\n") + "return {") + fields_) + "};\n") + "}")
|
|
936
936
|
} else {
|
|
937
937
|
return (((((((((("export function " + definition_.name_) + "(") + fields_) + ") {\n") + "return {") + definition_.name_) + ": true, ") + fields_) + "};\n") + "}")
|
|
@@ -1094,7 +1094,7 @@ const controller_ = (newAsync_
|
|
|
1094
1094
|
? ["$task"]
|
|
1095
1095
|
: []);
|
|
1096
1096
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
1097
|
-
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs(ff_core_List.
|
|
1097
|
+
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.internalGrab_(cases_, 0)).patterns_), ((_w1) => {
|
|
1098
1098
|
return ("_" + (_w1.first_ + 1))
|
|
1099
1099
|
}));
|
|
1100
1100
|
const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
|
|
@@ -1179,7 +1179,7 @@ const typeArguments_ = _1.typeArguments_;
|
|
|
1179
1179
|
const arguments_ = _1.arguments_;
|
|
1180
1180
|
const dictionaries_ = _1.dictionaries_;
|
|
1181
1181
|
if(ff_core_String.String_contains(name_, "bundleForBrowser")) {
|
|
1182
|
-
if((!ff_core_Option.Option_contains(ff_core_List.
|
|
1182
|
+
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.internalGrab_(arguments_, 0)).name_, "system", ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String))) {
|
|
1183
1183
|
ff_core_Log.debug_(("Wrong arguments for bundleForBrowser: " + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_core_Show.ff_core_Show_Show$ff_core_String_String)).show_(ff_core_List.List_map(arguments_, ((_w1) => {
|
|
1184
1184
|
return _w1.name_
|
|
1185
1185
|
})))));
|
|
@@ -1508,19 +1508,39 @@ return ff_core_Option.Some((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(
|
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
1510
|
if(_1 === "ff:core/List.List_grab") {
|
|
1511
|
-
const
|
|
1512
|
-
if(
|
|
1513
|
-
const
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1511
|
+
const _guard2 = arguments_;
|
|
1512
|
+
if(_guard2.length === 2) {
|
|
1513
|
+
const e1_ = _guard2[0];
|
|
1514
|
+
const e2_ = _guard2[1];
|
|
1515
|
+
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
1516
|
+
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
1517
|
+
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
1518
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.internalGrab_(") + code1_) + ", ") + code2_) + "))"))
|
|
1519
|
+
}
|
|
1516
1520
|
}
|
|
1517
1521
|
}
|
|
1518
1522
|
if(_1 === "ff:core/Array.Array_grab") {
|
|
1519
1523
|
const _guard1 = arguments_;
|
|
1520
|
-
if(_guard1.length === 2
|
|
1521
|
-
const
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1524
|
+
if(_guard1.length === 2) {
|
|
1525
|
+
const e1_ = _guard1[0];
|
|
1526
|
+
const e2_ = _guard1[1];
|
|
1527
|
+
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
1528
|
+
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
1529
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.internalGrab_(") + code1_) + ", ") + code2_) + "))"))
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
if(_1 === "ff:core/List.List_size") {
|
|
1533
|
+
const _guard1 = arguments_;
|
|
1534
|
+
if(_guard1.length === 1) {
|
|
1535
|
+
const e_ = _guard1[0];
|
|
1536
|
+
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".length"))
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if(_1 === "ff:core/Array.Array_size") {
|
|
1540
|
+
const _guard1 = arguments_;
|
|
1541
|
+
if(_guard1.length === 1) {
|
|
1542
|
+
const e_ = _guard1[0];
|
|
1543
|
+
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".array.length"))
|
|
1524
1544
|
}
|
|
1525
1545
|
}
|
|
1526
1546
|
if(_1 === "ff:core/Equal.equals") {
|
|
@@ -2306,7 +2326,7 @@ const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
|
|
|
2306
2326
|
if(_1.first_.length >= 1) {
|
|
2307
2327
|
const p_ = _1.first_[0];
|
|
2308
2328
|
const ps_ = _1.first_.slice(1);
|
|
2309
|
-
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, ff_core_List.
|
|
2329
|
+
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, (arguments_[0] ?? ff_core_List.internalGrab_(arguments_, 0)), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
|
|
2310
2330
|
return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
|
|
2311
2331
|
}))(matchCase_), conditions_, variables_, jump_, last_, async_)
|
|
2312
2332
|
return
|
|
@@ -2331,7 +2351,7 @@ return emitWrapper_(code_)
|
|
|
2331
2351
|
if(_1.first_.length === 0 && _1.second_.length >= 1) {
|
|
2332
2352
|
const guard_ = _1.second_[0];
|
|
2333
2353
|
const guards_ = _1.second_.slice(1);
|
|
2334
|
-
const guardName_ = ("_guard" + (
|
|
2354
|
+
const guardName_ = ("_guard" + (guards_.length + 1));
|
|
2335
2355
|
const newCase_ = (((_c) => {
|
|
2336
2356
|
return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
|
|
2337
2357
|
}))(matchCase_);
|
|
@@ -2417,7 +2437,7 @@ return (((argument_ + "[") + i_) + "]")
|
|
|
2417
2437
|
}
|
|
2418
2438
|
}));
|
|
2419
2439
|
const restArgument_ = ff_core_Option.Option_map(restPattern_, ((_) => {
|
|
2420
|
-
return (((argument_ + ".slice(") +
|
|
2440
|
+
return (((argument_ + ".slice(") + patterns_.length) + ")")
|
|
2421
2441
|
}));
|
|
2422
2442
|
const newArguments_ = [...itemArguments_, ...ff_core_Option.Option_toList(restArgument_), ...arguments_];
|
|
2423
2443
|
const newMatchCase_ = (((_c) => {
|
|
@@ -2428,7 +2448,7 @@ return ">="
|
|
|
2428
2448
|
})), (() => {
|
|
2429
2449
|
return "==="
|
|
2430
2450
|
}));
|
|
2431
|
-
const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") +
|
|
2451
|
+
const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") + patterns_.length)];
|
|
2432
2452
|
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2433
2453
|
}
|
|
2434
2454
|
}
|
|
@@ -2504,7 +2524,7 @@ return ff_core_Option.Option_map(ff_core_List.List_find(definition_.variants_, (
|
|
|
2504
2524
|
return (_w1.name_ === variantName_)
|
|
2505
2525
|
})), ((variant_) => {
|
|
2506
2526
|
newtype_ = definition_.newtype_;
|
|
2507
|
-
loneVariant_ = (
|
|
2527
|
+
loneVariant_ = (definition_.variants_.length === 1);
|
|
2508
2528
|
return [...ff_core_List.List_map(definition_.commonFields_, ((_w1) => {
|
|
2509
2529
|
return _w1.name_
|
|
2510
2530
|
})), ...ff_core_List.List_map(variant_.fields_, ((_w1) => {
|
|
@@ -2884,7 +2904,7 @@ return ff_compiler_JsEmitter.escapeKeyword_(_w1.name_)
|
|
|
2884
2904
|
})), ", ");
|
|
2885
2905
|
if(ff_core_List.List_isEmpty(allFields_)) {
|
|
2886
2906
|
return ((((((((((((("const " + definition_.name_) + "$ = {") + definition_.name_) + ": true};\n") + "export function ") + definition_.name_) + "(") + fields_) + ") {\n") + "return ") + definition_.name_) + "$;\n") + "}")
|
|
2887
|
-
} else if((
|
|
2907
|
+
} else if((typeDefinition_.variants_.length === 1)) {
|
|
2888
2908
|
return (((((((("export function " + definition_.name_) + "(") + fields_) + ") {\n") + "return {") + fields_) + "};\n") + "}")
|
|
2889
2909
|
} else {
|
|
2890
2910
|
return (((((((((("export function " + definition_.name_) + "(") + fields_) + ") {\n") + "return {") + definition_.name_) + ": true, ") + fields_) + "};\n") + "}")
|
|
@@ -3047,7 +3067,7 @@ const controller_ = (newAsync_
|
|
|
3047
3067
|
? ["$task"]
|
|
3048
3068
|
: []);
|
|
3049
3069
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
3050
|
-
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs(ff_core_List.
|
|
3070
|
+
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.internalGrab_(cases_, 0)).patterns_), ((_w1) => {
|
|
3051
3071
|
return ("_" + (_w1.first_ + 1))
|
|
3052
3072
|
}));
|
|
3053
3073
|
const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
|
|
@@ -3132,7 +3152,7 @@ const typeArguments_ = _1.typeArguments_;
|
|
|
3132
3152
|
const arguments_ = _1.arguments_;
|
|
3133
3153
|
const dictionaries_ = _1.dictionaries_;
|
|
3134
3154
|
if(ff_core_String.String_contains(name_, "bundleForBrowser")) {
|
|
3135
|
-
if((!ff_core_Option.Option_contains(ff_core_List.
|
|
3155
|
+
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.internalGrab_(arguments_, 0)).name_, "system", ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String))) {
|
|
3136
3156
|
ff_core_Log.debug_(("Wrong arguments for bundleForBrowser: " + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_core_Show.ff_core_Show_Show$ff_core_String_String)).show_(ff_core_List.List_map(arguments_, ((_w1) => {
|
|
3137
3157
|
return _w1.name_
|
|
3138
3158
|
})))));
|
|
@@ -3461,19 +3481,39 @@ return ff_core_Option.Some((((((("(" + (await ff_compiler_JsEmitter.JsEmitter_em
|
|
|
3461
3481
|
}
|
|
3462
3482
|
}
|
|
3463
3483
|
if(_1 === "ff:core/List.List_grab") {
|
|
3464
|
-
const
|
|
3465
|
-
if(
|
|
3466
|
-
const
|
|
3467
|
-
const
|
|
3468
|
-
|
|
3484
|
+
const _guard2 = arguments_;
|
|
3485
|
+
if(_guard2.length === 2) {
|
|
3486
|
+
const e1_ = _guard2[0];
|
|
3487
|
+
const e2_ = _guard2[1];
|
|
3488
|
+
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
3489
|
+
const code1_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e1_, async_, $task));
|
|
3490
|
+
const code2_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e2_, async_, $task));
|
|
3491
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.internalGrab_(") + code1_) + ", ") + code2_) + "))"))
|
|
3492
|
+
}
|
|
3469
3493
|
}
|
|
3470
3494
|
}
|
|
3471
3495
|
if(_1 === "ff:core/Array.Array_grab") {
|
|
3472
3496
|
const _guard1 = arguments_;
|
|
3473
|
-
if(_guard1.length === 2
|
|
3474
|
-
const
|
|
3475
|
-
const
|
|
3476
|
-
|
|
3497
|
+
if(_guard1.length === 2) {
|
|
3498
|
+
const e1_ = _guard1[0];
|
|
3499
|
+
const e2_ = _guard1[1];
|
|
3500
|
+
const code1_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e1_, async_, $task));
|
|
3501
|
+
const code2_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e2_, async_, $task));
|
|
3502
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.internalGrab_(") + code1_) + ", ") + code2_) + "))"))
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
if(_1 === "ff:core/List.List_size") {
|
|
3506
|
+
const _guard1 = arguments_;
|
|
3507
|
+
if(_guard1.length === 1) {
|
|
3508
|
+
const e_ = _guard1[0];
|
|
3509
|
+
return ff_core_Option.Some(((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task)) + ".length"))
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
if(_1 === "ff:core/Array.Array_size") {
|
|
3513
|
+
const _guard1 = arguments_;
|
|
3514
|
+
if(_guard1.length === 1) {
|
|
3515
|
+
const e_ = _guard1[0];
|
|
3516
|
+
return ff_core_Option.Some(((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task)) + ".array.length"))
|
|
3477
3517
|
}
|
|
3478
3518
|
}
|
|
3479
3519
|
if(_1 === "ff:core/Equal.equals") {
|
|
@@ -4259,7 +4299,7 @@ const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
|
|
|
4259
4299
|
if(_1.first_.length >= 1) {
|
|
4260
4300
|
const p_ = _1.first_[0];
|
|
4261
4301
|
const ps_ = _1.first_.slice(1);
|
|
4262
|
-
return (await ff_compiler_JsEmitter.JsEmitter_emitPattern$(self_, ff_core_List.
|
|
4302
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitPattern$(self_, (arguments_[0] ?? ff_core_List.internalGrab_(arguments_, 0)), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
|
|
4263
4303
|
return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
|
|
4264
4304
|
}))(matchCase_), conditions_, variables_, jump_, last_, async_, $task))
|
|
4265
4305
|
return
|
|
@@ -4284,7 +4324,7 @@ return emitWrapper_(code_)
|
|
|
4284
4324
|
if(_1.first_.length === 0 && _1.second_.length >= 1) {
|
|
4285
4325
|
const guard_ = _1.second_[0];
|
|
4286
4326
|
const guards_ = _1.second_.slice(1);
|
|
4287
|
-
const guardName_ = ("_guard" + (
|
|
4327
|
+
const guardName_ = ("_guard" + (guards_.length + 1));
|
|
4288
4328
|
const newCase_ = (((_c) => {
|
|
4289
4329
|
return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
|
|
4290
4330
|
}))(matchCase_);
|
|
@@ -4370,7 +4410,7 @@ return (((argument_ + "[") + i_) + "]")
|
|
|
4370
4410
|
}
|
|
4371
4411
|
}));
|
|
4372
4412
|
const restArgument_ = ff_core_Option.Option_map(restPattern_, ((_) => {
|
|
4373
|
-
return (((argument_ + ".slice(") +
|
|
4413
|
+
return (((argument_ + ".slice(") + patterns_.length) + ")")
|
|
4374
4414
|
}));
|
|
4375
4415
|
const newArguments_ = [...itemArguments_, ...ff_core_Option.Option_toList(restArgument_), ...arguments_];
|
|
4376
4416
|
const newMatchCase_ = (((_c) => {
|
|
@@ -4381,7 +4421,7 @@ return ">="
|
|
|
4381
4421
|
})), (() => {
|
|
4382
4422
|
return "==="
|
|
4383
4423
|
}));
|
|
4384
|
-
const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") +
|
|
4424
|
+
const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") + patterns_.length)];
|
|
4385
4425
|
return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_, $task))
|
|
4386
4426
|
}
|
|
4387
4427
|
}
|
|
@@ -4457,7 +4497,7 @@ return ff_core_Option.Option_map(ff_core_List.List_find(definition_.variants_, (
|
|
|
4457
4497
|
return (_w1.name_ === variantName_)
|
|
4458
4498
|
})), ((variant_) => {
|
|
4459
4499
|
newtype_ = definition_.newtype_;
|
|
4460
|
-
loneVariant_ = (
|
|
4500
|
+
loneVariant_ = (definition_.variants_.length === 1);
|
|
4461
4501
|
return [...ff_core_List.List_map(definition_.commonFields_, ((_w1) => {
|
|
4462
4502
|
return _w1.name_
|
|
4463
4503
|
})), ...ff_core_List.List_map(variant_.fields_, ((_w1) => {
|