firefly-compiler 0.4.6 → 0.4.8

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