firefly-compiler 0.4.6 → 0.4.7

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.
Files changed (68) hide show
  1. package/output/js/ff/compiler/Builder.mjs +444 -444
  2. package/output/js/ff/compiler/Compiler.mjs +416 -416
  3. package/output/js/ff/compiler/Dependencies.mjs +389 -389
  4. package/output/js/ff/compiler/Deriver.mjs +1170 -1170
  5. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
  6. package/output/js/ff/compiler/Environment.mjs +1015 -1015
  7. package/output/js/ff/compiler/Inference.mjs +4268 -4268
  8. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
  9. package/output/js/ff/compiler/JsImporter.mjs +266 -266
  10. package/output/js/ff/compiler/LspHook.mjs +793 -793
  11. package/output/js/ff/compiler/Main.mjs +1675 -1675
  12. package/output/js/ff/compiler/Parser.mjs +4008 -4008
  13. package/output/js/ff/compiler/Patterns.mjs +927 -927
  14. package/output/js/ff/compiler/Resolver.mjs +2307 -2307
  15. package/output/js/ff/compiler/Substitution.mjs +1150 -1150
  16. package/output/js/ff/compiler/Syntax.mjs +12434 -12434
  17. package/output/js/ff/compiler/Token.mjs +3096 -3096
  18. package/output/js/ff/compiler/Tokenizer.mjs +593 -593
  19. package/output/js/ff/compiler/Unification.mjs +1752 -1752
  20. package/output/js/ff/compiler/Wildcards.mjs +608 -608
  21. package/output/js/ff/compiler/Workspace.mjs +687 -687
  22. package/output/js/ff/core/Any.mjs +143 -143
  23. package/output/js/ff/core/Array.mjs +547 -547
  24. package/output/js/ff/core/AssetSystem.mjs +274 -274
  25. package/output/js/ff/core/Atomic.mjs +154 -154
  26. package/output/js/ff/core/Bool.mjs +152 -152
  27. package/output/js/ff/core/Box.mjs +112 -112
  28. package/output/js/ff/core/BrowserSystem.mjs +126 -126
  29. package/output/js/ff/core/Buffer.mjs +395 -395
  30. package/output/js/ff/core/BuildSystem.mjs +296 -296
  31. package/output/js/ff/core/Channel.mjs +189 -189
  32. package/output/js/ff/core/Char.mjs +149 -149
  33. package/output/js/ff/core/Core.mjs +300 -300
  34. package/output/js/ff/core/Duration.mjs +116 -116
  35. package/output/js/ff/core/Equal.mjs +179 -179
  36. package/output/js/ff/core/Error.mjs +142 -142
  37. package/output/js/ff/core/FileHandle.mjs +150 -150
  38. package/output/js/ff/core/Float.mjs +225 -225
  39. package/output/js/ff/core/HttpClient.mjs +191 -191
  40. package/output/js/ff/core/Instant.mjs +109 -109
  41. package/output/js/ff/core/Int.mjs +265 -265
  42. package/output/js/ff/core/IntMap.mjs +280 -280
  43. package/output/js/ff/core/JsSystem.mjs +238 -238
  44. package/output/js/ff/core/JsValue.mjs +708 -708
  45. package/output/js/ff/core/List.mjs +2334 -2334
  46. package/output/js/ff/core/Lock.mjs +229 -229
  47. package/output/js/ff/core/Log.mjs +163 -163
  48. package/output/js/ff/core/Map.mjs +362 -362
  49. package/output/js/ff/core/NodeSystem.mjs +294 -294
  50. package/output/js/ff/core/Nothing.mjs +104 -104
  51. package/output/js/ff/core/Option.mjs +1015 -1015
  52. package/output/js/ff/core/Ordering.mjs +730 -730
  53. package/output/js/ff/core/Pair.mjs +331 -331
  54. package/output/js/ff/core/Path.mjs +545 -545
  55. package/output/js/ff/core/RbMap.mjs +1940 -1940
  56. package/output/js/ff/core/Serializable.mjs +428 -428
  57. package/output/js/ff/core/Set.mjs +254 -254
  58. package/output/js/ff/core/Show.mjs +205 -205
  59. package/output/js/ff/core/SourceLocation.mjs +229 -229
  60. package/output/js/ff/core/Stack.mjs +529 -529
  61. package/output/js/ff/core/Stream.mjs +1304 -1304
  62. package/output/js/ff/core/String.mjs +365 -365
  63. package/output/js/ff/core/StringMap.mjs +280 -280
  64. package/output/js/ff/core/Task.mjs +320 -320
  65. package/output/js/ff/core/Try.mjs +507 -507
  66. package/output/js/ff/core/Unit.mjs +151 -151
  67. package/package.json +1 -1
  68. package/vscode/package.json +1 -1
@@ -1,1170 +1,1170 @@
1
-
2
-
3
- import * as ff_compiler_Deriver from "../../ff/compiler/Deriver.mjs"
4
-
5
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
6
-
7
- import * as ff_core_Any from "../../ff/core/Any.mjs"
8
-
9
- import * as ff_core_Array from "../../ff/core/Array.mjs"
10
-
11
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
12
-
13
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
14
-
15
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
16
-
17
- import * as ff_core_Box from "../../ff/core/Box.mjs"
18
-
19
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
20
-
21
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
22
-
23
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
24
-
25
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
26
-
27
- import * as ff_core_Char from "../../ff/core/Char.mjs"
28
-
29
- import * as ff_core_Core from "../../ff/core/Core.mjs"
30
-
31
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
32
-
33
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
34
-
35
- import * as ff_core_Error from "../../ff/core/Error.mjs"
36
-
37
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
38
-
39
- import * as ff_core_Float from "../../ff/core/Float.mjs"
40
-
41
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
42
-
43
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
44
-
45
- import * as ff_core_Int from "../../ff/core/Int.mjs"
46
-
47
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
48
-
49
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
50
-
51
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
52
-
53
- import * as ff_core_List from "../../ff/core/List.mjs"
54
-
55
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
56
-
57
- import * as ff_core_Log from "../../ff/core/Log.mjs"
58
-
59
- import * as ff_core_Map from "../../ff/core/Map.mjs"
60
-
61
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
62
-
63
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
64
-
65
- import * as ff_core_Option from "../../ff/core/Option.mjs"
66
-
67
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
68
-
69
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
70
-
71
- import * as ff_core_Path from "../../ff/core/Path.mjs"
72
-
73
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
74
-
75
- import * as ff_core_Set from "../../ff/core/Set.mjs"
76
-
77
- import * as ff_core_Show from "../../ff/core/Show.mjs"
78
-
79
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
80
-
81
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
82
-
83
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
84
-
85
- import * as ff_core_String from "../../ff/core/String.mjs"
86
-
87
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
88
-
89
- import * as ff_core_Task from "../../ff/core/Task.mjs"
90
-
91
- import * as ff_core_Try from "../../ff/core/Try.mjs"
92
-
93
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
94
-
95
- // type Deriver
96
- const Deriver$ = {Deriver: true};
97
- export function Deriver() {
98
- return Deriver$;
99
- }
100
-
101
-
102
-
103
- export function make_() {
104
- return ff_compiler_Deriver.Deriver()
105
- }
106
-
107
- export function fail_(at_, message_) {
108
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
109
- }
110
-
111
- export async function make_$($task) {
112
- return ff_compiler_Deriver.Deriver()
113
- }
114
-
115
- export async function fail_$(at_, message_, $task) {
116
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
117
- }
118
-
119
- export function Deriver_deriveModule(self_, module_) {
120
- const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3));
121
- {
122
- const _1 = module_;
123
- {
124
- const _c = _1;
125
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, ff_core_List.List_addAll(module_.instances_, ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)))))), _c.extends_, _c.lets_, _c.functions_)
126
- return
127
- }
128
- }
129
- }
130
-
131
- export function Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_) {
132
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Serializable.DeserializationChecksumException", ff_core_List.Link("ff:core/Core.GrabException", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Int.Int", ff_core_List.Link("ff:core/Float.Float", ff_core_List.Link("ff:core/String.String", ff_core_List.Link("ff:core/Char.Char", ff_core_List.Link("ff:core/Bool.Bool", ff_core_List.Link("ff:core/List.List", ff_core_List.Empty()))))))))))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
133
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
134
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
135
- return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
136
- }))
137
- }
138
-
139
- export function Deriver_makeHasAnyTagInstance(self_, modulePrefix_, declaration_) {
140
- const at_ = (((_c) => {
141
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
142
- }))(declaration_.at_);
143
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
144
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
145
- }));
146
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
147
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
148
- }));
149
- const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
150
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
151
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
152
- const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty())), noEffect_);
153
- const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
154
- return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", ff_core_List.Empty(), ff_core_List.Link(_w1, ff_core_List.Empty())), "show", ff_core_List.Empty())
155
- }));
156
- const strings_ = ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"[\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(typeArgumentStrings_, ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\",\""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"]\""), ff_core_List.Empty())));
157
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", ff_core_List.Link(ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
158
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
159
- })), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
160
- const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
161
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(method_, ff_core_List.Empty()), true)
162
- }
163
-
164
- export function Deriver_makeShowInstances(self_, modulePrefix_, module_) {
165
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
166
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
167
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
168
- return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
169
- }))
170
- }
171
-
172
- export function Deriver_makeShowInstance(self_, modulePrefix_, declaration_) {
173
- const at_ = (((_c) => {
174
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
175
- }))(declaration_.at_);
176
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
177
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
178
- }));
179
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
180
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
181
- }));
182
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
183
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
184
- const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty()), ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", ff_core_List.Empty()), noEffect_);
185
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
186
- const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
187
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(showMethod_, ff_core_List.Empty()), true)
188
- }
189
-
190
- export function Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_) {
191
- const at_ = (((_c) => {
192
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
193
- }))(declaration_.at_);
194
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
195
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
196
- {
197
- const _1 = declaration_.variants_;
198
- {
199
- const variants_ = _1;
200
- return ff_core_List.List_map(variants_, ((variant_) => {
201
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
202
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
203
- const strings_ = ((ff_core_List.List_size(fields_) === 0)
204
- ? ff_core_List.Empty()
205
- : ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"(\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(ff_core_List.List_map(fields_, ((field_) => {
206
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_), ff_core_List.Empty()), ff_core_List.Empty())
207
- })), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\", \""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\")\""), ff_core_List.Empty()))));
208
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z")), ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
209
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
210
- })))
211
- }))
212
- return
213
- }
214
- }
215
- }
216
-
217
- export function Deriver_makeOrderingInstances(self_, modulePrefix_, module_) {
218
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
219
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
220
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
221
- return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
222
- }))
223
- }
224
-
225
- export function Deriver_makeOrderingInstance(self_, modulePrefix_, declaration_) {
226
- const at_ = (((_c) => {
227
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
228
- }))(declaration_.at_);
229
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
230
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
231
- }));
232
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
233
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
234
- }));
235
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
236
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
237
- const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty()), noEffect_);
238
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
239
- const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
240
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(compareMethod_, ff_core_List.Empty()), true)
241
- }
242
-
243
- export function Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_) {
244
- const at_ = (((_c) => {
245
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
246
- }))(declaration_.at_);
247
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
248
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
249
- const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None()));
250
- {
251
- const _1 = declaration_.variants_;
252
- {
253
- if(_1.Link) {
254
- const variant_ = _1.head_;
255
- if(_1.tail_.Empty) {
256
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
257
- return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
258
- return
259
- }
260
- }
261
- }
262
- {
263
- const variants_ = _1;
264
- const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
265
- return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
266
- }));
267
- const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
268
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
269
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
270
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
271
- }));
272
- const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
273
- const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None()), ff_core_List.Empty()), intType_, noEffect_);
274
- const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
275
- {
276
- const index_ = _1.first_;
277
- const variant_ = _1.second_;
278
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
279
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.EInt(at_, ("" + index_)))
280
- return
281
- }
282
- }));
283
- const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EFunctions(at_, ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_))), ff_core_List.Empty()), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
284
- return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
285
- return
286
- }
287
- }
288
- }
289
-
290
- export function Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_) {
291
- const at_ = (((_c) => {
292
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
293
- }))(declaration_.at_);
294
- const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty());
295
- const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None());
296
- function go_(fields_) {
297
- {
298
- const fields_a = fields_;
299
- {
300
- if(fields_a.Empty) {
301
- return orderingSame_
302
- return
303
- }
304
- }
305
- {
306
- if(fields_a.Link) {
307
- const head_ = fields_a.head_;
308
- const tail_ = fields_a.tail_;
309
- const variableName_ = (head_.name_ + "Ordering");
310
- const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
311
- const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, variableName_), ff_core_List.Link(orderingSame_, ff_core_List.Empty())), ff_core_List.Empty());
312
- const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
313
- return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
314
- return
315
- }
316
- }
317
- }
318
- }
319
- return go_(fields_)
320
- }
321
-
322
- export function Deriver_makeEqualInstances(self_, modulePrefix_, module_) {
323
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/List.List", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Empty())))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
324
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
325
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
326
- return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
327
- }))
328
- }
329
-
330
- export function Deriver_makeEqualInstance(self_, modulePrefix_, declaration_) {
331
- const at_ = (((_c) => {
332
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
333
- }))(declaration_.at_);
334
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
335
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
336
- }));
337
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
338
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
339
- }));
340
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
341
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
342
- const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", ff_core_List.Empty()), noEffect_);
343
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
344
- const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
345
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(equalsMethod_, ff_core_List.Empty()), true)
346
- }
347
-
348
- export function Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_) {
349
- const at_ = (((_c) => {
350
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
351
- }))(declaration_.at_);
352
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
353
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
354
- const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None()));
355
- {
356
- const _1 = declaration_.variants_;
357
- {
358
- if(_1.Link) {
359
- const variant_ = _1.head_;
360
- if(_1.tail_.Empty) {
361
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
362
- return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
363
- return
364
- }
365
- }
366
- }
367
- {
368
- const variants_ = _1;
369
- const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
370
- return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
371
- }));
372
- const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
373
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
374
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
375
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
376
- }));
377
- const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", ff_core_List.Empty(), ff_core_Option.None()));
378
- return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
379
- return
380
- }
381
- }
382
- }
383
-
384
- export function Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_) {
385
- const at_ = (((_c) => {
386
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
387
- }))(declaration_.at_);
388
- function go_(fields_) {
389
- {
390
- const fields_a = fields_;
391
- {
392
- if(fields_a.Empty) {
393
- return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None())
394
- return
395
- }
396
- }
397
- {
398
- if(fields_a.Link) {
399
- const head_ = fields_a.head_;
400
- if(fields_a.tail_.Empty) {
401
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty())
402
- return
403
- }
404
- }
405
- }
406
- {
407
- if(fields_a.Link) {
408
- const head_ = fields_a.head_;
409
- const tail_ = fields_a.tail_;
410
- const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
411
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", ff_core_List.Link(equalsTerm_, ff_core_List.Link(go_(tail_), ff_core_List.Empty())), ff_core_List.Empty())
412
- return
413
- }
414
- }
415
- }
416
- }
417
- return go_(fields_)
418
- }
419
-
420
- export function Deriver_makeSerializableInstances(self_, modulePrefix_, module_) {
421
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Empty())), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
422
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
423
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
424
- return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
425
- }))
426
- }
427
-
428
- export function Deriver_makeSerializableInstance(self_, modulePrefix_, declaration_) {
429
- const at_ = (((_c) => {
430
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
431
- }))(declaration_.at_);
432
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
433
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
434
- }));
435
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
436
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
437
- }));
438
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
439
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
440
- const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", ff_core_List.Empty());
441
- const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", ff_core_List.Empty()), noEffect_);
442
- const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Empty()), selfType_, noEffect_);
443
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
444
- const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
445
- const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_)), ff_core_List.Empty())));
446
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_), ff_core_List.Empty())), true)
447
- }
448
-
449
- export function Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_) {
450
- const at_ = (((_c) => {
451
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
452
- }))(declaration_.at_);
453
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
454
- return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
455
- {
456
- const index_ = _1.first_;
457
- const variant_ = _1.second_;
458
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
459
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
460
- const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
461
- const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + index_)), ff_core_List.Empty())));
462
- const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
463
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_), ff_core_List.Empty())), ff_core_List.Empty())
464
- }));
465
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v")), ff_core_List.Empty())), ff_core_List.Empty(), ff_core_List.List_foldLeft(ff_core_List.Link(setVariantIndex_, ff_core_List.Link(ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), fieldSerializations_)), updateChecksum_, ((_w1, _w2) => {
466
- return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
467
- })))
468
- return
469
- }
470
- }))
471
- }
472
-
473
- export function Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_) {
474
- const at_ = (((_c) => {
475
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
476
- }))(declaration_.at_);
477
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
478
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
479
- const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Empty()));
480
- const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
481
- const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
482
- const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
483
- {
484
- const index_ = _1.first_;
485
- const variant_ = _1.second_;
486
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
487
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
488
- const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
489
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Empty()), ff_core_List.Empty()))
490
- }));
491
- const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
492
- const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, ff_core_List.Empty(), ff_core_Option.Some(fieldValues_));
493
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PInt(at_, ("" + index_)), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
494
- return
495
- }
496
- }));
497
- const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", ff_core_List.Link(ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", ff_core_List.Empty(), ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty()));
498
- const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.List_addAll(cases_, ff_core_List.Link(otherwiseCase_, ff_core_List.Empty()))));
499
- const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
500
- return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
501
- }
502
-
503
- export function Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_) {
504
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
505
- const variantChecksum_ = ff_core_String.String_size(variantName_);
506
- 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_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "31"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum"), ff_core_List.Empty())), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_)), ff_core_List.Empty())), ff_core_List.Empty()), "bitOr", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "0"), ff_core_List.Empty())))
507
- }
508
-
509
- export function Deriver_findTypesThatNeedInstances(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_) {
510
- const typesWithInstance_ = ff_core_List.List_toSet(ff_core_List.List_collect(module_.instances_, ((_1) => {
511
- {
512
- const instance_ = _1;
513
- const _guard1 = ff_core_List.List_first(instance_.typeArguments_);
514
- if(_guard1.Some) {
515
- if(_guard1.value_.TConstructor) {
516
- const name_ = _guard1.value_.name_;
517
- if((instance_.traitName_ === traitName_)) {
518
- return ff_core_Option.Some(name_)
519
- } else return ff_core_Option.None()
520
- return
521
- }
522
- }
523
- }
524
- {
525
- return ff_core_Option.None()
526
- return
527
- }
528
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
529
- return ff_core_List.List_filter(module_.types_, ((t_) => {
530
- return (((((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") !== "ff:core") || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
531
- return (_w1 === "Q$")
532
- })))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
533
- }))
534
- }
535
-
536
- export function Deriver_makeSimpleCall(self_, at_, name_, arguments_, typeArguments_ = ff_core_List.Empty()) {
537
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
538
- const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
539
- return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
540
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
541
- })), ff_core_List.Empty())
542
- }
543
-
544
- export function Deriver_makeMethodCall(self_, at_, target_, methodName_, arguments_) {
545
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
546
- const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
547
- return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, ff_core_List.Empty(), ff_core_List.List_map(arguments_, ((_w1) => {
548
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
549
- })), ff_core_List.Empty())
550
- }
551
-
552
- export function Deriver_makeIf(self_, at_, condition_, then_, else_) {
553
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
554
- const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
555
- const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), then_), ff_core_List.Empty())))), ff_core_List.Empty())), ff_core_List.Empty());
556
- return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), else_), ff_core_List.Empty())))), ff_core_List.Empty()), ff_core_List.Empty())
557
- }
558
-
559
- export async function Deriver_deriveModule$(self_, module_, $task) {
560
- const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3));
561
- {
562
- const _1 = module_;
563
- {
564
- const _c = _1;
565
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, ff_core_List.List_addAll(module_.instances_, ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)))))), _c.extends_, _c.lets_, _c.functions_)
566
- return
567
- }
568
- }
569
- }
570
-
571
- export async function Deriver_makeHasAnyTagInstances$(self_, modulePrefix_, module_, $task) {
572
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Serializable.DeserializationChecksumException", ff_core_List.Link("ff:core/Core.GrabException", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Int.Int", ff_core_List.Link("ff:core/Float.Float", ff_core_List.Link("ff:core/String.String", ff_core_List.Link("ff:core/Char.Char", ff_core_List.Link("ff:core/Bool.Bool", ff_core_List.Link("ff:core/List.List", ff_core_List.Empty()))))))))))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
573
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
574
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
575
- return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
576
- }))
577
- }
578
-
579
- export async function Deriver_makeHasAnyTagInstance$(self_, modulePrefix_, declaration_, $task) {
580
- const at_ = (((_c) => {
581
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
582
- }))(declaration_.at_);
583
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
584
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
585
- }));
586
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
587
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
588
- }));
589
- const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
590
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
591
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
592
- const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty())), noEffect_);
593
- const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
594
- return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", ff_core_List.Empty(), ff_core_List.Link(_w1, ff_core_List.Empty())), "show", ff_core_List.Empty())
595
- }));
596
- const strings_ = ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"[\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(typeArgumentStrings_, ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\",\""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"]\""), ff_core_List.Empty())));
597
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", ff_core_List.Link(ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
598
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
599
- })), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
600
- const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
601
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(method_, ff_core_List.Empty()), true)
602
- }
603
-
604
- export async function Deriver_makeShowInstances$(self_, modulePrefix_, module_, $task) {
605
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
606
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
607
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
608
- return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
609
- }))
610
- }
611
-
612
- export async function Deriver_makeShowInstance$(self_, modulePrefix_, declaration_, $task) {
613
- const at_ = (((_c) => {
614
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
615
- }))(declaration_.at_);
616
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
617
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
618
- }));
619
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
620
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
621
- }));
622
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
623
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
624
- const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty()), ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", ff_core_List.Empty()), noEffect_);
625
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
626
- const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
627
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(showMethod_, ff_core_List.Empty()), true)
628
- }
629
-
630
- export async function Deriver_makeShowCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
631
- const at_ = (((_c) => {
632
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
633
- }))(declaration_.at_);
634
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
635
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
636
- {
637
- const _1 = declaration_.variants_;
638
- {
639
- const variants_ = _1;
640
- return ff_core_List.List_map(variants_, ((variant_) => {
641
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
642
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
643
- const strings_ = ((ff_core_List.List_size(fields_) === 0)
644
- ? ff_core_List.Empty()
645
- : ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"(\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(ff_core_List.List_map(fields_, ((field_) => {
646
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_), ff_core_List.Empty()), ff_core_List.Empty())
647
- })), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\", \""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\")\""), ff_core_List.Empty()))));
648
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z")), ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
649
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
650
- })))
651
- }))
652
- return
653
- }
654
- }
655
- }
656
-
657
- export async function Deriver_makeOrderingInstances$(self_, modulePrefix_, module_, $task) {
658
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
659
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
660
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
661
- return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
662
- }))
663
- }
664
-
665
- export async function Deriver_makeOrderingInstance$(self_, modulePrefix_, declaration_, $task) {
666
- const at_ = (((_c) => {
667
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
668
- }))(declaration_.at_);
669
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
670
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
671
- }));
672
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
673
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
674
- }));
675
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
676
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
677
- const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty()), noEffect_);
678
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
679
- const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
680
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(compareMethod_, ff_core_List.Empty()), true)
681
- }
682
-
683
- export async function Deriver_makeOrderingCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
684
- const at_ = (((_c) => {
685
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
686
- }))(declaration_.at_);
687
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
688
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
689
- const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None()));
690
- {
691
- const _1 = declaration_.variants_;
692
- {
693
- if(_1.Link) {
694
- const variant_ = _1.head_;
695
- if(_1.tail_.Empty) {
696
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
697
- return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
698
- return
699
- }
700
- }
701
- }
702
- {
703
- const variants_ = _1;
704
- const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
705
- return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
706
- }));
707
- const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
708
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
709
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
710
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
711
- }));
712
- const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
713
- const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None()), ff_core_List.Empty()), intType_, noEffect_);
714
- const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
715
- {
716
- const index_ = _1.first_;
717
- const variant_ = _1.second_;
718
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
719
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.EInt(at_, ("" + index_)))
720
- return
721
- }
722
- }));
723
- const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EFunctions(at_, ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_))), ff_core_List.Empty()), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
724
- return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
725
- return
726
- }
727
- }
728
- }
729
-
730
- export async function Deriver_makeOrderingFields$(self_, modulePrefix_, declaration_, fields_, $task) {
731
- const at_ = (((_c) => {
732
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
733
- }))(declaration_.at_);
734
- const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty());
735
- const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None());
736
- function go_(fields_) {
737
- {
738
- const fields_a = fields_;
739
- {
740
- if(fields_a.Empty) {
741
- return orderingSame_
742
- return
743
- }
744
- }
745
- {
746
- if(fields_a.Link) {
747
- const head_ = fields_a.head_;
748
- const tail_ = fields_a.tail_;
749
- const variableName_ = (head_.name_ + "Ordering");
750
- const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
751
- const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, variableName_), ff_core_List.Link(orderingSame_, ff_core_List.Empty())), ff_core_List.Empty());
752
- const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
753
- return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
754
- return
755
- }
756
- }
757
- }
758
- }
759
- return go_(fields_)
760
- }
761
-
762
- export async function Deriver_makeEqualInstances$(self_, modulePrefix_, module_, $task) {
763
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/List.List", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Empty())))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
764
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
765
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
766
- return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
767
- }))
768
- }
769
-
770
- export async function Deriver_makeEqualInstance$(self_, modulePrefix_, declaration_, $task) {
771
- const at_ = (((_c) => {
772
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
773
- }))(declaration_.at_);
774
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
775
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
776
- }));
777
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
778
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
779
- }));
780
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
781
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
782
- const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", ff_core_List.Empty()), noEffect_);
783
- const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
784
- const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
785
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(equalsMethod_, ff_core_List.Empty()), true)
786
- }
787
-
788
- export async function Deriver_makeEqualsCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
789
- const at_ = (((_c) => {
790
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
791
- }))(declaration_.at_);
792
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
793
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
794
- const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None()));
795
- {
796
- const _1 = declaration_.variants_;
797
- {
798
- if(_1.Link) {
799
- const variant_ = _1.head_;
800
- if(_1.tail_.Empty) {
801
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
802
- return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
803
- return
804
- }
805
- }
806
- }
807
- {
808
- const variants_ = _1;
809
- const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
810
- return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
811
- }));
812
- const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
813
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
814
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
815
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
816
- }));
817
- const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", ff_core_List.Empty(), ff_core_Option.None()));
818
- return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
819
- return
820
- }
821
- }
822
- }
823
-
824
- export async function Deriver_makeEqualFields$(self_, modulePrefix_, declaration_, fields_, $task) {
825
- const at_ = (((_c) => {
826
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
827
- }))(declaration_.at_);
828
- function go_(fields_) {
829
- {
830
- const fields_a = fields_;
831
- {
832
- if(fields_a.Empty) {
833
- return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None())
834
- return
835
- }
836
- }
837
- {
838
- if(fields_a.Link) {
839
- const head_ = fields_a.head_;
840
- if(fields_a.tail_.Empty) {
841
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty())
842
- return
843
- }
844
- }
845
- }
846
- {
847
- if(fields_a.Link) {
848
- const head_ = fields_a.head_;
849
- const tail_ = fields_a.tail_;
850
- const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
851
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", ff_core_List.Link(equalsTerm_, ff_core_List.Link(go_(tail_), ff_core_List.Empty())), ff_core_List.Empty())
852
- return
853
- }
854
- }
855
- }
856
- }
857
- return go_(fields_)
858
- }
859
-
860
- export async function Deriver_makeSerializableInstances$(self_, modulePrefix_, module_, $task) {
861
- const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Empty())), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
862
- const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
863
- return ff_core_List.List_map(missingInstance_, ((_w1) => {
864
- return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
865
- }))
866
- }
867
-
868
- export async function Deriver_makeSerializableInstance$(self_, modulePrefix_, declaration_, $task) {
869
- const at_ = (((_c) => {
870
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
871
- }))(declaration_.at_);
872
- const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
873
- return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
874
- }));
875
- const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
876
- return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
877
- }));
878
- const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
879
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
880
- const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", ff_core_List.Empty());
881
- const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", ff_core_List.Empty()), noEffect_);
882
- const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Empty()), selfType_, noEffect_);
883
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
884
- const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
885
- const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_)), ff_core_List.Empty())));
886
- return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_), ff_core_List.Empty())), true)
887
- }
888
-
889
- export async function Deriver_makeSerializeBody$(self_, modulePrefix_, declaration_, selfType_, $task) {
890
- const at_ = (((_c) => {
891
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
892
- }))(declaration_.at_);
893
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
894
- return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
895
- {
896
- const index_ = _1.first_;
897
- const variant_ = _1.second_;
898
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
899
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
900
- const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
901
- const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + index_)), ff_core_List.Empty())));
902
- const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
903
- return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_), ff_core_List.Empty())), ff_core_List.Empty())
904
- }));
905
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v")), ff_core_List.Empty())), ff_core_List.Empty(), ff_core_List.List_foldLeft(ff_core_List.Link(setVariantIndex_, ff_core_List.Link(ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), fieldSerializations_)), updateChecksum_, ((_w1, _w2) => {
906
- return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
907
- })))
908
- return
909
- }
910
- }))
911
- }
912
-
913
- export async function Deriver_makeDeserializeBody$(self_, modulePrefix_, declaration_, selfType_, $task) {
914
- const at_ = (((_c) => {
915
- return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
916
- }))(declaration_.at_);
917
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
918
- const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
919
- const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Empty()));
920
- const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
921
- const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
922
- const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
923
- {
924
- const index_ = _1.first_;
925
- const variant_ = _1.second_;
926
- const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
927
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
928
- const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
929
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Empty()), ff_core_List.Empty()))
930
- }));
931
- const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
932
- const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, ff_core_List.Empty(), ff_core_Option.Some(fieldValues_));
933
- return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PInt(at_, ("" + index_)), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
934
- return
935
- }
936
- }));
937
- const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", ff_core_List.Link(ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", ff_core_List.Empty(), ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty()));
938
- const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.List_addAll(cases_, ff_core_List.Link(otherwiseCase_, ff_core_List.Empty()))));
939
- const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
940
- return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
941
- }
942
-
943
- export async function Deriver_makeUpdateChecksum$(self_, at_, variantName_, declaration_, variant_, $task) {
944
- const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
945
- const variantChecksum_ = ff_core_String.String_size(variantName_);
946
- 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_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "31"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum"), ff_core_List.Empty())), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_)), ff_core_List.Empty())), ff_core_List.Empty()), "bitOr", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "0"), ff_core_List.Empty())))
947
- }
948
-
949
- export async function Deriver_findTypesThatNeedInstances$(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_, $task) {
950
- const typesWithInstance_ = ff_core_List.List_toSet(ff_core_List.List_collect(module_.instances_, ((_1) => {
951
- {
952
- const instance_ = _1;
953
- const _guard1 = ff_core_List.List_first(instance_.typeArguments_);
954
- if(_guard1.Some) {
955
- if(_guard1.value_.TConstructor) {
956
- const name_ = _guard1.value_.name_;
957
- if((instance_.traitName_ === traitName_)) {
958
- return ff_core_Option.Some(name_)
959
- } else return ff_core_Option.None()
960
- return
961
- }
962
- }
963
- }
964
- {
965
- return ff_core_Option.None()
966
- return
967
- }
968
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
969
- return ff_core_List.List_filter(module_.types_, ((t_) => {
970
- return (((((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") !== "ff:core") || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
971
- return (_w1 === "Q$")
972
- })))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
973
- }))
974
- }
975
-
976
- export async function Deriver_makeSimpleCall$(self_, at_, name_, arguments_, typeArguments_ = ff_core_List.Empty(), $task) {
977
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
978
- const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
979
- return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
980
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
981
- })), ff_core_List.Empty())
982
- }
983
-
984
- export async function Deriver_makeMethodCall$(self_, at_, target_, methodName_, arguments_, $task) {
985
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
986
- const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
987
- return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, ff_core_List.Empty(), ff_core_List.List_map(arguments_, ((_w1) => {
988
- return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
989
- })), ff_core_List.Empty())
990
- }
991
-
992
- export async function Deriver_makeIf$(self_, at_, condition_, then_, else_, $task) {
993
- const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
994
- const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
995
- const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), then_), ff_core_List.Empty())))), ff_core_List.Empty())), ff_core_List.Empty());
996
- return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), else_), ff_core_List.Empty())))), ff_core_List.Empty()), ff_core_List.Empty())
997
- }
998
-
999
- export const ff_core_Any_HasAnyTag$ff_compiler_Deriver_Deriver = {
1000
- anyTag_() {
1001
- return ff_core_Any.internalAnyTag_((("ff:compiler/Deriver.Deriver" + "[") + "]"))
1002
- },
1003
- async anyTag_$($task) {
1004
- return ff_core_Any.internalAnyTag_((("ff:compiler/Deriver.Deriver" + "[") + "]"))
1005
- }
1006
- };
1007
-
1008
- export const ff_core_Show_Show$ff_compiler_Deriver_Deriver = {
1009
- show_(value_) {
1010
- {
1011
- const value_a = value_;
1012
- {
1013
- const z_ = value_a;
1014
- return "Deriver"
1015
- return
1016
- }
1017
- }
1018
- },
1019
- async show_$(value_, $task) {
1020
- {
1021
- const value_a = value_;
1022
- {
1023
- const z_ = value_a;
1024
- return "Deriver"
1025
- return
1026
- }
1027
- }
1028
- }
1029
- };
1030
-
1031
- export const ff_core_Equal_Equal$ff_compiler_Deriver_Deriver = {
1032
- equals_(x_, y_) {
1033
- {
1034
- const x_a = x_;
1035
- const y_a = y_;
1036
- {
1037
- const _guard1 = (x_ === y_);
1038
- if(_guard1) {
1039
- return true
1040
- return
1041
- }
1042
- }
1043
- {
1044
- return true
1045
- return
1046
- }
1047
- }
1048
- },
1049
- async equals_$(x_, y_, $task) {
1050
- {
1051
- const x_a = x_;
1052
- const y_a = y_;
1053
- {
1054
- const _guard1 = (x_ === y_);
1055
- if(_guard1) {
1056
- return true
1057
- return
1058
- }
1059
- }
1060
- {
1061
- return true
1062
- return
1063
- }
1064
- }
1065
- }
1066
- };
1067
-
1068
- export const ff_core_Ordering_Order$ff_compiler_Deriver_Deriver = {
1069
- compare_(x_, y_) {
1070
- {
1071
- const x_a = x_;
1072
- const y_a = y_;
1073
- {
1074
- const _guard1 = (x_ === y_);
1075
- if(_guard1) {
1076
- return ff_core_Ordering.OrderingSame()
1077
- return
1078
- }
1079
- }
1080
- {
1081
- return ff_core_Ordering.OrderingSame()
1082
- return
1083
- }
1084
- }
1085
- },
1086
- async compare_$(x_, y_, $task) {
1087
- {
1088
- const x_a = x_;
1089
- const y_a = y_;
1090
- {
1091
- const _guard1 = (x_ === y_);
1092
- if(_guard1) {
1093
- return ff_core_Ordering.OrderingSame()
1094
- return
1095
- }
1096
- }
1097
- {
1098
- return ff_core_Ordering.OrderingSame()
1099
- return
1100
- }
1101
- }
1102
- }
1103
- };
1104
-
1105
- export const ff_core_Serializable_Serializable$ff_compiler_Deriver_Deriver = {
1106
- serializeUsing_(serialization_, value_) {
1107
- {
1108
- const serialization_a = serialization_;
1109
- const value_a = value_;
1110
- {
1111
- const v_ = value_a;
1112
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1113
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1114
- serialization_.offset_ += 1
1115
- return
1116
- }
1117
- }
1118
- },
1119
- deserializeUsing_(serialization_) {
1120
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1121
- serialization_.offset_ += 1;
1122
- {
1123
- const _1 = variantIndex_;
1124
- {
1125
- if(_1 == 0) {
1126
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1127
- return ff_compiler_Deriver.Deriver()
1128
- return
1129
- }
1130
- }
1131
- {
1132
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1133
- return
1134
- }
1135
- }
1136
- },
1137
- async serializeUsing_$(serialization_, value_, $task) {
1138
- {
1139
- const serialization_a = serialization_;
1140
- const value_a = value_;
1141
- {
1142
- const v_ = value_a;
1143
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1144
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1145
- serialization_.offset_ += 1
1146
- return
1147
- }
1148
- }
1149
- },
1150
- async deserializeUsing_$(serialization_, $task) {
1151
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1152
- serialization_.offset_ += 1;
1153
- {
1154
- const _1 = variantIndex_;
1155
- {
1156
- if(_1 == 0) {
1157
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1158
- return ff_compiler_Deriver.Deriver()
1159
- return
1160
- }
1161
- }
1162
- {
1163
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1164
- return
1165
- }
1166
- }
1167
- }
1168
- };
1169
-
1170
-
1
+
2
+
3
+ import * as ff_compiler_Deriver from "../../ff/compiler/Deriver.mjs"
4
+
5
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
6
+
7
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
8
+
9
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
10
+
11
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
12
+
13
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
14
+
15
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
16
+
17
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
18
+
19
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
20
+
21
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
22
+
23
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
24
+
25
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
26
+
27
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
28
+
29
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
30
+
31
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
32
+
33
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
34
+
35
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
36
+
37
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
38
+
39
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
40
+
41
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
42
+
43
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
44
+
45
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
46
+
47
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
48
+
49
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
50
+
51
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
52
+
53
+ import * as ff_core_List from "../../ff/core/List.mjs"
54
+
55
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
56
+
57
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
58
+
59
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
60
+
61
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
62
+
63
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
64
+
65
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
66
+
67
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
68
+
69
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
70
+
71
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
72
+
73
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
74
+
75
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
76
+
77
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
78
+
79
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
80
+
81
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
82
+
83
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
84
+
85
+ import * as ff_core_String from "../../ff/core/String.mjs"
86
+
87
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
88
+
89
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
90
+
91
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
92
+
93
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
94
+
95
+ // type Deriver
96
+ const Deriver$ = {Deriver: true};
97
+ export function Deriver() {
98
+ return Deriver$;
99
+ }
100
+
101
+
102
+
103
+ export function make_() {
104
+ return ff_compiler_Deriver.Deriver()
105
+ }
106
+
107
+ export function fail_(at_, message_) {
108
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
109
+ }
110
+
111
+ export async function make_$($task) {
112
+ return ff_compiler_Deriver.Deriver()
113
+ }
114
+
115
+ export async function fail_$(at_, message_, $task) {
116
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
117
+ }
118
+
119
+ export function Deriver_deriveModule(self_, module_) {
120
+ const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3));
121
+ {
122
+ const _1 = module_;
123
+ {
124
+ const _c = _1;
125
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, ff_core_List.List_addAll(module_.instances_, ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)))))), _c.extends_, _c.lets_, _c.functions_)
126
+ return
127
+ }
128
+ }
129
+ }
130
+
131
+ export function Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_) {
132
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Serializable.DeserializationChecksumException", ff_core_List.Link("ff:core/Core.GrabException", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Int.Int", ff_core_List.Link("ff:core/Float.Float", ff_core_List.Link("ff:core/String.String", ff_core_List.Link("ff:core/Char.Char", ff_core_List.Link("ff:core/Bool.Bool", ff_core_List.Link("ff:core/List.List", ff_core_List.Empty()))))))))))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
133
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
134
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
135
+ return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
136
+ }))
137
+ }
138
+
139
+ export function Deriver_makeHasAnyTagInstance(self_, modulePrefix_, declaration_) {
140
+ const at_ = (((_c) => {
141
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
142
+ }))(declaration_.at_);
143
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
144
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
145
+ }));
146
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
147
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
148
+ }));
149
+ const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
150
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
151
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
152
+ const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty())), noEffect_);
153
+ const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
154
+ return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", ff_core_List.Empty(), ff_core_List.Link(_w1, ff_core_List.Empty())), "show", ff_core_List.Empty())
155
+ }));
156
+ const strings_ = ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"[\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(typeArgumentStrings_, ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\",\""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"]\""), ff_core_List.Empty())));
157
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", ff_core_List.Link(ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
158
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
159
+ })), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
160
+ const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
161
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(method_, ff_core_List.Empty()), true)
162
+ }
163
+
164
+ export function Deriver_makeShowInstances(self_, modulePrefix_, module_) {
165
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
166
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
167
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
168
+ return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
169
+ }))
170
+ }
171
+
172
+ export function Deriver_makeShowInstance(self_, modulePrefix_, declaration_) {
173
+ const at_ = (((_c) => {
174
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
175
+ }))(declaration_.at_);
176
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
177
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
178
+ }));
179
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
180
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
181
+ }));
182
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
183
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
184
+ const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty()), ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", ff_core_List.Empty()), noEffect_);
185
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
186
+ const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
187
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(showMethod_, ff_core_List.Empty()), true)
188
+ }
189
+
190
+ export function Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_) {
191
+ const at_ = (((_c) => {
192
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
193
+ }))(declaration_.at_);
194
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
195
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
196
+ {
197
+ const _1 = declaration_.variants_;
198
+ {
199
+ const variants_ = _1;
200
+ return ff_core_List.List_map(variants_, ((variant_) => {
201
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
202
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
203
+ const strings_ = ((ff_core_List.List_size(fields_) === 0)
204
+ ? ff_core_List.Empty()
205
+ : ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"(\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(ff_core_List.List_map(fields_, ((field_) => {
206
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_), ff_core_List.Empty()), ff_core_List.Empty())
207
+ })), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\", \""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\")\""), ff_core_List.Empty()))));
208
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z")), ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
209
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
210
+ })))
211
+ }))
212
+ return
213
+ }
214
+ }
215
+ }
216
+
217
+ export function Deriver_makeOrderingInstances(self_, modulePrefix_, module_) {
218
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
219
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
220
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
221
+ return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
222
+ }))
223
+ }
224
+
225
+ export function Deriver_makeOrderingInstance(self_, modulePrefix_, declaration_) {
226
+ const at_ = (((_c) => {
227
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
228
+ }))(declaration_.at_);
229
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
230
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
231
+ }));
232
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
233
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
234
+ }));
235
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
236
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
237
+ const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty()), noEffect_);
238
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
239
+ const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
240
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(compareMethod_, ff_core_List.Empty()), true)
241
+ }
242
+
243
+ export function Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_) {
244
+ const at_ = (((_c) => {
245
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
246
+ }))(declaration_.at_);
247
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
248
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
249
+ const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None()));
250
+ {
251
+ const _1 = declaration_.variants_;
252
+ {
253
+ if(_1.Link) {
254
+ const variant_ = _1.head_;
255
+ if(_1.tail_.Empty) {
256
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
257
+ return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
258
+ return
259
+ }
260
+ }
261
+ }
262
+ {
263
+ const variants_ = _1;
264
+ const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
265
+ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
266
+ }));
267
+ const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
268
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
269
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
270
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
271
+ }));
272
+ const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
273
+ const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None()), ff_core_List.Empty()), intType_, noEffect_);
274
+ const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
275
+ {
276
+ const index_ = _1.first_;
277
+ const variant_ = _1.second_;
278
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
279
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.EInt(at_, ("" + index_)))
280
+ return
281
+ }
282
+ }));
283
+ const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EFunctions(at_, ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_))), ff_core_List.Empty()), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
284
+ return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
285
+ return
286
+ }
287
+ }
288
+ }
289
+
290
+ export function Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_) {
291
+ const at_ = (((_c) => {
292
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
293
+ }))(declaration_.at_);
294
+ const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty());
295
+ const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None());
296
+ function go_(fields_) {
297
+ {
298
+ const fields_a = fields_;
299
+ {
300
+ if(fields_a.Empty) {
301
+ return orderingSame_
302
+ return
303
+ }
304
+ }
305
+ {
306
+ if(fields_a.Link) {
307
+ const head_ = fields_a.head_;
308
+ const tail_ = fields_a.tail_;
309
+ const variableName_ = (head_.name_ + "Ordering");
310
+ const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
311
+ const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, variableName_), ff_core_List.Link(orderingSame_, ff_core_List.Empty())), ff_core_List.Empty());
312
+ const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
313
+ return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
314
+ return
315
+ }
316
+ }
317
+ }
318
+ }
319
+ return go_(fields_)
320
+ }
321
+
322
+ export function Deriver_makeEqualInstances(self_, modulePrefix_, module_) {
323
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/List.List", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Empty())))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
324
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
325
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
326
+ return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
327
+ }))
328
+ }
329
+
330
+ export function Deriver_makeEqualInstance(self_, modulePrefix_, declaration_) {
331
+ const at_ = (((_c) => {
332
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
333
+ }))(declaration_.at_);
334
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
335
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
336
+ }));
337
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
338
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
339
+ }));
340
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
341
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
342
+ const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", ff_core_List.Empty()), noEffect_);
343
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
344
+ const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
345
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(equalsMethod_, ff_core_List.Empty()), true)
346
+ }
347
+
348
+ export function Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_) {
349
+ const at_ = (((_c) => {
350
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
351
+ }))(declaration_.at_);
352
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
353
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
354
+ const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None()));
355
+ {
356
+ const _1 = declaration_.variants_;
357
+ {
358
+ if(_1.Link) {
359
+ const variant_ = _1.head_;
360
+ if(_1.tail_.Empty) {
361
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
362
+ return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
363
+ return
364
+ }
365
+ }
366
+ }
367
+ {
368
+ const variants_ = _1;
369
+ const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
370
+ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
371
+ }));
372
+ const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
373
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
374
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
375
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
376
+ }));
377
+ const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", ff_core_List.Empty(), ff_core_Option.None()));
378
+ return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
379
+ return
380
+ }
381
+ }
382
+ }
383
+
384
+ export function Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_) {
385
+ const at_ = (((_c) => {
386
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
387
+ }))(declaration_.at_);
388
+ function go_(fields_) {
389
+ {
390
+ const fields_a = fields_;
391
+ {
392
+ if(fields_a.Empty) {
393
+ return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None())
394
+ return
395
+ }
396
+ }
397
+ {
398
+ if(fields_a.Link) {
399
+ const head_ = fields_a.head_;
400
+ if(fields_a.tail_.Empty) {
401
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty())
402
+ return
403
+ }
404
+ }
405
+ }
406
+ {
407
+ if(fields_a.Link) {
408
+ const head_ = fields_a.head_;
409
+ const tail_ = fields_a.tail_;
410
+ const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
411
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", ff_core_List.Link(equalsTerm_, ff_core_List.Link(go_(tail_), ff_core_List.Empty())), ff_core_List.Empty())
412
+ return
413
+ }
414
+ }
415
+ }
416
+ }
417
+ return go_(fields_)
418
+ }
419
+
420
+ export function Deriver_makeSerializableInstances(self_, modulePrefix_, module_) {
421
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Empty())), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
422
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
423
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
424
+ return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
425
+ }))
426
+ }
427
+
428
+ export function Deriver_makeSerializableInstance(self_, modulePrefix_, declaration_) {
429
+ const at_ = (((_c) => {
430
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
431
+ }))(declaration_.at_);
432
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
433
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
434
+ }));
435
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
436
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
437
+ }));
438
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
439
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
440
+ const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", ff_core_List.Empty());
441
+ const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", ff_core_List.Empty()), noEffect_);
442
+ const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Empty()), selfType_, noEffect_);
443
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
444
+ const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
445
+ const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_)), ff_core_List.Empty())));
446
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_), ff_core_List.Empty())), true)
447
+ }
448
+
449
+ export function Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_) {
450
+ const at_ = (((_c) => {
451
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
452
+ }))(declaration_.at_);
453
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
454
+ return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
455
+ {
456
+ const index_ = _1.first_;
457
+ const variant_ = _1.second_;
458
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
459
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
460
+ const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
461
+ const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + index_)), ff_core_List.Empty())));
462
+ const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
463
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_), ff_core_List.Empty())), ff_core_List.Empty())
464
+ }));
465
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v")), ff_core_List.Empty())), ff_core_List.Empty(), ff_core_List.List_foldLeft(ff_core_List.Link(setVariantIndex_, ff_core_List.Link(ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), fieldSerializations_)), updateChecksum_, ((_w1, _w2) => {
466
+ return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
467
+ })))
468
+ return
469
+ }
470
+ }))
471
+ }
472
+
473
+ export function Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_) {
474
+ const at_ = (((_c) => {
475
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
476
+ }))(declaration_.at_);
477
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
478
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
479
+ const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Empty()));
480
+ const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
481
+ const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
482
+ const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
483
+ {
484
+ const index_ = _1.first_;
485
+ const variant_ = _1.second_;
486
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
487
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
488
+ const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
489
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Empty()), ff_core_List.Empty()))
490
+ }));
491
+ const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
492
+ const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, ff_core_List.Empty(), ff_core_Option.Some(fieldValues_));
493
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PInt(at_, ("" + index_)), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
494
+ return
495
+ }
496
+ }));
497
+ const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", ff_core_List.Link(ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", ff_core_List.Empty(), ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty()));
498
+ const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.List_addAll(cases_, ff_core_List.Link(otherwiseCase_, ff_core_List.Empty()))));
499
+ const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
500
+ return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
501
+ }
502
+
503
+ export function Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_) {
504
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
505
+ const variantChecksum_ = ff_core_String.String_size(variantName_);
506
+ 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_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "31"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum"), ff_core_List.Empty())), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_)), ff_core_List.Empty())), ff_core_List.Empty()), "bitOr", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "0"), ff_core_List.Empty())))
507
+ }
508
+
509
+ export function Deriver_findTypesThatNeedInstances(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_) {
510
+ const typesWithInstance_ = ff_core_List.List_toSet(ff_core_List.List_collect(module_.instances_, ((_1) => {
511
+ {
512
+ const instance_ = _1;
513
+ const _guard1 = ff_core_List.List_first(instance_.typeArguments_);
514
+ if(_guard1.Some) {
515
+ if(_guard1.value_.TConstructor) {
516
+ const name_ = _guard1.value_.name_;
517
+ if((instance_.traitName_ === traitName_)) {
518
+ return ff_core_Option.Some(name_)
519
+ } else return ff_core_Option.None()
520
+ return
521
+ }
522
+ }
523
+ }
524
+ {
525
+ return ff_core_Option.None()
526
+ return
527
+ }
528
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
529
+ return ff_core_List.List_filter(module_.types_, ((t_) => {
530
+ return (((((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") !== "ff:core") || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
531
+ return (_w1 === "Q$")
532
+ })))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
533
+ }))
534
+ }
535
+
536
+ export function Deriver_makeSimpleCall(self_, at_, name_, arguments_, typeArguments_ = ff_core_List.Empty()) {
537
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
538
+ const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
539
+ return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
540
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
541
+ })), ff_core_List.Empty())
542
+ }
543
+
544
+ export function Deriver_makeMethodCall(self_, at_, target_, methodName_, arguments_) {
545
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
546
+ const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
547
+ return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, ff_core_List.Empty(), ff_core_List.List_map(arguments_, ((_w1) => {
548
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
549
+ })), ff_core_List.Empty())
550
+ }
551
+
552
+ export function Deriver_makeIf(self_, at_, condition_, then_, else_) {
553
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
554
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
555
+ const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), then_), ff_core_List.Empty())))), ff_core_List.Empty())), ff_core_List.Empty());
556
+ return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), else_), ff_core_List.Empty())))), ff_core_List.Empty()), ff_core_List.Empty())
557
+ }
558
+
559
+ export async function Deriver_deriveModule$(self_, module_, $task) {
560
+ const modulePrefix_ = ((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3));
561
+ {
562
+ const _1 = module_;
563
+ {
564
+ const _c = _1;
565
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, ff_core_List.List_addAll(module_.instances_, ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ff_core_List.List_addAll(ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)))))), _c.extends_, _c.lets_, _c.functions_)
566
+ return
567
+ }
568
+ }
569
+ }
570
+
571
+ export async function Deriver_makeHasAnyTagInstances$(self_, modulePrefix_, module_, $task) {
572
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Serializable.DeserializationChecksumException", ff_core_List.Link("ff:core/Core.GrabException", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Int.Int", ff_core_List.Link("ff:core/Float.Float", ff_core_List.Link("ff:core/String.String", ff_core_List.Link("ff:core/Char.Char", ff_core_List.Link("ff:core/Bool.Bool", ff_core_List.Link("ff:core/List.List", ff_core_List.Empty()))))))))))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
573
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Any.HasAnyTag", modulePrefix_, coreWhitelist_, true, module_);
574
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
575
+ return ff_compiler_Deriver.Deriver_makeHasAnyTagInstance(self_, modulePrefix_, _w1)
576
+ }))
577
+ }
578
+
579
+ export async function Deriver_makeHasAnyTagInstance$(self_, modulePrefix_, declaration_, $task) {
580
+ const at_ = (((_c) => {
581
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
582
+ }))(declaration_.at_);
583
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
584
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Any.HasAnyTag", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
585
+ }));
586
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
587
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
588
+ }));
589
+ const selfTypeName_ = ((modulePrefix_ + ".") + declaration_.name_);
590
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, selfTypeName_, typeArguments_);
591
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
592
+ const signature_ = ff_compiler_Syntax.Signature(at_, "anyTag", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.TConstructor(at_, "ff:core/Any.AnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty())), noEffect_);
593
+ const typeArgumentStrings_ = ff_core_List.List_map(typeArguments_, ((_w1) => {
594
+ return ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.anyTag", ff_core_List.Empty(), ff_core_List.Link(_w1, ff_core_List.Empty())), "show", ff_core_List.Empty())
595
+ }));
596
+ const strings_ = ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"[\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(typeArgumentStrings_, ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\",\""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"]\""), ff_core_List.Empty())));
597
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Any.internalAnyTag", ff_core_List.Link(ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + selfTypeName_) + "\"")), ((a_, b_) => {
598
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
599
+ })), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
600
+ const method_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
601
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Any.HasAnyTag", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(method_, ff_core_List.Empty()), true)
602
+ }
603
+
604
+ export async function Deriver_makeShowInstances$(self_, modulePrefix_, module_, $task) {
605
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
606
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Show.Show", modulePrefix_, coreWhitelist_, true, module_);
607
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
608
+ return ff_compiler_Deriver.Deriver_makeShowInstance(self_, modulePrefix_, _w1)
609
+ }))
610
+ }
611
+
612
+ export async function Deriver_makeShowInstance$(self_, modulePrefix_, declaration_, $task) {
613
+ const at_ = (((_c) => {
614
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
615
+ }))(declaration_.at_);
616
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
617
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Show.Show", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
618
+ }));
619
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
620
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
621
+ }));
622
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
623
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
624
+ const signature_ = ff_compiler_Syntax.Signature(at_, "show", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty()), ff_compiler_Syntax.TConstructor(at_, "ff:core/String.String", ff_core_List.Empty()), noEffect_);
625
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeShowCases(self_, modulePrefix_, declaration_, selfType_)));
626
+ const showMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
627
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Show.Show", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(showMethod_, ff_core_List.Empty()), true)
628
+ }
629
+
630
+ export async function Deriver_makeShowCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
631
+ const at_ = (((_c) => {
632
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
633
+ }))(declaration_.at_);
634
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
635
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
636
+ {
637
+ const _1 = declaration_.variants_;
638
+ {
639
+ const variants_ = _1;
640
+ return ff_core_List.List_map(variants_, ((variant_) => {
641
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
642
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
643
+ const strings_ = ((ff_core_List.List_size(fields_) === 0)
644
+ ? ff_core_List.Empty()
645
+ : ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\"(\""), ff_core_List.List_addAll(ff_core_List.List_insertBetween(ff_core_List.List_map(fields_, ((field_) => {
646
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Show.show", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "z"), field_.name_), ff_core_List.Empty()), ff_core_List.Empty())
647
+ })), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\", \""), ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.EString(at_, "\")\""), ff_core_List.Empty()))));
648
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("z")), ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.List_foldLeft(strings_, ff_compiler_Syntax.EString(at_, (("\"" + variant_.name_) + "\"")), ((a_, b_) => {
649
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "+", ff_core_List.Link(a_, ff_core_List.Link(b_, ff_core_List.Empty())), ff_core_List.Empty())
650
+ })))
651
+ }))
652
+ return
653
+ }
654
+ }
655
+ }
656
+
657
+ export async function Deriver_makeOrderingInstances$(self_, modulePrefix_, module_, $task) {
658
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
659
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Ordering.Order", modulePrefix_, coreWhitelist_, true, module_);
660
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
661
+ return ff_compiler_Deriver.Deriver_makeOrderingInstance(self_, modulePrefix_, _w1)
662
+ }))
663
+ }
664
+
665
+ export async function Deriver_makeOrderingInstance$(self_, modulePrefix_, declaration_, $task) {
666
+ const at_ = (((_c) => {
667
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
668
+ }))(declaration_.at_);
669
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
670
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Ordering.Order", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
671
+ }));
672
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
673
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
674
+ }));
675
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
676
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
677
+ const signature_ = ff_compiler_Syntax.Signature(at_, "compare", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty()), noEffect_);
678
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeOrderingCases(self_, modulePrefix_, declaration_, selfType_)));
679
+ const compareMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
680
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Ordering.Order", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(compareMethod_, ff_core_List.Empty()), true)
681
+ }
682
+
683
+ export async function Deriver_makeOrderingCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
684
+ const at_ = (((_c) => {
685
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
686
+ }))(declaration_.at_);
687
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
688
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
689
+ const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None()));
690
+ {
691
+ const _1 = declaration_.variants_;
692
+ {
693
+ if(_1.Link) {
694
+ const variant_ = _1.head_;
695
+ if(_1.tail_.Empty) {
696
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
697
+ return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
698
+ return
699
+ }
700
+ }
701
+ }
702
+ {
703
+ const variants_ = _1;
704
+ const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
705
+ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
706
+ }));
707
+ const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
708
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
709
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
710
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeOrderingFields(self_, modulePrefix_, declaration_, fields_))
711
+ }));
712
+ const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
713
+ const numberSignature_ = ff_compiler_Syntax.Signature(at_, "number", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "z", selfType_, ff_core_Option.None()), ff_core_List.Empty()), intType_, noEffect_);
714
+ const numberCases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
715
+ {
716
+ const index_ = _1.first_;
717
+ const variant_ = _1.second_;
718
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
719
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.EInt(at_, ("" + index_)))
720
+ return
721
+ }
722
+ }));
723
+ const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EFunctions(at_, ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, numberSignature_, ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, numberCases_))), ff_core_List.Empty()), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "number", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty()), ff_core_List.Empty()), ff_core_List.Empty())), ff_core_List.Empty())));
724
+ return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
725
+ return
726
+ }
727
+ }
728
+ }
729
+
730
+ export async function Deriver_makeOrderingFields$(self_, modulePrefix_, declaration_, fields_, $task) {
731
+ const at_ = (((_c) => {
732
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
733
+ }))(declaration_.at_);
734
+ const orderingType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Ordering.Ordering", ff_core_List.Empty());
735
+ const orderingSame_ = ff_compiler_Syntax.EVariant(at_, "ff:core/Ordering.OrderingSame", ff_core_List.Empty(), ff_core_Option.None());
736
+ function go_(fields_) {
737
+ {
738
+ const fields_a = fields_;
739
+ {
740
+ if(fields_a.Empty) {
741
+ return orderingSame_
742
+ return
743
+ }
744
+ }
745
+ {
746
+ if(fields_a.Link) {
747
+ const head_ = fields_a.head_;
748
+ const tail_ = fields_a.tail_;
749
+ const variableName_ = (head_.name_ + "Ordering");
750
+ const compareTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Ordering.compare", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
751
+ const notEqualTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "!==", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, variableName_), ff_core_List.Link(orderingSame_, ff_core_List.Empty())), ff_core_List.Empty());
752
+ const ifTerm_ = ff_compiler_Deriver.Deriver_makeIf(self_, at_, notEqualTerm_, ff_compiler_Syntax.EVariable(at_, variableName_), go_(tail_));
753
+ return ff_compiler_Syntax.ELet(at_, false, variableName_, orderingType_, compareTerm_, ifTerm_)
754
+ return
755
+ }
756
+ }
757
+ }
758
+ }
759
+ return go_(fields_)
760
+ }
761
+
762
+ export async function Deriver_makeEqualInstances$(self_, modulePrefix_, module_, $task) {
763
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/List.List", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Link("ff:core/Unit.Unit", ff_core_List.Empty())))), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
764
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Equal.Equal", modulePrefix_, coreWhitelist_, true, module_);
765
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
766
+ return ff_compiler_Deriver.Deriver_makeEqualInstance(self_, modulePrefix_, _w1)
767
+ }))
768
+ }
769
+
770
+ export async function Deriver_makeEqualInstance$(self_, modulePrefix_, declaration_, $task) {
771
+ const at_ = (((_c) => {
772
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
773
+ }))(declaration_.at_);
774
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
775
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Equal.Equal", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
776
+ }));
777
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
778
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
779
+ }));
780
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
781
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
782
+ const signature_ = ff_compiler_Syntax.Signature(at_, "equals", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "x", selfType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "y", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Bool.Bool", ff_core_List.Empty()), noEffect_);
783
+ const body_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeEqualsCases(self_, modulePrefix_, declaration_, selfType_)));
784
+ const equalsMethod_ = ff_compiler_Syntax.DFunction(at_, signature_, body_);
785
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Equal.Equal", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(equalsMethod_, ff_core_List.Empty()), true)
786
+ }
787
+
788
+ export async function Deriver_makeEqualsCases$(self_, modulePrefix_, declaration_, selfType_, $task) {
789
+ const at_ = (((_c) => {
790
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
791
+ }))(declaration_.at_);
792
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
793
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
794
+ const sameCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Link(ff_compiler_Syntax.MatchGuard(at_, ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "===", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "x"), ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "y"), ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.PVariant(at_, "ff:core/Bool.True", ff_core_List.Empty())), ff_core_List.Empty()), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None()));
795
+ {
796
+ const _1 = declaration_.variants_;
797
+ {
798
+ if(_1.Link) {
799
+ const variant_ = _1.head_;
800
+ if(_1.tail_.Empty) {
801
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
802
+ return ff_core_List.Link(sameCase_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_)), ff_core_List.Empty()))
803
+ return
804
+ }
805
+ }
806
+ }
807
+ {
808
+ const variants_ = _1;
809
+ const variantsWithFields_ = ff_core_List.List_filter(variants_, ((variant_) => {
810
+ return ((!ff_core_List.List_isEmpty(declaration_.commonFields_)) || (!ff_core_List.List_isEmpty(variant_.fields_)))
811
+ }));
812
+ const sameVariantCases_ = ff_core_List.List_map(variantsWithFields_, ((variant_) => {
813
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
814
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
815
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("x")), ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("y")), ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeEqualFields(self_, modulePrefix_, declaration_, fields_))
816
+ }));
817
+ const differentVariant_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty())), ff_core_List.Empty(), ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.False", ff_core_List.Empty(), ff_core_Option.None()));
818
+ return ff_core_List.Link(sameCase_, ff_core_List.List_addAll(sameVariantCases_, ff_core_List.Link(differentVariant_, ff_core_List.Empty())))
819
+ return
820
+ }
821
+ }
822
+ }
823
+
824
+ export async function Deriver_makeEqualFields$(self_, modulePrefix_, declaration_, fields_, $task) {
825
+ const at_ = (((_c) => {
826
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
827
+ }))(declaration_.at_);
828
+ function go_(fields_) {
829
+ {
830
+ const fields_a = fields_;
831
+ {
832
+ if(fields_a.Empty) {
833
+ return ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True", ff_core_List.Empty(), ff_core_Option.None())
834
+ return
835
+ }
836
+ }
837
+ {
838
+ if(fields_a.Link) {
839
+ const head_ = fields_a.head_;
840
+ if(fields_a.tail_.Empty) {
841
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty())
842
+ return
843
+ }
844
+ }
845
+ }
846
+ {
847
+ if(fields_a.Link) {
848
+ const head_ = fields_a.head_;
849
+ const tail_ = fields_a.tail_;
850
+ const equalsTerm_ = ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Equal.equals", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "x"), head_.name_), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "y"), head_.name_), ff_core_List.Empty())), ff_core_List.Empty());
851
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "&&", ff_core_List.Link(equalsTerm_, ff_core_List.Link(go_(tail_), ff_core_List.Empty())), ff_core_List.Empty())
852
+ return
853
+ }
854
+ }
855
+ }
856
+ }
857
+ return go_(fields_)
858
+ }
859
+
860
+ export async function Deriver_makeSerializableInstances$(self_, modulePrefix_, module_, $task) {
861
+ const coreWhitelist_ = ff_core_List.List_toSet(ff_core_List.Link("ff:core/Option.Option", ff_core_List.Link("ff:core/Pair.Pair", ff_core_List.Empty())), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
862
+ const missingInstance_ = ff_compiler_Deriver.Deriver_findTypesThatNeedInstances(self_, "ff:core/Serializable.Serializable", modulePrefix_, coreWhitelist_, true, module_);
863
+ return ff_core_List.List_map(missingInstance_, ((_w1) => {
864
+ return ff_compiler_Deriver.Deriver_makeSerializableInstance(self_, modulePrefix_, _w1)
865
+ }))
866
+ }
867
+
868
+ export async function Deriver_makeSerializableInstance$(self_, modulePrefix_, declaration_, $task) {
869
+ const at_ = (((_c) => {
870
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
871
+ }))(declaration_.at_);
872
+ const constraints_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
873
+ return ff_compiler_Syntax.Constraint(at_, "ff:core/Serializable.Serializable", ff_core_List.Link(ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty()), ff_core_List.Empty()))
874
+ }));
875
+ const typeArguments_ = ff_core_List.List_map(declaration_.generics_, ((t_) => {
876
+ return ff_compiler_Syntax.TConstructor(at_, t_, ff_core_List.Empty())
877
+ }));
878
+ const selfType_ = ff_compiler_Syntax.TConstructor(at_, ((modulePrefix_ + ".") + declaration_.name_), typeArguments_);
879
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
880
+ const serializationType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Serializable.Serialization", ff_core_List.Empty());
881
+ const serializeSignature_ = ff_compiler_Syntax.Signature(at_, "serializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "value", selfType_, ff_core_Option.None()), ff_core_List.Empty())), ff_compiler_Syntax.TConstructor(at_, "ff:core/Unit.Unit", ff_core_List.Empty()), noEffect_);
882
+ const deserializeSignature_ = ff_compiler_Syntax.Signature(at_, "deserializeUsing", false, ff_core_List.Empty(), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Parameter(at_, false, "serialization", serializationType_, ff_core_Option.None()), ff_core_List.Empty()), selfType_, noEffect_);
883
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
884
+ const serializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_compiler_Deriver.Deriver_makeSerializeBody(self_, modulePrefix_, declaration_, selfType_)));
885
+ const deserializeBody_ = ff_compiler_Syntax.FireflyTarget(ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeDeserializeBody(self_, modulePrefix_, declaration_, selfType_)), ff_core_List.Empty())));
886
+ return ff_compiler_Syntax.DInstance(at_, declaration_.generics_, constraints_, "ff:core/Serializable.Serializable", ff_core_List.Link(selfType_, ff_core_List.Empty()), ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, serializeSignature_, serializeBody_), ff_core_List.Link(ff_compiler_Syntax.DFunction(at_, deserializeSignature_, deserializeBody_), ff_core_List.Empty())), true)
887
+ }
888
+
889
+ export async function Deriver_makeSerializeBody$(self_, modulePrefix_, declaration_, selfType_, $task) {
890
+ const at_ = (((_c) => {
891
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
892
+ }))(declaration_.at_);
893
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
894
+ return ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
895
+ {
896
+ const index_ = _1.first_;
897
+ const variant_ = _1.second_;
898
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
899
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
900
+ const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
901
+ const setVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "setUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + index_)), ff_core_List.Empty())));
902
+ const fieldSerializations_ = ff_core_List.List_map(fields_, ((field_) => {
903
+ return ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.serializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "v"), field_.name_), ff_core_List.Empty())), ff_core_List.Empty())
904
+ }));
905
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Link(ff_compiler_Syntax.PVariantAs(at_, variantName_, at_, ff_core_Option.Some("v")), ff_core_List.Empty())), ff_core_List.Empty(), ff_core_List.List_foldLeft(ff_core_List.Link(setVariantIndex_, ff_core_List.Link(ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1")), fieldSerializations_)), updateChecksum_, ((_w1, _w2) => {
906
+ return ff_compiler_Syntax.ESequential(at_, _w1, _w2)
907
+ })))
908
+ return
909
+ }
910
+ }))
911
+ }
912
+
913
+ export async function Deriver_makeDeserializeBody$(self_, modulePrefix_, declaration_, selfType_, $task) {
914
+ const at_ = (((_c) => {
915
+ return ff_compiler_Syntax.Location((declaration_.at_.file_ + "/<derived>"), _c.line_, _c.column_)
916
+ }))(declaration_.at_);
917
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
918
+ const wildcardPattern_ = ff_compiler_Syntax.PVariable(at_, ff_core_Option.None());
919
+ const grabVariantIndex_ = ff_compiler_Deriver.Deriver_makeMethodCall(self_, at_, ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "buffer"), "grabUint8", ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "offset"), ff_core_List.Empty()));
920
+ const intType_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Int.Int", ff_core_List.Empty());
921
+ const incrementOffset_ = ff_compiler_Syntax.EAssignField(at_, "+", ff_compiler_Syntax.EVariable(at_, "serialization"), "offset", ff_compiler_Syntax.EInt(at_, "1"));
922
+ const cases_ = ff_core_List.List_map(ff_core_List.List_pairs(declaration_.variants_), ((_1) => {
923
+ {
924
+ const index_ = _1.first_;
925
+ const variant_ = _1.second_;
926
+ const variantName_ = ((modulePrefix_ + ".") + variant_.name_);
927
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
928
+ const fieldValues_ = ff_core_List.List_map(fields_, ((field_) => {
929
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Serializable.deserializeUsing", ff_core_List.Link(ff_compiler_Syntax.EVariable(at_, "serialization"), ff_core_List.Empty()), ff_core_List.Empty()))
930
+ }));
931
+ const updateChecksum_ = ff_compiler_Deriver.Deriver_makeUpdateChecksum(self_, at_, variantName_, declaration_, variant_);
932
+ const makeVariant_ = ff_compiler_Syntax.EVariant(at_, variantName_, ff_core_List.Empty(), ff_core_Option.Some(fieldValues_));
933
+ return ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(ff_compiler_Syntax.PInt(at_, ("" + index_)), ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Syntax.ESequential(at_, updateChecksum_, makeVariant_))
934
+ return
935
+ }
936
+ }));
937
+ const otherwiseCase_ = ff_compiler_Syntax.MatchCase(at_, ff_core_List.Link(wildcardPattern_, ff_core_List.Empty()), ff_core_List.Empty(), ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "ff:core/Core.throw", ff_core_List.Link(ff_compiler_Syntax.EVariant(at_, "ff:core/Serializable.DeserializationChecksumException", ff_core_List.Empty(), ff_core_Option.None()), ff_core_List.Empty()), ff_core_List.Empty()));
938
+ const matchLambda_ = ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.List_addAll(cases_, ff_core_List.Link(otherwiseCase_, ff_core_List.Empty()))));
939
+ const match_ = ff_compiler_Syntax.EPipe(at_, ff_compiler_Syntax.EVariable(at_, "variantIndex"), noEffect_, matchLambda_);
940
+ return ff_compiler_Syntax.ELet(at_, false, "variantIndex", intType_, grabVariantIndex_, ff_compiler_Syntax.ESequential(at_, incrementOffset_, match_))
941
+ }
942
+
943
+ export async function Deriver_makeUpdateChecksum$(self_, at_, variantName_, declaration_, variant_, $task) {
944
+ const fields_ = ff_core_List.List_addAll(declaration_.commonFields_, variant_.fields_);
945
+ const variantChecksum_ = ff_core_String.String_size(variantName_);
946
+ 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_core_List.Link(ff_compiler_Deriver.Deriver_makeSimpleCall(self_, at_, "*", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "31"), ff_core_List.Link(ff_compiler_Syntax.EField(at_, false, ff_compiler_Syntax.EVariable(at_, "serialization"), "checksum"), ff_core_List.Empty())), ff_core_List.Empty()), ff_core_List.Link(ff_compiler_Syntax.EInt(at_, ("" + variantChecksum_)), ff_core_List.Empty())), ff_core_List.Empty()), "bitOr", ff_core_List.Link(ff_compiler_Syntax.EInt(at_, "0"), ff_core_List.Empty())))
947
+ }
948
+
949
+ export async function Deriver_findTypesThatNeedInstances$(self_, traitName_, modulePrefix_, coreWhitelist_, allowGenerics_, module_, $task) {
950
+ const typesWithInstance_ = ff_core_List.List_toSet(ff_core_List.List_collect(module_.instances_, ((_1) => {
951
+ {
952
+ const instance_ = _1;
953
+ const _guard1 = ff_core_List.List_first(instance_.typeArguments_);
954
+ if(_guard1.Some) {
955
+ if(_guard1.value_.TConstructor) {
956
+ const name_ = _guard1.value_.name_;
957
+ if((instance_.traitName_ === traitName_)) {
958
+ return ff_core_Option.Some(name_)
959
+ } else return ff_core_Option.None()
960
+ return
961
+ }
962
+ }
963
+ }
964
+ {
965
+ return ff_core_Option.None()
966
+ return
967
+ }
968
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
969
+ return ff_core_List.List_filter(module_.types_, ((t_) => {
970
+ return (((((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") !== "ff:core") || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
971
+ return (_w1 === "Q$")
972
+ })))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
973
+ }))
974
+ }
975
+
976
+ export async function Deriver_makeSimpleCall$(self_, at_, name_, arguments_, typeArguments_ = ff_core_List.Empty(), $task) {
977
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
978
+ const callTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, name_), false);
979
+ return ff_compiler_Syntax.ECall(at_, callTarget_, noEffect_, typeArguments_, ff_core_List.List_map(arguments_, ((e_) => {
980
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), e_)
981
+ })), ff_core_List.Empty())
982
+ }
983
+
984
+ export async function Deriver_makeMethodCall$(self_, at_, target_, methodName_, arguments_, $task) {
985
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
986
+ const method_ = ff_compiler_Syntax.EField(at_, false, target_, methodName_);
987
+ return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(method_, false), noEffect_, ff_core_List.Empty(), ff_core_List.List_map(arguments_, ((_w1) => {
988
+ return ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), _w1)
989
+ })), ff_core_List.Empty())
990
+ }
991
+
992
+ export async function Deriver_makeIf$(self_, at_, condition_, then_, else_, $task) {
993
+ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty());
994
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EVariable(at_, "ff:core/Core.if"), false);
995
+ const option_ = ff_compiler_Syntax.ECall(at_, target_, noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), condition_), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), then_), ff_core_List.Empty())))), ff_core_List.Empty())), ff_core_List.Empty());
996
+ return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(at_, false, option_, "else"), false), noEffect_, ff_core_List.Empty(), ff_core_List.Link(ff_compiler_Syntax.Argument(at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(at_, noEffect_, ff_core_List.Link(ff_compiler_Syntax.MatchCase(at_, ff_core_List.Empty(), ff_core_List.Empty(), else_), ff_core_List.Empty())))), ff_core_List.Empty()), ff_core_List.Empty())
997
+ }
998
+
999
+ export const ff_core_Any_HasAnyTag$ff_compiler_Deriver_Deriver = {
1000
+ anyTag_() {
1001
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Deriver.Deriver" + "[") + "]"))
1002
+ },
1003
+ async anyTag_$($task) {
1004
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Deriver.Deriver" + "[") + "]"))
1005
+ }
1006
+ };
1007
+
1008
+ export const ff_core_Show_Show$ff_compiler_Deriver_Deriver = {
1009
+ show_(value_) {
1010
+ {
1011
+ const value_a = value_;
1012
+ {
1013
+ const z_ = value_a;
1014
+ return "Deriver"
1015
+ return
1016
+ }
1017
+ }
1018
+ },
1019
+ async show_$(value_, $task) {
1020
+ {
1021
+ const value_a = value_;
1022
+ {
1023
+ const z_ = value_a;
1024
+ return "Deriver"
1025
+ return
1026
+ }
1027
+ }
1028
+ }
1029
+ };
1030
+
1031
+ export const ff_core_Equal_Equal$ff_compiler_Deriver_Deriver = {
1032
+ equals_(x_, y_) {
1033
+ {
1034
+ const x_a = x_;
1035
+ const y_a = y_;
1036
+ {
1037
+ const _guard1 = (x_ === y_);
1038
+ if(_guard1) {
1039
+ return true
1040
+ return
1041
+ }
1042
+ }
1043
+ {
1044
+ return true
1045
+ return
1046
+ }
1047
+ }
1048
+ },
1049
+ async equals_$(x_, y_, $task) {
1050
+ {
1051
+ const x_a = x_;
1052
+ const y_a = y_;
1053
+ {
1054
+ const _guard1 = (x_ === y_);
1055
+ if(_guard1) {
1056
+ return true
1057
+ return
1058
+ }
1059
+ }
1060
+ {
1061
+ return true
1062
+ return
1063
+ }
1064
+ }
1065
+ }
1066
+ };
1067
+
1068
+ export const ff_core_Ordering_Order$ff_compiler_Deriver_Deriver = {
1069
+ compare_(x_, y_) {
1070
+ {
1071
+ const x_a = x_;
1072
+ const y_a = y_;
1073
+ {
1074
+ const _guard1 = (x_ === y_);
1075
+ if(_guard1) {
1076
+ return ff_core_Ordering.OrderingSame()
1077
+ return
1078
+ }
1079
+ }
1080
+ {
1081
+ return ff_core_Ordering.OrderingSame()
1082
+ return
1083
+ }
1084
+ }
1085
+ },
1086
+ async compare_$(x_, y_, $task) {
1087
+ {
1088
+ const x_a = x_;
1089
+ const y_a = y_;
1090
+ {
1091
+ const _guard1 = (x_ === y_);
1092
+ if(_guard1) {
1093
+ return ff_core_Ordering.OrderingSame()
1094
+ return
1095
+ }
1096
+ }
1097
+ {
1098
+ return ff_core_Ordering.OrderingSame()
1099
+ return
1100
+ }
1101
+ }
1102
+ }
1103
+ };
1104
+
1105
+ export const ff_core_Serializable_Serializable$ff_compiler_Deriver_Deriver = {
1106
+ serializeUsing_(serialization_, value_) {
1107
+ {
1108
+ const serialization_a = serialization_;
1109
+ const value_a = value_;
1110
+ {
1111
+ const v_ = value_a;
1112
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1113
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1114
+ serialization_.offset_ += 1
1115
+ return
1116
+ }
1117
+ }
1118
+ },
1119
+ deserializeUsing_(serialization_) {
1120
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1121
+ serialization_.offset_ += 1;
1122
+ {
1123
+ const _1 = variantIndex_;
1124
+ {
1125
+ if(_1 == 0) {
1126
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1127
+ return ff_compiler_Deriver.Deriver()
1128
+ return
1129
+ }
1130
+ }
1131
+ {
1132
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1133
+ return
1134
+ }
1135
+ }
1136
+ },
1137
+ async serializeUsing_$(serialization_, value_, $task) {
1138
+ {
1139
+ const serialization_a = serialization_;
1140
+ const value_a = value_;
1141
+ {
1142
+ const v_ = value_a;
1143
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1144
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1145
+ serialization_.offset_ += 1
1146
+ return
1147
+ }
1148
+ }
1149
+ },
1150
+ async deserializeUsing_$(serialization_, $task) {
1151
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1152
+ serialization_.offset_ += 1;
1153
+ {
1154
+ const _1 = variantIndex_;
1155
+ {
1156
+ if(_1 == 0) {
1157
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 27), 0);
1158
+ return ff_compiler_Deriver.Deriver()
1159
+ return
1160
+ }
1161
+ }
1162
+ {
1163
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1164
+ return
1165
+ }
1166
+ }
1167
+ }
1168
+ };
1169
+
1170
+