firefly-compiler 0.4.17 → 0.4.19
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/Builder.ff +1 -1
- package/compiler/Compiler.ff +6 -5
- package/compiler/Inference.ff +31 -19
- package/compiler/JsEmitter.ff +98 -71
- package/compiler/JsImporter.ff +1 -1
- package/compiler/LspHook.ff +4 -4
- package/compiler/Main.ff +6 -6
- package/compiler/Parser.ff +39 -39
- package/compiler/Patterns.ff +2 -0
- package/compiler/Syntax.ff +1 -1
- package/compiler/Tokenizer.ff +2 -2
- package/compiler/Workspace.ff +2 -2
- package/core/Array.ff +135 -294
- package/core/Buffer.ff +3 -3
- package/core/BuildSystem.ff +1 -1
- package/core/Equal.ff +36 -52
- package/core/HttpClient.ff +1 -1
- package/core/IntMap.ff +14 -18
- package/core/JsSystem.ff +1 -1
- package/core/JsValue.ff +6 -12
- package/core/Json.ff +19 -28
- package/core/List.ff +281 -312
- package/core/Map.ff +4 -8
- package/core/NodeSystem.ff +2 -2
- package/core/Option.ff +0 -4
- package/core/Ordering.ff +10 -6
- package/core/Pair.ff +0 -4
- package/core/Random.ff +12 -26
- package/core/RbMap.ff +216 -216
- package/core/Serializable.ff +9 -18
- package/core/Set.ff +0 -1
- package/core/SourceLocation.ff +1 -1
- package/core/Stack.ff +32 -45
- package/core/Stream.ff +10 -14
- package/core/String.ff +24 -6
- package/core/StringMap.ff +15 -19
- package/guide/Main.ff +20 -2
- package/lsp/CompletionHandler.ff +4 -4
- package/lsp/Handler.ff +45 -34
- package/lsp/HoverHandler.ff +2 -2
- package/lsp/LanguageServer.ff +2 -2
- package/lsp/SignatureHelpHandler.ff +1 -1
- package/lsp/SymbolHandler.ff +1 -1
- package/lux/Lux.ff +3 -3
- package/output/js/ff/compiler/Builder.mjs +19 -21
- package/output/js/ff/compiler/Compiler.mjs +18 -20
- package/output/js/ff/compiler/Dependencies.mjs +8 -10
- package/output/js/ff/compiler/Deriver.mjs +234 -236
- package/output/js/ff/compiler/Dictionaries.mjs +6 -8
- package/output/js/ff/compiler/Environment.mjs +42 -44
- package/output/js/ff/compiler/Inference.mjs +346 -304
- package/output/js/ff/compiler/JsEmitter.mjs +907 -833
- package/output/js/ff/compiler/JsImporter.mjs +0 -2
- package/output/js/ff/compiler/LspHook.mjs +10 -12
- package/output/js/ff/compiler/Main.mjs +109 -111
- package/output/js/ff/compiler/Parser.mjs +405 -407
- package/output/js/ff/compiler/Patterns.mjs +64 -50
- package/output/js/ff/compiler/Resolver.mjs +36 -38
- package/output/js/ff/compiler/Substitution.mjs +4 -6
- package/output/js/ff/compiler/Syntax.mjs +160 -162
- package/output/js/ff/compiler/Token.mjs +52 -54
- package/output/js/ff/compiler/Tokenizer.mjs +16 -18
- package/output/js/ff/compiler/Unification.mjs +24 -26
- package/output/js/ff/compiler/Wildcards.mjs +0 -2
- package/output/js/ff/compiler/Workspace.mjs +18 -20
- package/output/js/ff/core/Any.mjs +0 -2
- package/output/js/ff/core/Array.mjs +216 -613
- package/output/js/ff/core/AssetSystem.mjs +2 -4
- package/output/js/ff/core/Atomic.mjs +0 -2
- package/output/js/ff/core/Bool.mjs +0 -2
- package/output/js/ff/core/Box.mjs +0 -2
- package/output/js/ff/core/BrowserSystem.mjs +0 -2
- package/output/js/ff/core/Buffer.mjs +0 -2
- package/output/js/ff/core/BuildSystem.mjs +12 -14
- package/output/js/ff/core/Channel.mjs +0 -2
- package/output/js/ff/core/Char.mjs +0 -2
- package/output/js/ff/core/Core.mjs +0 -2
- package/output/js/ff/core/Duration.mjs +0 -2
- package/output/js/ff/core/Equal.mjs +0 -22
- package/output/js/ff/core/Error.mjs +0 -2
- package/output/js/ff/core/FileHandle.mjs +0 -2
- package/output/js/ff/core/Float.mjs +0 -2
- package/output/js/ff/core/HttpClient.mjs +2 -4
- package/output/js/ff/core/Instant.mjs +0 -2
- package/output/js/ff/core/Int.mjs +8 -10
- package/output/js/ff/core/IntMap.mjs +32 -42
- package/output/js/ff/core/JsSystem.mjs +1 -3
- package/output/js/ff/core/JsValue.mjs +5 -12
- package/output/js/ff/core/Json.mjs +23 -56
- package/output/js/ff/core/List.mjs +648 -1989
- package/output/js/ff/core/Lock.mjs +0 -2
- package/output/js/ff/core/Log.mjs +0 -2
- package/output/js/ff/core/Map.mjs +10 -20
- package/output/js/ff/core/NodeSystem.mjs +6 -8
- package/output/js/ff/core/Nothing.mjs +0 -2
- package/output/js/ff/core/Option.mjs +8 -18
- package/output/js/ff/core/Ordering.mjs +20 -98
- package/output/js/ff/core/Pair.mjs +6 -16
- package/output/js/ff/core/Path.mjs +12 -14
- package/output/js/ff/core/Random.mjs +24 -54
- package/output/js/ff/core/RbMap.mjs +54 -56
- package/output/js/ff/core/Serializable.mjs +19 -36
- package/output/js/ff/core/Set.mjs +0 -14
- package/output/js/ff/core/Show.mjs +0 -2
- package/output/js/ff/core/SourceLocation.mjs +0 -2
- package/output/js/ff/core/Stream.mjs +34 -44
- package/output/js/ff/core/String.mjs +31 -5
- package/output/js/ff/core/StringMap.mjs +32 -42
- package/output/js/ff/core/Task.mjs +0 -2
- package/output/js/ff/core/Try.mjs +0 -2
- package/output/js/ff/core/Unit.mjs +0 -2
- package/package.json +1 -1
- package/vscode/package.json +1 -1
- package/webserver/WebServer.ff +8 -8
- package/output/js/ff/core/Stack.mjs +0 -603
|
@@ -82,8 +82,6 @@ import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
|
82
82
|
|
|
83
83
|
import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
|
|
84
84
|
|
|
85
|
-
import * as ff_core_Stack from "../../ff/core/Stack.mjs"
|
|
86
|
-
|
|
87
85
|
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
88
86
|
|
|
89
87
|
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
@@ -126,14 +124,14 @@ const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.package
|
|
|
126
124
|
const _1 = module_;
|
|
127
125
|
{
|
|
128
126
|
const _c = _1;
|
|
129
|
-
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_,
|
|
127
|
+
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, [...module_.instances_, ...ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)], _c.extends_, _c.lets_, _c.functions_)
|
|
130
128
|
return
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
export function Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_) {
|
|
136
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
134
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Serializable.DeserializationChecksumException", "ff:core/Core.GrabException", "ff:core/Unit.Unit", "ff:core/Pair.Pair", "ff:core/Option.Option", "ff:core/Int.Int", "ff:core/Float.Float", "ff:core/String.String", "ff:core/Char.Char", "ff:core/Bool.Bool", "ff:core/List.List"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
137
135
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
|
|
138
136
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
139
137
|
return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
|
|
@@ -145,28 +143,28 @@ const at_ = (((_c) => {
|
|
|
145
143
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
146
144
|
}))(declaration_.at_);
|
|
147
145
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
148
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag",
|
|
146
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
149
147
|
}));
|
|
150
148
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
151
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
149
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
152
150
|
}));
|
|
153
151
|
const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
|
|
154
152
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
|
|
155
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
156
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false,
|
|
153
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
154
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, [], [], [], ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", [selfType_]), noEffect_);
|
|
157
155
|
const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
158
|
-
return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag",
|
|
156
|
+
return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", [], [_w1]), "show", [])
|
|
159
157
|
}));
|
|
160
|
-
const strings_ =
|
|
161
|
-
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
162
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
163
|
-
})),
|
|
158
|
+
const strings_ = [ff_compiler_Syntax.EString(at_, "\"[\""), ...ff_core_List.List_separate(typeArgumentStrings_, [ff_compiler_Syntax.EString(at_, "\",\"")]), ff_compiler_Syntax.EString(at_, "\"]\"")];
|
|
159
|
+
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", [ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
|
|
160
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [a_, b_], [])
|
|
161
|
+
}))], []))]));
|
|
164
162
|
const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
165
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag",
|
|
163
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", [selfType_], [], [method_], true)
|
|
166
164
|
}
|
|
167
165
|
|
|
168
166
|
export function Deriver_makeShowInstances(self_, modulePrefix_, module_) {
|
|
169
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
167
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
170
168
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
|
|
171
169
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
172
170
|
return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
|
|
@@ -178,24 +176,24 @@ const at_ = (((_c) => {
|
|
|
178
176
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
179
177
|
}))(declaration_.at_);
|
|
180
178
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
181
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show",
|
|
179
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
182
180
|
}));
|
|
183
181
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
184
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
182
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
185
183
|
}));
|
|
186
184
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
187
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
188
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "show", false,
|
|
185
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
186
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", []), noEffect_);
|
|
189
187
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
190
188
|
const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
191
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show",
|
|
189
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", [selfType_], [], [showMethod_], true)
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
export function Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_) {
|
|
195
193
|
const at_ = (((_c) => {
|
|
196
194
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
197
195
|
}))(declaration_.at_);
|
|
198
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
196
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
199
197
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
200
198
|
{
|
|
201
199
|
const _1 = declaration_.variants_;
|
|
@@ -203,14 +201,14 @@ const _1 = declaration_.variants_;
|
|
|
203
201
|
const variants_ = _1;
|
|
204
202
|
return ff_core_List.List_map(variants_, ((variant_) => {
|
|
205
203
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
206
|
-
const fields_ =
|
|
204
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
207
205
|
const strings_ = ((ff_core_List.List_size(fields_) === 0)
|
|
208
|
-
?
|
|
209
|
-
:
|
|
210
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show",
|
|
211
|
-
})),
|
|
212
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
213
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
206
|
+
? []
|
|
207
|
+
: [ff_compiler_Syntax.EString(at_, "\"(\""), ...ff_core_List.List_separate(ff_core_List.List_map(fields_, ((field_) => {
|
|
208
|
+
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_)], [])
|
|
209
|
+
})), [ff_compiler_Syntax.EString(at_, "\", \"")]), ff_compiler_Syntax.EString(at_, "\")\"")]);
|
|
210
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z"))], [], ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
|
|
211
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [a_, b_], [])
|
|
214
212
|
})))
|
|
215
213
|
}))
|
|
216
214
|
return
|
|
@@ -219,7 +217,7 @@ return
|
|
|
219
217
|
}
|
|
220
218
|
|
|
221
219
|
export function Deriver_makeOrderingInstances(self_, modulePrefix_, module_) {
|
|
222
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
220
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
223
221
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
|
|
224
222
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
225
223
|
return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
|
|
@@ -231,34 +229,34 @@ const at_ = (((_c) => {
|
|
|
231
229
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
232
230
|
}))(declaration_.at_);
|
|
233
231
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
234
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order",
|
|
232
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
235
233
|
}));
|
|
236
234
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
237
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
235
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
238
236
|
}));
|
|
239
237
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
240
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
241
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false,
|
|
238
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
239
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", []), noEffect_);
|
|
242
240
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
243
241
|
const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
244
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order",
|
|
242
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", [selfType_], [], [compareMethod_], true)
|
|
245
243
|
}
|
|
246
244
|
|
|
247
245
|
export function Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_) {
|
|
248
246
|
const at_ = (((_c) => {
|
|
249
247
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
250
248
|
}))(declaration_.at_);
|
|
251
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
249
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
252
250
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
253
|
-
const sameCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
251
|
+
const sameCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", [ff_compiler_Syntax.EVariable(at_, "x"), ff_compiler_Syntax.EVariable(at_, "y")], []), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", []))], ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", [], ff_core_Option.None()));
|
|
254
252
|
{
|
|
255
253
|
const _1 = declaration_.variants_;
|
|
256
254
|
{
|
|
257
|
-
if(_1.
|
|
258
|
-
const variant_ = _1
|
|
259
|
-
if(_1.
|
|
260
|
-
const fields_ =
|
|
261
|
-
return
|
|
255
|
+
if(_1.length > 0) {
|
|
256
|
+
const variant_ = _1[0];
|
|
257
|
+
if(_1.length === 1) {
|
|
258
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
259
|
+
return [sameCase_, ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))]
|
|
262
260
|
return
|
|
263
261
|
}
|
|
264
262
|
}
|
|
@@ -270,22 +268,22 @@ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_Li
|
|
|
270
268
|
}));
|
|
271
269
|
const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
|
|
272
270
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
273
|
-
const fields_ =
|
|
274
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
271
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
272
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y"))], [], ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
|
|
275
273
|
}));
|
|
276
|
-
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int",
|
|
277
|
-
const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false,
|
|
274
|
+
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", []);
|
|
275
|
+
const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None())], intType_, noEffect_);
|
|
278
276
|
const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
|
|
279
277
|
{
|
|
280
278
|
const index_ = _1.first_;
|
|
281
279
|
const variant_ = _1.second_;
|
|
282
280
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
283
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
281
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None())], [], ff_compiler_Syntax.EInt(at_, ("" + index_)))
|
|
284
282
|
return
|
|
285
283
|
}
|
|
286
284
|
}));
|
|
287
|
-
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_,
|
|
288
|
-
return
|
|
285
|
+
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Syntax.EFunctions(at_, [ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_)))], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", [ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", [ff_compiler_Syntax.EVariable(at_, "x")], []), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", [ff_compiler_Syntax.EVariable(at_, "y")], [])], [])));
|
|
286
|
+
return [sameCase_, ...sameVariantCases_, differentVariant_]
|
|
289
287
|
return
|
|
290
288
|
}
|
|
291
289
|
}
|
|
@@ -295,24 +293,24 @@ export function Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, f
|
|
|
295
293
|
const at_ = (((_c) => {
|
|
296
294
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
297
295
|
}))(declaration_.at_);
|
|
298
|
-
const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering",
|
|
299
|
-
const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame",
|
|
296
|
+
const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", []);
|
|
297
|
+
const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", [], ff_core_Option.None());
|
|
300
298
|
function go_(fields_) {
|
|
301
299
|
{
|
|
302
300
|
const fields_a = fields_;
|
|
303
301
|
{
|
|
304
|
-
if(fields_a.
|
|
302
|
+
if(fields_a.length === 0) {
|
|
305
303
|
return orderingSame_
|
|
306
304
|
return
|
|
307
305
|
}
|
|
308
306
|
}
|
|
309
307
|
{
|
|
310
|
-
if(fields_a.
|
|
311
|
-
const head_ = fields_a
|
|
312
|
-
const tail_ = fields_a.
|
|
308
|
+
if(fields_a.length > 0) {
|
|
309
|
+
const head_ = fields_a[0];
|
|
310
|
+
const tail_ = fields_a.slice(1);
|
|
313
311
|
const variableName_ = (head_.name_ + "Ordering");
|
|
314
|
-
const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare",
|
|
315
|
-
const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==",
|
|
312
|
+
const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], []);
|
|
313
|
+
const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", [ff_compiler_Syntax.EVariable(at_, variableName_), orderingSame_], []);
|
|
316
314
|
const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
|
|
317
315
|
return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
|
|
318
316
|
return
|
|
@@ -324,7 +322,7 @@ return go_(fields_)
|
|
|
324
322
|
}
|
|
325
323
|
|
|
326
324
|
export function Deriver_makeEqualInstances(self_, modulePrefix_, module_) {
|
|
327
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
325
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option", "ff:core/List.List", "ff:core/Pair.Pair", "ff:core/Unit.Unit"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
328
326
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
|
|
329
327
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
330
328
|
return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
|
|
@@ -336,34 +334,34 @@ const at_ = (((_c) => {
|
|
|
336
334
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
337
335
|
}))(declaration_.at_);
|
|
338
336
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
339
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal",
|
|
337
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
340
338
|
}));
|
|
341
339
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
342
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
340
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
343
341
|
}));
|
|
344
342
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
345
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
346
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false,
|
|
343
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
344
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", []), noEffect_);
|
|
347
345
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
348
346
|
const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
349
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal",
|
|
347
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", [selfType_], [], [equalsMethod_], true)
|
|
350
348
|
}
|
|
351
349
|
|
|
352
350
|
export function Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_) {
|
|
353
351
|
const at_ = (((_c) => {
|
|
354
352
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
355
353
|
}))(declaration_.at_);
|
|
356
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
354
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
357
355
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
358
|
-
const sameCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
356
|
+
const sameCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", [ff_compiler_Syntax.EVariable(at_, "x"), ff_compiler_Syntax.EVariable(at_, "y")], []), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", []))], ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", [], ff_core_Option.None()));
|
|
359
357
|
{
|
|
360
358
|
const _1 = declaration_.variants_;
|
|
361
359
|
{
|
|
362
|
-
if(_1.
|
|
363
|
-
const variant_ = _1
|
|
364
|
-
if(_1.
|
|
365
|
-
const fields_ =
|
|
366
|
-
return
|
|
360
|
+
if(_1.length > 0) {
|
|
361
|
+
const variant_ = _1[0];
|
|
362
|
+
if(_1.length === 1) {
|
|
363
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
364
|
+
return [sameCase_, ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))]
|
|
367
365
|
return
|
|
368
366
|
}
|
|
369
367
|
}
|
|
@@ -375,11 +373,11 @@ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_Li
|
|
|
375
373
|
}));
|
|
376
374
|
const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
|
|
377
375
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
378
|
-
const fields_ =
|
|
379
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
376
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
377
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y"))], [], ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
|
|
380
378
|
}));
|
|
381
|
-
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_,
|
|
382
|
-
return
|
|
379
|
+
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", [], ff_core_Option.None()));
|
|
380
|
+
return [sameCase_, ...sameVariantCases_, differentVariant_]
|
|
383
381
|
return
|
|
384
382
|
}
|
|
385
383
|
}
|
|
@@ -393,26 +391,26 @@ function go_(fields_) {
|
|
|
393
391
|
{
|
|
394
392
|
const fields_a = fields_;
|
|
395
393
|
{
|
|
396
|
-
if(fields_a.
|
|
397
|
-
return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True",
|
|
394
|
+
if(fields_a.length === 0) {
|
|
395
|
+
return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", [], ff_core_Option.None())
|
|
398
396
|
return
|
|
399
397
|
}
|
|
400
398
|
}
|
|
401
399
|
{
|
|
402
|
-
if(fields_a.
|
|
403
|
-
const head_ = fields_a
|
|
404
|
-
if(fields_a.
|
|
405
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals",
|
|
400
|
+
if(fields_a.length > 0) {
|
|
401
|
+
const head_ = fields_a[0];
|
|
402
|
+
if(fields_a.length === 1) {
|
|
403
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], [])
|
|
406
404
|
return
|
|
407
405
|
}
|
|
408
406
|
}
|
|
409
407
|
}
|
|
410
408
|
{
|
|
411
|
-
if(fields_a.
|
|
412
|
-
const head_ = fields_a
|
|
413
|
-
const tail_ = fields_a.
|
|
414
|
-
const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals",
|
|
415
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&",
|
|
409
|
+
if(fields_a.length > 0) {
|
|
410
|
+
const head_ = fields_a[0];
|
|
411
|
+
const tail_ = fields_a.slice(1);
|
|
412
|
+
const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], []);
|
|
413
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", [equalsTerm_, go_(tail_)], [])
|
|
416
414
|
return
|
|
417
415
|
}
|
|
418
416
|
}
|
|
@@ -422,7 +420,7 @@ return go_(fields_)
|
|
|
422
420
|
}
|
|
423
421
|
|
|
424
422
|
export function Deriver_makeSerializableInstances(self_, modulePrefix_, module_) {
|
|
425
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
423
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option", "ff:core/Pair.Pair"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
426
424
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
|
|
427
425
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
428
426
|
return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
|
|
@@ -434,20 +432,20 @@ const at_ = (((_c) => {
|
|
|
434
432
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
435
433
|
}))(declaration_.at_);
|
|
436
434
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
437
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable",
|
|
435
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
438
436
|
}));
|
|
439
437
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
440
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
438
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
441
439
|
}));
|
|
442
440
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
443
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
444
|
-
const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization",
|
|
445
|
-
const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false,
|
|
446
|
-
const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false,
|
|
441
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
442
|
+
const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", []);
|
|
443
|
+
const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", []), noEffect_);
|
|
444
|
+
const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None())], selfType_, noEffect_);
|
|
447
445
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
448
446
|
const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
|
|
449
|
-
const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
450
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable",
|
|
447
|
+
const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_))]));
|
|
448
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", [selfType_], [], [ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_)], true)
|
|
451
449
|
}
|
|
452
450
|
|
|
453
451
|
export function Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_) {
|
|
@@ -460,14 +458,14 @@ return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((
|
|
|
460
458
|
const index_ = _1.first_;
|
|
461
459
|
const variant_ = _1.second_;
|
|
462
460
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
463
|
-
const fields_ =
|
|
461
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
464
462
|
const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
|
|
465
|
-
const autoResize_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EVariable(at_, "serialization"), "autoResize",
|
|
466
|
-
const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8",
|
|
463
|
+
const autoResize_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EVariable(at_, "serialization"), "autoResize", [ff_compiler_Syntax.EInt(at_, "1")]);
|
|
464
|
+
const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_compiler_Syntax.EInt(at_, ("" + index_))]);
|
|
467
465
|
const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
|
|
468
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing",
|
|
466
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", [ff_compiler_Syntax.EVariable(at_, "serialization"), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_)], [])
|
|
469
467
|
}));
|
|
470
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
468
|
+
return ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v"))], [], ff_core_List.List_foldLeft([autoResize_, setVariantIndex_, ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), ...fieldSerializations_], updateChecksum_, ((_w1, _w2) => {
|
|
471
469
|
return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
|
|
472
470
|
})))
|
|
473
471
|
return
|
|
@@ -479,36 +477,36 @@ export function Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_,
|
|
|
479
477
|
const at_ = (((_c) => {
|
|
480
478
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
481
479
|
}))(declaration_.at_);
|
|
482
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
480
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
483
481
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
484
|
-
const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8",
|
|
485
|
-
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int",
|
|
482
|
+
const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset")]);
|
|
483
|
+
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", []);
|
|
486
484
|
const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
|
|
487
485
|
const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
|
|
488
486
|
{
|
|
489
487
|
const index_ = _1.first_;
|
|
490
488
|
const variant_ = _1.second_;
|
|
491
489
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
492
|
-
const fields_ =
|
|
490
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
493
491
|
const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
|
|
494
|
-
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing",
|
|
492
|
+
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", [ff_compiler_Syntax.EVariable(at_, "serialization")], []))
|
|
495
493
|
}));
|
|
496
494
|
const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
|
|
497
|
-
const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_,
|
|
498
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
495
|
+
const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, [], ff_core_Option.Some(fieldValues_));
|
|
496
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PInt(at_, ("" + index_))], [], ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
|
|
499
497
|
return
|
|
500
498
|
}
|
|
501
499
|
}));
|
|
502
|
-
const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
503
|
-
const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
500
|
+
const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", [ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", [], ff_core_Option.None())], []));
|
|
501
|
+
const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [...cases_, otherwiseCase_]));
|
|
504
502
|
const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
|
|
505
503
|
return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
|
|
506
504
|
}
|
|
507
505
|
|
|
508
506
|
export function Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_) {
|
|
509
|
-
const fields_ =
|
|
507
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
510
508
|
const variantChecksum_ = ff_core_String.String_size(variantName_);
|
|
511
|
-
return ff_compiler_Syntax.EAssignField(at_, "", ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum", ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
509
|
+
return ff_compiler_Syntax.EAssignField(at_, "", ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum", ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", [ff_compiler_Syntax.EInt(at_, "31"), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum")], []), ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_))], []), "bitOr", [ff_compiler_Syntax.EInt(at_, "0")]))
|
|
512
510
|
}
|
|
513
511
|
|
|
514
512
|
export function Deriver_findTypesThatNeedInstances(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_) {
|
|
@@ -538,27 +536,27 @@ return (_w1 === "Q$")
|
|
|
538
536
|
}))
|
|
539
537
|
}
|
|
540
538
|
|
|
541
|
-
export function Deriver_makeSimpleCall(self_, at_, name_, arguments_, typeArguments_ =
|
|
542
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
539
|
+
export function Deriver_makeSimpleCall(self_, at_, name_, arguments_, typeArguments_ = []) {
|
|
540
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
543
541
|
const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
|
|
544
542
|
return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
|
|
545
543
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
|
|
546
|
-
})),
|
|
544
|
+
})), [])
|
|
547
545
|
}
|
|
548
546
|
|
|
549
547
|
export function Deriver_makeMethodCall(self_, at_, target_, methodName_, arguments_) {
|
|
550
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
548
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
551
549
|
const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
|
|
552
|
-
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_,
|
|
550
|
+
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, [], ff_core_List.List_map(arguments_, ((_w1) => {
|
|
553
551
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
|
|
554
|
-
})),
|
|
552
|
+
})), [])
|
|
555
553
|
}
|
|
556
554
|
|
|
557
555
|
export function Deriver_makeIf(self_, at_, condition_, then_, else_) {
|
|
558
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
556
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
559
557
|
const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
|
|
560
|
-
const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_,
|
|
561
|
-
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_,
|
|
558
|
+
const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, [], [ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], then_)])))], []);
|
|
559
|
+
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, [], [ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], else_)])))], [])
|
|
562
560
|
}
|
|
563
561
|
|
|
564
562
|
export async function Deriver_deriveModule$(self_, module_, $task) {
|
|
@@ -567,14 +565,14 @@ const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.package
|
|
|
567
565
|
const _1 = module_;
|
|
568
566
|
{
|
|
569
567
|
const _c = _1;
|
|
570
|
-
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_,
|
|
568
|
+
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, [...module_.instances_, ...ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)], _c.extends_, _c.lets_, _c.functions_)
|
|
571
569
|
return
|
|
572
570
|
}
|
|
573
571
|
}
|
|
574
572
|
}
|
|
575
573
|
|
|
576
574
|
export async function Deriver_makeHasAnyTagInstances$(self_, modulePrefix_, module_, $task) {
|
|
577
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
575
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Serializable.DeserializationChecksumException", "ff:core/Core.GrabException", "ff:core/Unit.Unit", "ff:core/Pair.Pair", "ff:core/Option.Option", "ff:core/Int.Int", "ff:core/Float.Float", "ff:core/String.String", "ff:core/Char.Char", "ff:core/Bool.Bool", "ff:core/List.List"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
578
576
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
|
|
579
577
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
580
578
|
return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
|
|
@@ -586,28 +584,28 @@ const at_ = (((_c) => {
|
|
|
586
584
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
587
585
|
}))(declaration_.at_);
|
|
588
586
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
589
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag",
|
|
587
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
590
588
|
}));
|
|
591
589
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
592
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
590
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
593
591
|
}));
|
|
594
592
|
const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
|
|
595
593
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
|
|
596
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
597
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false,
|
|
594
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
595
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, [], [], [], ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", [selfType_]), noEffect_);
|
|
598
596
|
const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
599
|
-
return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag",
|
|
597
|
+
return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", [], [_w1]), "show", [])
|
|
600
598
|
}));
|
|
601
|
-
const strings_ =
|
|
602
|
-
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
603
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
604
|
-
})),
|
|
599
|
+
const strings_ = [ff_compiler_Syntax.EString(at_, "\"[\""), ...ff_core_List.List_separate(typeArgumentStrings_, [ff_compiler_Syntax.EString(at_, "\",\"")]), ff_compiler_Syntax.EString(at_, "\"]\"")];
|
|
600
|
+
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", [ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
|
|
601
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [a_, b_], [])
|
|
602
|
+
}))], []))]));
|
|
605
603
|
const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
606
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag",
|
|
604
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", [selfType_], [], [method_], true)
|
|
607
605
|
}
|
|
608
606
|
|
|
609
607
|
export async function Deriver_makeShowInstances$(self_, modulePrefix_, module_, $task) {
|
|
610
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
608
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
611
609
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
|
|
612
610
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
613
611
|
return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
|
|
@@ -619,24 +617,24 @@ const at_ = (((_c) => {
|
|
|
619
617
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
620
618
|
}))(declaration_.at_);
|
|
621
619
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
622
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show",
|
|
620
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
623
621
|
}));
|
|
624
622
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
625
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
623
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
626
624
|
}));
|
|
627
625
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
628
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
629
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "show", false,
|
|
626
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
627
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", []), noEffect_);
|
|
630
628
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
631
629
|
const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
632
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show",
|
|
630
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", [selfType_], [], [showMethod_], true)
|
|
633
631
|
}
|
|
634
632
|
|
|
635
633
|
export async function Deriver_makeShowCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
|
|
636
634
|
const at_ = (((_c) => {
|
|
637
635
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
638
636
|
}))(declaration_.at_);
|
|
639
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
637
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
640
638
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
641
639
|
{
|
|
642
640
|
const _1 = declaration_.variants_;
|
|
@@ -644,14 +642,14 @@ const _1 = declaration_.variants_;
|
|
|
644
642
|
const variants_ = _1;
|
|
645
643
|
return ff_core_List.List_map(variants_, ((variant_) => {
|
|
646
644
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
647
|
-
const fields_ =
|
|
645
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
648
646
|
const strings_ = ((ff_core_List.List_size(fields_) === 0)
|
|
649
|
-
?
|
|
650
|
-
:
|
|
651
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show",
|
|
652
|
-
})),
|
|
653
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
654
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
647
|
+
? []
|
|
648
|
+
: [ff_compiler_Syntax.EString(at_, "\"(\""), ...ff_core_List.List_separate(ff_core_List.List_map(fields_, ((field_) => {
|
|
649
|
+
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_)], [])
|
|
650
|
+
})), [ff_compiler_Syntax.EString(at_, "\", \"")]), ff_compiler_Syntax.EString(at_, "\")\"")]);
|
|
651
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z"))], [], ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
|
|
652
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [a_, b_], [])
|
|
655
653
|
})))
|
|
656
654
|
}))
|
|
657
655
|
return
|
|
@@ -660,7 +658,7 @@ return
|
|
|
660
658
|
}
|
|
661
659
|
|
|
662
660
|
export async function Deriver_makeOrderingInstances$(self_, modulePrefix_, module_, $task) {
|
|
663
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
661
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
664
662
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
|
|
665
663
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
666
664
|
return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
|
|
@@ -672,34 +670,34 @@ const at_ = (((_c) => {
|
|
|
672
670
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
673
671
|
}))(declaration_.at_);
|
|
674
672
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
675
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order",
|
|
673
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
676
674
|
}));
|
|
677
675
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
678
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
676
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
679
677
|
}));
|
|
680
678
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
681
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
682
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false,
|
|
679
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
680
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", []), noEffect_);
|
|
683
681
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
684
682
|
const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
685
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order",
|
|
683
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", [selfType_], [], [compareMethod_], true)
|
|
686
684
|
}
|
|
687
685
|
|
|
688
686
|
export async function Deriver_makeOrderingCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
|
|
689
687
|
const at_ = (((_c) => {
|
|
690
688
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
691
689
|
}))(declaration_.at_);
|
|
692
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
690
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
693
691
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
694
|
-
const sameCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
692
|
+
const sameCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", [ff_compiler_Syntax.EVariable(at_, "x"), ff_compiler_Syntax.EVariable(at_, "y")], []), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", []))], ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", [], ff_core_Option.None()));
|
|
695
693
|
{
|
|
696
694
|
const _1 = declaration_.variants_;
|
|
697
695
|
{
|
|
698
|
-
if(_1.
|
|
699
|
-
const variant_ = _1
|
|
700
|
-
if(_1.
|
|
701
|
-
const fields_ =
|
|
702
|
-
return
|
|
696
|
+
if(_1.length > 0) {
|
|
697
|
+
const variant_ = _1[0];
|
|
698
|
+
if(_1.length === 1) {
|
|
699
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
700
|
+
return [sameCase_, ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))]
|
|
703
701
|
return
|
|
704
702
|
}
|
|
705
703
|
}
|
|
@@ -711,22 +709,22 @@ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_Li
|
|
|
711
709
|
}));
|
|
712
710
|
const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
|
|
713
711
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
714
|
-
const fields_ =
|
|
715
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
712
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
713
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y"))], [], ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
|
|
716
714
|
}));
|
|
717
|
-
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int",
|
|
718
|
-
const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false,
|
|
715
|
+
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", []);
|
|
716
|
+
const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None())], intType_, noEffect_);
|
|
719
717
|
const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
|
|
720
718
|
{
|
|
721
719
|
const index_ = _1.first_;
|
|
722
720
|
const variant_ = _1.second_;
|
|
723
721
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
724
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
722
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None())], [], ff_compiler_Syntax.EInt(at_, ("" + index_)))
|
|
725
723
|
return
|
|
726
724
|
}
|
|
727
725
|
}));
|
|
728
|
-
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_,
|
|
729
|
-
return
|
|
726
|
+
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Syntax.EFunctions(at_, [ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_)))], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", [ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", [ff_compiler_Syntax.EVariable(at_, "x")], []), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", [ff_compiler_Syntax.EVariable(at_, "y")], [])], [])));
|
|
727
|
+
return [sameCase_, ...sameVariantCases_, differentVariant_]
|
|
730
728
|
return
|
|
731
729
|
}
|
|
732
730
|
}
|
|
@@ -736,24 +734,24 @@ export async function Deriver_makeOrderingFields$(self_, modulePrefix_, declarat
|
|
|
736
734
|
const at_ = (((_c) => {
|
|
737
735
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
738
736
|
}))(declaration_.at_);
|
|
739
|
-
const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering",
|
|
740
|
-
const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame",
|
|
737
|
+
const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", []);
|
|
738
|
+
const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", [], ff_core_Option.None());
|
|
741
739
|
function go_(fields_) {
|
|
742
740
|
{
|
|
743
741
|
const fields_a = fields_;
|
|
744
742
|
{
|
|
745
|
-
if(fields_a.
|
|
743
|
+
if(fields_a.length === 0) {
|
|
746
744
|
return orderingSame_
|
|
747
745
|
return
|
|
748
746
|
}
|
|
749
747
|
}
|
|
750
748
|
{
|
|
751
|
-
if(fields_a.
|
|
752
|
-
const head_ = fields_a
|
|
753
|
-
const tail_ = fields_a.
|
|
749
|
+
if(fields_a.length > 0) {
|
|
750
|
+
const head_ = fields_a[0];
|
|
751
|
+
const tail_ = fields_a.slice(1);
|
|
754
752
|
const variableName_ = (head_.name_ + "Ordering");
|
|
755
|
-
const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare",
|
|
756
|
-
const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==",
|
|
753
|
+
const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], []);
|
|
754
|
+
const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", [ff_compiler_Syntax.EVariable(at_, variableName_), orderingSame_], []);
|
|
757
755
|
const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
|
|
758
756
|
return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
|
|
759
757
|
return
|
|
@@ -765,7 +763,7 @@ return go_(fields_)
|
|
|
765
763
|
}
|
|
766
764
|
|
|
767
765
|
export async function Deriver_makeEqualInstances$(self_, modulePrefix_, module_, $task) {
|
|
768
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
766
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option", "ff:core/List.List", "ff:core/Pair.Pair", "ff:core/Unit.Unit"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
769
767
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
|
|
770
768
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
771
769
|
return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
|
|
@@ -777,34 +775,34 @@ const at_ = (((_c) => {
|
|
|
777
775
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
778
776
|
}))(declaration_.at_);
|
|
779
777
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
780
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal",
|
|
778
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
781
779
|
}));
|
|
782
780
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
783
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
781
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
784
782
|
}));
|
|
785
783
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
786
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
787
|
-
const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false,
|
|
784
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
785
|
+
const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", []), noEffect_);
|
|
788
786
|
const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
|
|
789
787
|
const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
|
|
790
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal",
|
|
788
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", [selfType_], [], [equalsMethod_], true)
|
|
791
789
|
}
|
|
792
790
|
|
|
793
791
|
export async function Deriver_makeEqualsCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
|
|
794
792
|
const at_ = (((_c) => {
|
|
795
793
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
796
794
|
}))(declaration_.at_);
|
|
797
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
795
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
798
796
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
799
|
-
const sameCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
797
|
+
const sameCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", [ff_compiler_Syntax.EVariable(at_, "x"), ff_compiler_Syntax.EVariable(at_, "y")], []), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", []))], ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", [], ff_core_Option.None()));
|
|
800
798
|
{
|
|
801
799
|
const _1 = declaration_.variants_;
|
|
802
800
|
{
|
|
803
|
-
if(_1.
|
|
804
|
-
const variant_ = _1
|
|
805
|
-
if(_1.
|
|
806
|
-
const fields_ =
|
|
807
|
-
return
|
|
801
|
+
if(_1.length > 0) {
|
|
802
|
+
const variant_ = _1[0];
|
|
803
|
+
if(_1.length === 1) {
|
|
804
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
805
|
+
return [sameCase_, ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))]
|
|
808
806
|
return
|
|
809
807
|
}
|
|
810
808
|
}
|
|
@@ -816,11 +814,11 @@ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_Li
|
|
|
816
814
|
}));
|
|
817
815
|
const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
|
|
818
816
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
819
|
-
const fields_ =
|
|
820
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
817
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
818
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y"))], [], ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
|
|
821
819
|
}));
|
|
822
|
-
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_,
|
|
823
|
-
return
|
|
820
|
+
const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, wildcardPattern_], [], ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", [], ff_core_Option.None()));
|
|
821
|
+
return [sameCase_, ...sameVariantCases_, differentVariant_]
|
|
824
822
|
return
|
|
825
823
|
}
|
|
826
824
|
}
|
|
@@ -834,26 +832,26 @@ function go_(fields_) {
|
|
|
834
832
|
{
|
|
835
833
|
const fields_a = fields_;
|
|
836
834
|
{
|
|
837
|
-
if(fields_a.
|
|
838
|
-
return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True",
|
|
835
|
+
if(fields_a.length === 0) {
|
|
836
|
+
return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", [], ff_core_Option.None())
|
|
839
837
|
return
|
|
840
838
|
}
|
|
841
839
|
}
|
|
842
840
|
{
|
|
843
|
-
if(fields_a.
|
|
844
|
-
const head_ = fields_a
|
|
845
|
-
if(fields_a.
|
|
846
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals",
|
|
841
|
+
if(fields_a.length > 0) {
|
|
842
|
+
const head_ = fields_a[0];
|
|
843
|
+
if(fields_a.length === 1) {
|
|
844
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], [])
|
|
847
845
|
return
|
|
848
846
|
}
|
|
849
847
|
}
|
|
850
848
|
}
|
|
851
849
|
{
|
|
852
|
-
if(fields_a.
|
|
853
|
-
const head_ = fields_a
|
|
854
|
-
const tail_ = fields_a.
|
|
855
|
-
const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals",
|
|
856
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&",
|
|
850
|
+
if(fields_a.length > 0) {
|
|
851
|
+
const head_ = fields_a[0];
|
|
852
|
+
const tail_ = fields_a.slice(1);
|
|
853
|
+
const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_)], []);
|
|
854
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", [equalsTerm_, go_(tail_)], [])
|
|
857
855
|
return
|
|
858
856
|
}
|
|
859
857
|
}
|
|
@@ -863,7 +861,7 @@ return go_(fields_)
|
|
|
863
861
|
}
|
|
864
862
|
|
|
865
863
|
export async function Deriver_makeSerializableInstances$(self_, modulePrefix_, module_, $task) {
|
|
866
|
-
const coreWhitelist_ = ff_core_List.List_toSet(
|
|
864
|
+
const coreWhitelist_ = ff_core_List.List_toSet(["ff:core/Option.Option", "ff:core/Pair.Pair"], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
867
865
|
const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
|
|
868
866
|
return ff_core_List.List_map(missingInstance_, ((_w1) => {
|
|
869
867
|
return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
|
|
@@ -875,20 +873,20 @@ const at_ = (((_c) => {
|
|
|
875
873
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
876
874
|
}))(declaration_.at_);
|
|
877
875
|
const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
878
|
-
return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable",
|
|
876
|
+
return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", [ff_compiler_Syntax.TConstructor(at_, t_, [])])
|
|
879
877
|
}));
|
|
880
878
|
const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
|
|
881
|
-
return ff_compiler_Syntax.TConstructor(at_, t_,
|
|
879
|
+
return ff_compiler_Syntax.TConstructor(at_, t_, [])
|
|
882
880
|
}));
|
|
883
881
|
const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
|
|
884
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
885
|
-
const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization",
|
|
886
|
-
const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false,
|
|
887
|
-
const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false,
|
|
882
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
883
|
+
const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", []);
|
|
884
|
+
const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None())], ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", []), noEffect_);
|
|
885
|
+
const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, [], [], [ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None())], selfType_, noEffect_);
|
|
888
886
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
889
887
|
const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
|
|
890
|
-
const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
891
|
-
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable",
|
|
888
|
+
const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_))]));
|
|
889
|
+
return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", [selfType_], [], [ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_)], true)
|
|
892
890
|
}
|
|
893
891
|
|
|
894
892
|
export async function Deriver_makeSerializeBody$(self_, modulePrefix_, declaration_, selfType_, $task) {
|
|
@@ -901,14 +899,14 @@ return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((
|
|
|
901
899
|
const index_ = _1.first_;
|
|
902
900
|
const variant_ = _1.second_;
|
|
903
901
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
904
|
-
const fields_ =
|
|
902
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
905
903
|
const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
|
|
906
|
-
const autoResize_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EVariable(at_, "serialization"), "autoResize",
|
|
907
|
-
const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8",
|
|
904
|
+
const autoResize_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EVariable(at_, "serialization"), "autoResize", [ff_compiler_Syntax.EInt(at_, "1")]);
|
|
905
|
+
const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_compiler_Syntax.EInt(at_, ("" + index_))]);
|
|
908
906
|
const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
|
|
909
|
-
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing",
|
|
907
|
+
return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", [ff_compiler_Syntax.EVariable(at_, "serialization"), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_)], [])
|
|
910
908
|
}));
|
|
911
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
909
|
+
return ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_, ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v"))], [], ff_core_List.List_foldLeft([autoResize_, setVariantIndex_, ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), ...fieldSerializations_], updateChecksum_, ((_w1, _w2) => {
|
|
912
910
|
return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
|
|
913
911
|
})))
|
|
914
912
|
return
|
|
@@ -920,36 +918,36 @@ export async function Deriver_makeDeserializeBody$(self_, modulePrefix_, declara
|
|
|
920
918
|
const at_ = (((_c) => {
|
|
921
919
|
return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
|
|
922
920
|
}))(declaration_.at_);
|
|
923
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
921
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
924
922
|
const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
|
|
925
|
-
const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8",
|
|
926
|
-
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int",
|
|
923
|
+
const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", [ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset")]);
|
|
924
|
+
const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", []);
|
|
927
925
|
const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
|
|
928
926
|
const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
|
|
929
927
|
{
|
|
930
928
|
const index_ = _1.first_;
|
|
931
929
|
const variant_ = _1.second_;
|
|
932
930
|
const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
|
|
933
|
-
const fields_ =
|
|
931
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
934
932
|
const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
|
|
935
|
-
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing",
|
|
933
|
+
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", [ff_compiler_Syntax.EVariable(at_, "serialization")], []))
|
|
936
934
|
}));
|
|
937
935
|
const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
|
|
938
|
-
const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_,
|
|
939
|
-
return ff_compiler_Syntax.MatchCase(at_,
|
|
936
|
+
const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, [], ff_core_Option.Some(fieldValues_));
|
|
937
|
+
return ff_compiler_Syntax.MatchCase(at_, [ff_compiler_Syntax.PInt(at_, ("" + index_))], [], ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
|
|
940
938
|
return
|
|
941
939
|
}
|
|
942
940
|
}));
|
|
943
|
-
const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_,
|
|
944
|
-
const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_,
|
|
941
|
+
const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, [wildcardPattern_], [], ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", [ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", [], ff_core_Option.None())], []));
|
|
942
|
+
const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [...cases_, otherwiseCase_]));
|
|
945
943
|
const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
|
|
946
944
|
return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
|
|
947
945
|
}
|
|
948
946
|
|
|
949
947
|
export async function Deriver_makeUpdateChecksum$(self_, at_, variantName_, declaration_, variant_, $task) {
|
|
950
|
-
const fields_ =
|
|
948
|
+
const fields_ = [...declaration_.commonFields_, ...variant_.fields_];
|
|
951
949
|
const variantChecksum_ = ff_core_String.String_size(variantName_);
|
|
952
|
-
return ff_compiler_Syntax.EAssignField(at_, "", ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum", ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+",
|
|
950
|
+
return ff_compiler_Syntax.EAssignField(at_, "", ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum", ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", [ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", [ff_compiler_Syntax.EInt(at_, "31"), ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum")], []), ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_))], []), "bitOr", [ff_compiler_Syntax.EInt(at_, "0")]))
|
|
953
951
|
}
|
|
954
952
|
|
|
955
953
|
export async function Deriver_findTypesThatNeedInstances$(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_, $task) {
|
|
@@ -979,27 +977,27 @@ return (_w1 === "Q$")
|
|
|
979
977
|
}))
|
|
980
978
|
}
|
|
981
979
|
|
|
982
|
-
export async function Deriver_makeSimpleCall$(self_, at_, name_, arguments_, typeArguments_ =
|
|
983
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
980
|
+
export async function Deriver_makeSimpleCall$(self_, at_, name_, arguments_, typeArguments_ = [], $task) {
|
|
981
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
984
982
|
const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
|
|
985
983
|
return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
|
|
986
984
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
|
|
987
|
-
})),
|
|
985
|
+
})), [])
|
|
988
986
|
}
|
|
989
987
|
|
|
990
988
|
export async function Deriver_makeMethodCall$(self_, at_, target_, methodName_, arguments_, $task) {
|
|
991
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
989
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
992
990
|
const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
|
|
993
|
-
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_,
|
|
991
|
+
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, [], ff_core_List.List_map(arguments_, ((_w1) => {
|
|
994
992
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
|
|
995
|
-
})),
|
|
993
|
+
})), [])
|
|
996
994
|
}
|
|
997
995
|
|
|
998
996
|
export async function Deriver_makeIf$(self_, at_, condition_, then_, else_, $task) {
|
|
999
|
-
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing",
|
|
997
|
+
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
1000
998
|
const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
|
|
1001
|
-
const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_,
|
|
1002
|
-
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_,
|
|
999
|
+
const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, [], [ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], then_)])))], []);
|
|
1000
|
+
return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, [], [ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, [ff_compiler_Syntax.MatchCase(at_, [], [], else_)])))], [])
|
|
1003
1001
|
}
|
|
1004
1002
|
|
|
1005
1003
|
export const ff_core_Any_HasAnyTag$ff_compiler_Deriver_Deriver = {
|
|
@@ -1129,7 +1127,7 @@ serialization_.offset_ += 1;
|
|
|
1129
1127
|
{
|
|
1130
1128
|
const _1 = variantIndex_;
|
|
1131
1129
|
{
|
|
1132
|
-
if(_1
|
|
1130
|
+
if(_1 === 0) {
|
|
1133
1131
|
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
|
|
1134
1132
|
return ff_compiler_Deriver.Deriver()
|
|
1135
1133
|
return
|
|
@@ -1161,7 +1159,7 @@ serialization_.offset_ += 1;
|
|
|
1161
1159
|
{
|
|
1162
1160
|
const _1 = variantIndex_;
|
|
1163
1161
|
{
|
|
1164
|
-
if(_1
|
|
1162
|
+
if(_1 === 0) {
|
|
1165
1163
|
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
|
|
1166
1164
|
return ff_compiler_Deriver.Deriver()
|
|
1167
1165
|
return
|