firefly-compiler 0.4.4

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 (221) hide show
  1. package/.firefly-workspace +1 -0
  2. package/.vscode/settings.json +5 -0
  3. package/LICENSE.txt +21 -0
  4. package/README.md +96 -0
  5. package/bin/firefly.mjs +2 -0
  6. package/compiler/.firefly/package.ff +1 -0
  7. package/compiler/Builder.ff +218 -0
  8. package/compiler/Compiler.ff +241 -0
  9. package/compiler/Dependencies.ff +179 -0
  10. package/compiler/Deriver.ff +647 -0
  11. package/compiler/Dictionaries.ff +205 -0
  12. package/compiler/Environment.ff +166 -0
  13. package/compiler/Inference.ff +1117 -0
  14. package/compiler/JsEmitter.ff +861 -0
  15. package/compiler/JsImporter.ff +56 -0
  16. package/compiler/LspHook.ff +188 -0
  17. package/compiler/Main.ff +237 -0
  18. package/compiler/Parser.ff +1383 -0
  19. package/compiler/Patterns.ff +111 -0
  20. package/compiler/Resolver.ff +620 -0
  21. package/compiler/Substitution.ff +178 -0
  22. package/compiler/Syntax.ff +299 -0
  23. package/compiler/Token.ff +180 -0
  24. package/compiler/Tokenizer.ff +278 -0
  25. package/compiler/Unification.ff +220 -0
  26. package/compiler/Wildcards.ff +50 -0
  27. package/compiler/Workspace.ff +88 -0
  28. package/core/.firefly/package.ff +2 -0
  29. package/core/Any.ff +30 -0
  30. package/core/Array.ff +249 -0
  31. package/core/AssetSystem.ff +61 -0
  32. package/core/Atomic.ff +64 -0
  33. package/core/Bool.ff +13 -0
  34. package/core/BrowserSystem.ff +14 -0
  35. package/core/Buffer.ff +211 -0
  36. package/core/BuildSystem.ff +144 -0
  37. package/core/Channel.ff +131 -0
  38. package/core/Char.ff +18 -0
  39. package/core/Core.ff +58 -0
  40. package/core/Duration.ff +15 -0
  41. package/core/Equal.ff +52 -0
  42. package/core/Error.ff +20 -0
  43. package/core/FileHandle.ff +41 -0
  44. package/core/Float.ff +41 -0
  45. package/core/HttpClient.ff +84 -0
  46. package/core/Instant.ff +9 -0
  47. package/core/Int.ff +61 -0
  48. package/core/IntMap.ff +85 -0
  49. package/core/JsSystem.ff +66 -0
  50. package/core/JsValue.ff +240 -0
  51. package/core/List.ff +440 -0
  52. package/core/Lock.ff +144 -0
  53. package/core/Log.ff +24 -0
  54. package/core/Map.ff +126 -0
  55. package/core/NodeSystem.ff +88 -0
  56. package/core/Nothing.ff +1 -0
  57. package/core/Option.ff +133 -0
  58. package/core/Ordering.ff +157 -0
  59. package/core/Pair.ff +55 -0
  60. package/core/Path.ff +393 -0
  61. package/core/RbMap.ff +216 -0
  62. package/core/Serializable.ff +173 -0
  63. package/core/Set.ff +38 -0
  64. package/core/Show.ff +43 -0
  65. package/core/Stack.ff +263 -0
  66. package/core/Stream.ff +406 -0
  67. package/core/String.ff +175 -0
  68. package/core/StringMap.ff +85 -0
  69. package/core/Task.ff +138 -0
  70. package/core/Try.ff +81 -0
  71. package/core/Unit.ff +3 -0
  72. package/experimental/random/AltGeneric.ff +44 -0
  73. package/experimental/random/Async.ff +68 -0
  74. package/experimental/random/Buffer2.ff +77 -0
  75. package/experimental/random/Cat.ff +12 -0
  76. package/experimental/random/Dictionary.ff +52 -0
  77. package/experimental/random/Example.ff +46 -0
  78. package/experimental/random/Generic.ff +102 -0
  79. package/experimental/random/HappyEyeballs.ff +40 -0
  80. package/experimental/random/HashMap.ff +72 -0
  81. package/experimental/random/IfElseUnit.ff +9 -0
  82. package/experimental/random/InputOutput.ff +23 -0
  83. package/experimental/random/ListVsArray.ff +45 -0
  84. package/experimental/random/Main.ff +44 -0
  85. package/experimental/random/MapTest.ff +67 -0
  86. package/experimental/random/OldTaskSystem.ff +210 -0
  87. package/experimental/random/PatternTest.ff +39 -0
  88. package/experimental/random/Patterns.ff +226 -0
  89. package/experimental/random/ReadBytesTest.ff +10 -0
  90. package/experimental/random/RunLength.ff +65 -0
  91. package/experimental/random/Scrape.ff +51 -0
  92. package/experimental/random/Serialization.ff +217 -0
  93. package/experimental/random/SerializationTest.ff +46 -0
  94. package/experimental/random/Serializer.ff +36 -0
  95. package/experimental/random/StdInOutErr.ff +4 -0
  96. package/experimental/random/Symbols.ff +74 -0
  97. package/experimental/random/Tag.ff +49 -0
  98. package/experimental/random/Tensor.ff +52 -0
  99. package/experimental/random/Try.ff +56 -0
  100. package/experimental/random/Tsv.ff +9 -0
  101. package/experimental/random/TypesAreModules.ff +87 -0
  102. package/experimental/random/blueprints/Blueprint.ff +52 -0
  103. package/experimental/random/blueprints/Main.ff +11 -0
  104. package/experimental/random/blueprints/Pretty.ff +58 -0
  105. package/experimental/random/blueprints/User.ff +64 -0
  106. package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
  107. package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
  108. package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
  109. package/experimental/random/blueprintsystem/User.ff +2 -0
  110. package/experimental/random/kahrs/Kahrs.ff +112 -0
  111. package/experimental/random/kahrs/TestKahrs.ff +22 -0
  112. package/experimental/random/kahrs/TestMap.ff +18 -0
  113. package/experimental/random/streaming/Gzip.ff +3 -0
  114. package/experimental/random/streaming/Main.ff +34 -0
  115. package/experimental/random/streaming/S3Bucket.ff +11 -0
  116. package/experimental/random/streaming/Tar.ff +5 -0
  117. package/experimental/rhymeapp/Main.ff +81 -0
  118. package/experimental/rhymeapp/index.html +14 -0
  119. package/firefly.sh +5 -0
  120. package/fireflysite/Main.ff +13 -0
  121. package/httpserver/.firefly/package.ff +1 -0
  122. package/httpserver/HttpServer.ff +184 -0
  123. package/lsp/.firefly/package.ff +1 -0
  124. package/lsp/CompletionHandler.ff +814 -0
  125. package/lsp/Handler.ff +551 -0
  126. package/lsp/HoverHandler.ff +82 -0
  127. package/lsp/LanguageServer.ff +229 -0
  128. package/lsp/SignatureHelpHandler.ff +55 -0
  129. package/lsp/SymbolHandler.ff +167 -0
  130. package/output/js/ff/compiler/Builder.mjs +483 -0
  131. package/output/js/ff/compiler/Compiler.mjs +410 -0
  132. package/output/js/ff/compiler/Dependencies.mjs +388 -0
  133. package/output/js/ff/compiler/Deriver.mjs +1166 -0
  134. package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
  135. package/output/js/ff/compiler/Environment.mjs +1005 -0
  136. package/output/js/ff/compiler/Inference.mjs +4264 -0
  137. package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
  138. package/output/js/ff/compiler/JsImporter.mjs +262 -0
  139. package/output/js/ff/compiler/LspHook.mjs +789 -0
  140. package/output/js/ff/compiler/Main.mjs +1695 -0
  141. package/output/js/ff/compiler/Parser.mjs +4004 -0
  142. package/output/js/ff/compiler/Patterns.mjs +923 -0
  143. package/output/js/ff/compiler/Resolver.mjs +2303 -0
  144. package/output/js/ff/compiler/Substitution.mjs +1146 -0
  145. package/output/js/ff/compiler/Syntax.mjs +12430 -0
  146. package/output/js/ff/compiler/Token.mjs +3092 -0
  147. package/output/js/ff/compiler/Tokenizer.mjs +589 -0
  148. package/output/js/ff/compiler/Unification.mjs +1748 -0
  149. package/output/js/ff/compiler/Wildcards.mjs +604 -0
  150. package/output/js/ff/compiler/Workspace.mjs +683 -0
  151. package/output/js/ff/core/Any.mjs +139 -0
  152. package/output/js/ff/core/Array.mjs +594 -0
  153. package/output/js/ff/core/AssetSystem.mjs +270 -0
  154. package/output/js/ff/core/Atomic.mjs +186 -0
  155. package/output/js/ff/core/Bool.mjs +141 -0
  156. package/output/js/ff/core/BrowserSystem.mjs +122 -0
  157. package/output/js/ff/core/Buffer.mjs +467 -0
  158. package/output/js/ff/core/BuildSystem.mjs +320 -0
  159. package/output/js/ff/core/Channel.mjs +268 -0
  160. package/output/js/ff/core/Char.mjs +145 -0
  161. package/output/js/ff/core/Core.mjs +300 -0
  162. package/output/js/ff/core/Duration.mjs +112 -0
  163. package/output/js/ff/core/Equal.mjs +175 -0
  164. package/output/js/ff/core/Error.mjs +138 -0
  165. package/output/js/ff/core/FileHandle.mjs +164 -0
  166. package/output/js/ff/core/Float.mjs +214 -0
  167. package/output/js/ff/core/HttpClient.mjs +210 -0
  168. package/output/js/ff/core/Instant.mjs +105 -0
  169. package/output/js/ff/core/Int.mjs +254 -0
  170. package/output/js/ff/core/IntMap.mjs +282 -0
  171. package/output/js/ff/core/JsSystem.mjs +234 -0
  172. package/output/js/ff/core/JsValue.mjs +678 -0
  173. package/output/js/ff/core/List.mjs +2335 -0
  174. package/output/js/ff/core/Lock.mjs +322 -0
  175. package/output/js/ff/core/Log.mjs +159 -0
  176. package/output/js/ff/core/Map.mjs +358 -0
  177. package/output/js/ff/core/NodeSystem.mjs +288 -0
  178. package/output/js/ff/core/Nothing.mjs +100 -0
  179. package/output/js/ff/core/Option.mjs +1002 -0
  180. package/output/js/ff/core/Ordering.mjs +734 -0
  181. package/output/js/ff/core/Pair.mjs +318 -0
  182. package/output/js/ff/core/Path.mjs +768 -0
  183. package/output/js/ff/core/RbMap.mjs +1936 -0
  184. package/output/js/ff/core/Serializable.mjs +434 -0
  185. package/output/js/ff/core/Set.mjs +250 -0
  186. package/output/js/ff/core/Show.mjs +201 -0
  187. package/output/js/ff/core/Stack.mjs +595 -0
  188. package/output/js/ff/core/Stream.mjs +1300 -0
  189. package/output/js/ff/core/String.mjs +433 -0
  190. package/output/js/ff/core/StringMap.mjs +282 -0
  191. package/output/js/ff/core/Task.mjs +345 -0
  192. package/output/js/ff/core/Try.mjs +503 -0
  193. package/output/js/ff/core/Unit.mjs +103 -0
  194. package/package.json +29 -0
  195. package/postgresql/.firefly/include/package-lock.json +250 -0
  196. package/postgresql/.firefly/include/package.json +5 -0
  197. package/postgresql/.firefly/include/prepare.sh +2 -0
  198. package/postgresql/.firefly/package.ff +3 -0
  199. package/postgresql/Pg.ff +530 -0
  200. package/unsafejs/.firefly/package.ff +1 -0
  201. package/unsafejs/UnsafeJs.ff +19 -0
  202. package/vscode/.vscode/launch.json +18 -0
  203. package/vscode/.vscode/tasks.json +33 -0
  204. package/vscode/LICENSE.txt +21 -0
  205. package/vscode/Prepublish.ff +15 -0
  206. package/vscode/README.md +17 -0
  207. package/vscode/client/package-lock.json +544 -0
  208. package/vscode/client/package.json +22 -0
  209. package/vscode/client/src/extension.ts +64 -0
  210. package/vscode/client/tsconfig.json +12 -0
  211. package/vscode/icons/firefly-icon.png +0 -0
  212. package/vscode/icons/firefly-icon.svg +10 -0
  213. package/vscode/icons/firefly-logo-notext.png +0 -0
  214. package/vscode/icons/firefly-logo.png +0 -0
  215. package/vscode/language-configuration.json +39 -0
  216. package/vscode/package-lock.json +3623 -0
  217. package/vscode/package.json +144 -0
  218. package/vscode/snippets-none.json +1 -0
  219. package/vscode/snippets.json +241 -0
  220. package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
  221. package/vscode/tsconfig.json +20 -0
@@ -0,0 +1,1305 @@
1
+
2
+
3
+ import * as ff_compiler_Dictionaries from "../../ff/compiler/Dictionaries.mjs"
4
+
5
+ import * as ff_compiler_Environment from "../../ff/compiler/Environment.mjs"
6
+
7
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
+
9
+ import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
10
+
11
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
12
+
13
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
14
+
15
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
16
+
17
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
18
+
19
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
20
+
21
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
22
+
23
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
24
+
25
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
26
+
27
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
28
+
29
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
30
+
31
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
32
+
33
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
34
+
35
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
36
+
37
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
38
+
39
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
40
+
41
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
42
+
43
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
44
+
45
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
46
+
47
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
48
+
49
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
50
+
51
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
52
+
53
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
54
+
55
+ import * as ff_core_List from "../../ff/core/List.mjs"
56
+
57
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
58
+
59
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
60
+
61
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
62
+
63
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
64
+
65
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
66
+
67
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
68
+
69
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
70
+
71
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
72
+
73
+ import * as ff_core_Path from "../../ff/core/Path.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_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 Dictionaries
96
+ export function Dictionaries(instances_) {
97
+ return {instances_};
98
+ }
99
+
100
+
101
+
102
+ export function make_(modules_) {
103
+ return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
104
+ }
105
+
106
+ export function fail_(at_, message_) {
107
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
108
+ }
109
+
110
+ export function constraintsToInstances_(constraints_) {
111
+ return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
112
+ const typeName_ = (((_1) => {
113
+ {
114
+ if(_1.TConstructor) {
115
+ const name_ = _1.name_;
116
+ return name_
117
+ return
118
+ }
119
+ }
120
+ {
121
+ if(_1.TVariable) {
122
+ const i_ = _1.index_;
123
+ return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
124
+ return
125
+ }
126
+ }
127
+ }))(ff_core_List.List_grabFirst(c_.generics_));
128
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
129
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
130
+ }
131
+
132
+ export async function make_$(modules_, $task) {
133
+ return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
134
+ }
135
+
136
+ export async function fail_$(at_, message_, $task) {
137
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
138
+ }
139
+
140
+ export async function constraintsToInstances_$(constraints_, $task) {
141
+ return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
142
+ const typeName_ = (((_1) => {
143
+ {
144
+ if(_1.TConstructor) {
145
+ const name_ = _1.name_;
146
+ return name_
147
+ return
148
+ }
149
+ }
150
+ {
151
+ if(_1.TVariable) {
152
+ const i_ = _1.index_;
153
+ return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
154
+ return
155
+ }
156
+ }
157
+ }))(ff_core_List.List_grabFirst(c_.generics_));
158
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
159
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
160
+ }
161
+
162
+ export function Dictionaries_processModule(self_, module_, otherModules_) {
163
+ const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
164
+ const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
165
+ {
166
+ const name_ = _1.first_;
167
+ const s_ = _1.second_;
168
+ const _guard1 = (!s_.isVariable_);
169
+ if(_guard1) {
170
+ return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
171
+ return
172
+ }
173
+ }
174
+ {
175
+ return ff_core_Option.None()
176
+ return
177
+ }
178
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
179
+ const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
180
+ return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
181
+ }));
182
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
183
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
184
+ }));
185
+ const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
186
+ return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
187
+ }));
188
+ const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
189
+ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
190
+ }));
191
+ {
192
+ const _1 = module_;
193
+ {
194
+ const _c = _1;
195
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
196
+ return
197
+ }
198
+ }
199
+ }
200
+
201
+ export function Dictionaries_processLetDefinition(self_, functions_, definition_) {
202
+ {
203
+ const _1 = definition_;
204
+ {
205
+ const _c = _1;
206
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
207
+ return
208
+ }
209
+ }
210
+ }
211
+
212
+ export function Dictionaries_processExtendDefinition(self_, functions_, definition_) {
213
+ {
214
+ const _1 = definition_;
215
+ {
216
+ const _c = _1;
217
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
218
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
219
+ })))
220
+ return
221
+ }
222
+ }
223
+ }
224
+
225
+ export function Dictionaries_processFunctionDefinition(self_, functions_, definition_) {
226
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
227
+ const self2_ = (((_c) => {
228
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
229
+ }))(self_);
230
+ {
231
+ const _1 = definition_;
232
+ {
233
+ const _c = _1;
234
+ return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
235
+ return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
236
+ })))
237
+ return
238
+ }
239
+ }
240
+ }
241
+
242
+ export function Dictionaries_processInstanceDefinition(self_, functions_, definition_) {
243
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
244
+ const self2_ = (((_c) => {
245
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
246
+ }))(self_);
247
+ {
248
+ const _1 = definition_;
249
+ {
250
+ const _c = _1;
251
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
252
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
253
+ })), _c.derived_)
254
+ return
255
+ }
256
+ }
257
+ }
258
+
259
+ export function Dictionaries_processLambda(self_, functions_, definition_) {
260
+ {
261
+ const _1 = definition_;
262
+ {
263
+ const _c = _1;
264
+ return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
265
+ {
266
+ const _1 = case_;
267
+ {
268
+ const _c = _1;
269
+ return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
270
+ {
271
+ const _1 = g_;
272
+ {
273
+ const _c = _1;
274
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
275
+ return
276
+ }
277
+ }
278
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
279
+ return
280
+ }
281
+ }
282
+ })))
283
+ return
284
+ }
285
+ }
286
+ }
287
+
288
+ export function Dictionaries_processTerm(self_, functions_, term_) {
289
+ {
290
+ const _1 = term_;
291
+ {
292
+ if(_1.EString) {
293
+ return term_
294
+ return
295
+ }
296
+ }
297
+ {
298
+ if(_1.EChar) {
299
+ return term_
300
+ return
301
+ }
302
+ }
303
+ {
304
+ if(_1.EInt) {
305
+ return term_
306
+ return
307
+ }
308
+ }
309
+ {
310
+ if(_1.EFloat) {
311
+ return term_
312
+ return
313
+ }
314
+ }
315
+ {
316
+ if(_1.EVariable) {
317
+ return term_
318
+ return
319
+ }
320
+ }
321
+ {
322
+ if(_1.EField) {
323
+ const e_ = _1;
324
+ {
325
+ const _1 = e_;
326
+ {
327
+ const _c = _1;
328
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
329
+ return
330
+ }
331
+ }
332
+ return
333
+ }
334
+ }
335
+ {
336
+ if(_1.EWildcard) {
337
+ const e_ = _1;
338
+ return term_
339
+ return
340
+ }
341
+ }
342
+ {
343
+ if(_1.EList) {
344
+ const e_ = _1;
345
+ {
346
+ const _1 = e_;
347
+ {
348
+ const _c = _1;
349
+ return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
350
+ {
351
+ const item_ = _1.first_;
352
+ const b_ = _1.second_;
353
+ return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
354
+ return
355
+ }
356
+ })))
357
+ return
358
+ }
359
+ }
360
+ return
361
+ }
362
+ }
363
+ {
364
+ if(_1.ESequential) {
365
+ const e_ = _1;
366
+ {
367
+ const _1 = e_;
368
+ {
369
+ const _c = _1;
370
+ return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
371
+ return
372
+ }
373
+ }
374
+ return
375
+ }
376
+ }
377
+ {
378
+ if(_1.ELet) {
379
+ const e_ = _1;
380
+ const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
381
+ {
382
+ const _1 = e_;
383
+ {
384
+ const _c = _1;
385
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
386
+ return
387
+ }
388
+ }
389
+ return
390
+ }
391
+ }
392
+ {
393
+ if(_1.ELambda) {
394
+ const e_ = _1;
395
+ {
396
+ const _1 = e_;
397
+ {
398
+ const _c = _1;
399
+ return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
400
+ return
401
+ }
402
+ }
403
+ return
404
+ }
405
+ }
406
+ {
407
+ if(_1.EVariant) {
408
+ const e_ = _1;
409
+ {
410
+ const _1 = e_;
411
+ {
412
+ const _c = _1;
413
+ return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
414
+ return ff_core_List.List_map(_w1, ((_w1) => {
415
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
416
+ }))
417
+ })))
418
+ return
419
+ }
420
+ }
421
+ return
422
+ }
423
+ }
424
+ {
425
+ if(_1.EVariantIs) {
426
+ const e_ = _1;
427
+ return term_
428
+ return
429
+ }
430
+ }
431
+ {
432
+ if(_1.ECopy) {
433
+ const e_ = _1;
434
+ {
435
+ const _1 = e_;
436
+ {
437
+ const _c = _1;
438
+ return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
439
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
440
+ })))
441
+ return
442
+ }
443
+ }
444
+ return
445
+ }
446
+ }
447
+ {
448
+ if(_1.EPipe) {
449
+ const e_ = _1;
450
+ {
451
+ const _1 = e_;
452
+ {
453
+ const _c = _1;
454
+ return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
455
+ return
456
+ }
457
+ }
458
+ return
459
+ }
460
+ }
461
+ {
462
+ if(_1.ECall) {
463
+ const at_ = _1.at_;
464
+ if(_1.target_.StaticCall) {
465
+ const target_ = _1.target_;
466
+ const effect_ = _1.effect_;
467
+ const typeArguments_ = _1.typeArguments_;
468
+ const arguments_ = _1.arguments_;
469
+ const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
470
+ if(_guard1.Some) {
471
+ const signature_ = _guard1.value_;
472
+ const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
473
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
474
+ }));
475
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
476
+ return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
477
+ }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
478
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
479
+ })), dictionaries_)
480
+ return
481
+ }
482
+ }
483
+ }
484
+ }
485
+ {
486
+ if(_1.ECall) {
487
+ const e_ = _1;
488
+ const target_ = (((_1) => {
489
+ {
490
+ if(_1.DynamicCall) {
491
+ const call_ = _1;
492
+ {
493
+ const _1 = call_;
494
+ {
495
+ const _c = _1;
496
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
497
+ return
498
+ }
499
+ }
500
+ return
501
+ }
502
+ }
503
+ {
504
+ if(_1.StaticCall) {
505
+ return e_.target_
506
+ return
507
+ }
508
+ }
509
+ }))(e_.target_);
510
+ {
511
+ const _1 = e_;
512
+ {
513
+ const _c = _1;
514
+ return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
515
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
516
+ })), _c.dictionaries_)
517
+ return
518
+ }
519
+ }
520
+ return
521
+ }
522
+ }
523
+ {
524
+ if(_1.ERecord) {
525
+ const e_ = _1;
526
+ {
527
+ const _1 = e_;
528
+ {
529
+ const _c = _1;
530
+ return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
531
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
532
+ })))
533
+ return
534
+ }
535
+ }
536
+ return
537
+ }
538
+ }
539
+ {
540
+ if(_1.EFunctions) {
541
+ const e_ = _1;
542
+ const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
543
+ return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
544
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
545
+ {
546
+ const _1 = e_;
547
+ {
548
+ const _c = _1;
549
+ return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
550
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
551
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
552
+ return
553
+ }
554
+ }
555
+ return
556
+ }
557
+ }
558
+ {
559
+ if(_1.EAssign) {
560
+ const e_ = _1;
561
+ {
562
+ const _1 = e_;
563
+ {
564
+ const _c = _1;
565
+ return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
566
+ return
567
+ }
568
+ }
569
+ return
570
+ }
571
+ }
572
+ {
573
+ if(_1.EAssignField) {
574
+ const e_ = _1;
575
+ {
576
+ const _1 = e_;
577
+ {
578
+ const _c = _1;
579
+ return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
580
+ return
581
+ }
582
+ }
583
+ return
584
+ }
585
+ }
586
+ }
587
+ }
588
+
589
+ export function Dictionaries_processArgument(self_, functions_, argument_) {
590
+ {
591
+ const _1 = argument_;
592
+ {
593
+ const _c = _1;
594
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
595
+ return
596
+ }
597
+ }
598
+ }
599
+
600
+ export function Dictionaries_processField(self_, functions_, field_) {
601
+ {
602
+ const _1 = field_;
603
+ {
604
+ const _c = _1;
605
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
606
+ return
607
+ }
608
+ }
609
+ }
610
+
611
+ export function Dictionaries_makeDictionary(self_, at_, typeParameters_, typeArguments_, constraint_) {
612
+ const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
613
+ const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
614
+ const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
615
+ return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
616
+ }));
617
+ const firstType_ = (((_1) => {
618
+ {
619
+ if(_1.TConstructor) {
620
+ const t_ = _1;
621
+ return t_
622
+ return
623
+ }
624
+ }
625
+ {
626
+ if(_1.TVariable) {
627
+ const t_ = _1;
628
+ return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
629
+ return
630
+ }
631
+ }
632
+ }))(ff_core_List.List_grabFirst(newGenerics_));
633
+ const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
634
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
635
+ }));
636
+ const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
637
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
638
+ }));
639
+ return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
640
+ }
641
+
642
+ export async function Dictionaries_processModule$(self_, module_, otherModules_, $task) {
643
+ const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
644
+ const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
645
+ {
646
+ const name_ = _1.first_;
647
+ const s_ = _1.second_;
648
+ const _guard1 = (!s_.isVariable_);
649
+ if(_guard1) {
650
+ return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
651
+ return
652
+ }
653
+ }
654
+ {
655
+ return ff_core_Option.None()
656
+ return
657
+ }
658
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
659
+ const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
660
+ return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
661
+ }));
662
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
663
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
664
+ }));
665
+ const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
666
+ return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
667
+ }));
668
+ const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
669
+ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
670
+ }));
671
+ {
672
+ const _1 = module_;
673
+ {
674
+ const _c = _1;
675
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
676
+ return
677
+ }
678
+ }
679
+ }
680
+
681
+ export async function Dictionaries_processLetDefinition$(self_, functions_, definition_, $task) {
682
+ {
683
+ const _1 = definition_;
684
+ {
685
+ const _c = _1;
686
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
687
+ return
688
+ }
689
+ }
690
+ }
691
+
692
+ export async function Dictionaries_processExtendDefinition$(self_, functions_, definition_, $task) {
693
+ {
694
+ const _1 = definition_;
695
+ {
696
+ const _c = _1;
697
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
698
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
699
+ })))
700
+ return
701
+ }
702
+ }
703
+ }
704
+
705
+ export async function Dictionaries_processFunctionDefinition$(self_, functions_, definition_, $task) {
706
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
707
+ const self2_ = (((_c) => {
708
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
709
+ }))(self_);
710
+ {
711
+ const _1 = definition_;
712
+ {
713
+ const _c = _1;
714
+ return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
715
+ return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
716
+ })))
717
+ return
718
+ }
719
+ }
720
+ }
721
+
722
+ export async function Dictionaries_processInstanceDefinition$(self_, functions_, definition_, $task) {
723
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
724
+ const self2_ = (((_c) => {
725
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
726
+ }))(self_);
727
+ {
728
+ const _1 = definition_;
729
+ {
730
+ const _c = _1;
731
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
732
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
733
+ })), _c.derived_)
734
+ return
735
+ }
736
+ }
737
+ }
738
+
739
+ export async function Dictionaries_processLambda$(self_, functions_, definition_, $task) {
740
+ {
741
+ const _1 = definition_;
742
+ {
743
+ const _c = _1;
744
+ return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
745
+ {
746
+ const _1 = case_;
747
+ {
748
+ const _c = _1;
749
+ return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
750
+ {
751
+ const _1 = g_;
752
+ {
753
+ const _c = _1;
754
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
755
+ return
756
+ }
757
+ }
758
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
759
+ return
760
+ }
761
+ }
762
+ })))
763
+ return
764
+ }
765
+ }
766
+ }
767
+
768
+ export async function Dictionaries_processTerm$(self_, functions_, term_, $task) {
769
+ {
770
+ const _1 = term_;
771
+ {
772
+ if(_1.EString) {
773
+ return term_
774
+ return
775
+ }
776
+ }
777
+ {
778
+ if(_1.EChar) {
779
+ return term_
780
+ return
781
+ }
782
+ }
783
+ {
784
+ if(_1.EInt) {
785
+ return term_
786
+ return
787
+ }
788
+ }
789
+ {
790
+ if(_1.EFloat) {
791
+ return term_
792
+ return
793
+ }
794
+ }
795
+ {
796
+ if(_1.EVariable) {
797
+ return term_
798
+ return
799
+ }
800
+ }
801
+ {
802
+ if(_1.EField) {
803
+ const e_ = _1;
804
+ {
805
+ const _1 = e_;
806
+ {
807
+ const _c = _1;
808
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
809
+ return
810
+ }
811
+ }
812
+ return
813
+ }
814
+ }
815
+ {
816
+ if(_1.EWildcard) {
817
+ const e_ = _1;
818
+ return term_
819
+ return
820
+ }
821
+ }
822
+ {
823
+ if(_1.EList) {
824
+ const e_ = _1;
825
+ {
826
+ const _1 = e_;
827
+ {
828
+ const _c = _1;
829
+ return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
830
+ {
831
+ const item_ = _1.first_;
832
+ const b_ = _1.second_;
833
+ return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
834
+ return
835
+ }
836
+ })))
837
+ return
838
+ }
839
+ }
840
+ return
841
+ }
842
+ }
843
+ {
844
+ if(_1.ESequential) {
845
+ const e_ = _1;
846
+ {
847
+ const _1 = e_;
848
+ {
849
+ const _c = _1;
850
+ return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
851
+ return
852
+ }
853
+ }
854
+ return
855
+ }
856
+ }
857
+ {
858
+ if(_1.ELet) {
859
+ const e_ = _1;
860
+ const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
861
+ {
862
+ const _1 = e_;
863
+ {
864
+ const _c = _1;
865
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
866
+ return
867
+ }
868
+ }
869
+ return
870
+ }
871
+ }
872
+ {
873
+ if(_1.ELambda) {
874
+ const e_ = _1;
875
+ {
876
+ const _1 = e_;
877
+ {
878
+ const _c = _1;
879
+ return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
880
+ return
881
+ }
882
+ }
883
+ return
884
+ }
885
+ }
886
+ {
887
+ if(_1.EVariant) {
888
+ const e_ = _1;
889
+ {
890
+ const _1 = e_;
891
+ {
892
+ const _c = _1;
893
+ return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
894
+ return ff_core_List.List_map(_w1, ((_w1) => {
895
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
896
+ }))
897
+ })))
898
+ return
899
+ }
900
+ }
901
+ return
902
+ }
903
+ }
904
+ {
905
+ if(_1.EVariantIs) {
906
+ const e_ = _1;
907
+ return term_
908
+ return
909
+ }
910
+ }
911
+ {
912
+ if(_1.ECopy) {
913
+ const e_ = _1;
914
+ {
915
+ const _1 = e_;
916
+ {
917
+ const _c = _1;
918
+ return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
919
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
920
+ })))
921
+ return
922
+ }
923
+ }
924
+ return
925
+ }
926
+ }
927
+ {
928
+ if(_1.EPipe) {
929
+ const e_ = _1;
930
+ {
931
+ const _1 = e_;
932
+ {
933
+ const _c = _1;
934
+ return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
935
+ return
936
+ }
937
+ }
938
+ return
939
+ }
940
+ }
941
+ {
942
+ if(_1.ECall) {
943
+ const at_ = _1.at_;
944
+ if(_1.target_.StaticCall) {
945
+ const target_ = _1.target_;
946
+ const effect_ = _1.effect_;
947
+ const typeArguments_ = _1.typeArguments_;
948
+ const arguments_ = _1.arguments_;
949
+ const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
950
+ if(_guard1.Some) {
951
+ const signature_ = _guard1.value_;
952
+ const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
953
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
954
+ }));
955
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
956
+ return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
957
+ }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
958
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
959
+ })), dictionaries_)
960
+ return
961
+ }
962
+ }
963
+ }
964
+ }
965
+ {
966
+ if(_1.ECall) {
967
+ const e_ = _1;
968
+ const target_ = (((_1) => {
969
+ {
970
+ if(_1.DynamicCall) {
971
+ const call_ = _1;
972
+ {
973
+ const _1 = call_;
974
+ {
975
+ const _c = _1;
976
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
977
+ return
978
+ }
979
+ }
980
+ return
981
+ }
982
+ }
983
+ {
984
+ if(_1.StaticCall) {
985
+ return e_.target_
986
+ return
987
+ }
988
+ }
989
+ }))(e_.target_);
990
+ {
991
+ const _1 = e_;
992
+ {
993
+ const _c = _1;
994
+ return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
995
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
996
+ })), _c.dictionaries_)
997
+ return
998
+ }
999
+ }
1000
+ return
1001
+ }
1002
+ }
1003
+ {
1004
+ if(_1.ERecord) {
1005
+ const e_ = _1;
1006
+ {
1007
+ const _1 = e_;
1008
+ {
1009
+ const _c = _1;
1010
+ return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
1011
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
1012
+ })))
1013
+ return
1014
+ }
1015
+ }
1016
+ return
1017
+ }
1018
+ }
1019
+ {
1020
+ if(_1.EFunctions) {
1021
+ const e_ = _1;
1022
+ const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
1023
+ return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
1024
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1025
+ {
1026
+ const _1 = e_;
1027
+ {
1028
+ const _c = _1;
1029
+ return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
1030
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
1031
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
1032
+ return
1033
+ }
1034
+ }
1035
+ return
1036
+ }
1037
+ }
1038
+ {
1039
+ if(_1.EAssign) {
1040
+ const e_ = _1;
1041
+ {
1042
+ const _1 = e_;
1043
+ {
1044
+ const _c = _1;
1045
+ return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1046
+ return
1047
+ }
1048
+ }
1049
+ return
1050
+ }
1051
+ }
1052
+ {
1053
+ if(_1.EAssignField) {
1054
+ const e_ = _1;
1055
+ {
1056
+ const _1 = e_;
1057
+ {
1058
+ const _c = _1;
1059
+ return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1060
+ return
1061
+ }
1062
+ }
1063
+ return
1064
+ }
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+ export async function Dictionaries_processArgument$(self_, functions_, argument_, $task) {
1070
+ {
1071
+ const _1 = argument_;
1072
+ {
1073
+ const _c = _1;
1074
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
1075
+ return
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ export async function Dictionaries_processField$(self_, functions_, field_, $task) {
1081
+ {
1082
+ const _1 = field_;
1083
+ {
1084
+ const _c = _1;
1085
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
1086
+ return
1087
+ }
1088
+ }
1089
+ }
1090
+
1091
+ export async function Dictionaries_makeDictionary$(self_, at_, typeParameters_, typeArguments_, constraint_, $task) {
1092
+ const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1093
+ const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
1094
+ const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
1095
+ return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
1096
+ }));
1097
+ const firstType_ = (((_1) => {
1098
+ {
1099
+ if(_1.TConstructor) {
1100
+ const t_ = _1;
1101
+ return t_
1102
+ return
1103
+ }
1104
+ }
1105
+ {
1106
+ if(_1.TVariable) {
1107
+ const t_ = _1;
1108
+ return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
1109
+ return
1110
+ }
1111
+ }
1112
+ }))(ff_core_List.List_grabFirst(newGenerics_));
1113
+ const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
1114
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1115
+ }));
1116
+ const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
1117
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
1118
+ }));
1119
+ return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
1120
+ }
1121
+
1122
+ export const ff_core_Any_HasAnyTag$ff_compiler_Dictionaries_Dictionaries = {
1123
+ anyTag_() {
1124
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1125
+ },
1126
+ async anyTag_$($task) {
1127
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1128
+ }
1129
+ };
1130
+
1131
+ export const ff_core_Show_Show$ff_compiler_Dictionaries_Dictionaries = {
1132
+ show_(value_) {
1133
+ {
1134
+ const value_a = value_;
1135
+ {
1136
+ const z_ = value_a;
1137
+ return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1138
+ return
1139
+ }
1140
+ }
1141
+ },
1142
+ async show_$(value_, $task) {
1143
+ {
1144
+ const value_a = value_;
1145
+ {
1146
+ const z_ = value_a;
1147
+ return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1148
+ return
1149
+ }
1150
+ }
1151
+ }
1152
+ };
1153
+
1154
+ export const ff_core_Equal_Equal$ff_compiler_Dictionaries_Dictionaries = {
1155
+ equals_(x_, y_) {
1156
+ {
1157
+ const x_a = x_;
1158
+ const y_a = y_;
1159
+ {
1160
+ const _guard1 = (x_ === y_);
1161
+ if(_guard1) {
1162
+ return true
1163
+ return
1164
+ }
1165
+ }
1166
+ {
1167
+ return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1168
+ return
1169
+ }
1170
+ }
1171
+ },
1172
+ async equals_$(x_, y_, $task) {
1173
+ {
1174
+ const x_a = x_;
1175
+ const y_a = y_;
1176
+ {
1177
+ const _guard1 = (x_ === y_);
1178
+ if(_guard1) {
1179
+ return true
1180
+ return
1181
+ }
1182
+ }
1183
+ {
1184
+ return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1185
+ return
1186
+ }
1187
+ }
1188
+ }
1189
+ };
1190
+
1191
+ export const ff_core_Ordering_Order$ff_compiler_Dictionaries_Dictionaries = {
1192
+ compare_(x_, y_) {
1193
+ {
1194
+ const x_a = x_;
1195
+ const y_a = y_;
1196
+ {
1197
+ const _guard1 = (x_ === y_);
1198
+ if(_guard1) {
1199
+ return ff_core_Ordering.OrderingSame()
1200
+ return
1201
+ }
1202
+ }
1203
+ {
1204
+ const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1205
+ if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1206
+ return instancesOrdering_
1207
+ } else {
1208
+ return ff_core_Ordering.OrderingSame()
1209
+ }
1210
+ return
1211
+ }
1212
+ }
1213
+ },
1214
+ async compare_$(x_, y_, $task) {
1215
+ {
1216
+ const x_a = x_;
1217
+ const y_a = y_;
1218
+ {
1219
+ const _guard1 = (x_ === y_);
1220
+ if(_guard1) {
1221
+ return ff_core_Ordering.OrderingSame()
1222
+ return
1223
+ }
1224
+ }
1225
+ {
1226
+ const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1227
+ if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1228
+ return instancesOrdering_
1229
+ } else {
1230
+ return ff_core_Ordering.OrderingSame()
1231
+ }
1232
+ return
1233
+ }
1234
+ }
1235
+ }
1236
+ };
1237
+
1238
+ export const ff_core_Serializable_Serializable$ff_compiler_Dictionaries_Dictionaries = {
1239
+ serializeUsing_(serialization_, value_) {
1240
+ {
1241
+ const serialization_a = serialization_;
1242
+ const value_a = value_;
1243
+ {
1244
+ const v_ = value_a;
1245
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1246
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1247
+ serialization_.offset_ += 1;
1248
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1249
+ return
1250
+ }
1251
+ }
1252
+ },
1253
+ deserializeUsing_(serialization_) {
1254
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1255
+ serialization_.offset_ += 1;
1256
+ {
1257
+ const _1 = variantIndex_;
1258
+ {
1259
+ if(_1 == 0) {
1260
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1261
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1262
+ return
1263
+ }
1264
+ }
1265
+ {
1266
+ 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)})
1267
+ return
1268
+ }
1269
+ }
1270
+ },
1271
+ async serializeUsing_$(serialization_, value_, $task) {
1272
+ {
1273
+ const serialization_a = serialization_;
1274
+ const value_a = value_;
1275
+ {
1276
+ const v_ = value_a;
1277
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1278
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1279
+ serialization_.offset_ += 1;
1280
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1281
+ return
1282
+ }
1283
+ }
1284
+ },
1285
+ async deserializeUsing_$(serialization_, $task) {
1286
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1287
+ serialization_.offset_ += 1;
1288
+ {
1289
+ const _1 = variantIndex_;
1290
+ {
1291
+ if(_1 == 0) {
1292
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1293
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1294
+ return
1295
+ }
1296
+ }
1297
+ {
1298
+ 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)})
1299
+ return
1300
+ }
1301
+ }
1302
+ }
1303
+ };
1304
+
1305
+