firefly-compiler 0.4.79 → 0.4.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +153 -153
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +257 -257
- package/compiler/Compiler.ff +227 -227
- package/compiler/Dependencies.ff +187 -187
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/Inference.ff +2 -1
- package/compiler/JsEmitter.ff +940 -946
- package/compiler/LspHook.ff +202 -202
- package/compiler/Main.ff +3 -3
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Tokenizer.ff +1 -1
- package/compiler/Unification.ff +1 -1
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package-lock.json +564 -564
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/include/prepare.sh +1 -1
- package/core/.firefly/package.ff +2 -2
- package/core/Array.ff +265 -265
- package/core/Atomic.ff +64 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/BuildSystem.ff +148 -148
- package/core/Crypto.ff +96 -96
- package/core/Equal.ff +36 -36
- package/core/Float.ff +25 -0
- package/core/HttpClient.ff +148 -148
- package/core/JsSystem.ff +69 -69
- package/core/Json.ff +434 -434
- package/core/List.ff +486 -486
- package/core/Lock.ff +144 -144
- package/core/NodeSystem.ff +216 -216
- package/core/Ordering.ff +161 -161
- package/core/Path.ff +401 -401
- package/core/Random.ff +134 -134
- package/core/RbMap.ff +216 -216
- package/core/Show.ff +43 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Stream.ff +9 -9
- package/core/Task.ff +149 -141
- package/core/Try.ff +25 -4
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
- package/experimental/s3/S3TestPut.ff +16 -16
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/.firefly/package.ff +4 -4
- package/fireflysite/CommunityOverview.ff +20 -20
- package/fireflysite/CountingButtonDemo.ff +58 -58
- package/fireflysite/DocumentParser.ff +331 -217
- package/fireflysite/ExamplesOverview.ff +40 -40
- package/fireflysite/FrontPage.ff +344 -360
- package/fireflysite/{GuideIntroduction.ff → GettingStarted.ff} +45 -52
- package/fireflysite/Guide.ff +442 -411
- package/fireflysite/Main.ff +151 -137
- package/fireflysite/MatchingPasswordsDemo.ff +82 -82
- package/fireflysite/PackagesOverview.ff +49 -49
- package/fireflysite/PostgresqlDemo.ff +34 -34
- package/fireflysite/ReferenceAll.ff +18 -0
- package/fireflysite/ReferenceIntroduction.ff +11 -0
- package/fireflysite/Styles.ff +567 -495
- package/fireflysite/Test.ff +46 -0
- package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -0
- package/fireflysite/assets/markdown/reference/EmittedJavascript.md +66 -0
- package/fireflysite/assets/markdown/reference/Exceptions.md +101 -0
- package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +338 -0
- package/fireflysite/assets/markdown/reference/JavascriptInterop.md +134 -0
- package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -0
- package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -0
- package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -0
- package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -0
- package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -0
- package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -0
- package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -0
- package/fireflysite/assets/markdown/{ControlFlow.md → scratch/ControlFlow.md} +136 -136
- package/fireflysite/assets/markdown/scratch/Toc.md +41 -0
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +828 -828
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +17 -17
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdout.txt +34 -34
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +593 -487
- package/lux/LuxEvent.ff +116 -116
- package/lux/Main.ff +123 -123
- package/lux/Main2.ff +143 -143
- package/lux/TestDry.ff +27 -0
- package/output/js/ff/compiler/Builder.mjs +47 -47
- package/output/js/ff/compiler/Dependencies.mjs +3 -3
- package/output/js/ff/compiler/Inference.mjs +2 -2
- package/output/js/ff/compiler/JsEmitter.mjs +18 -72
- package/output/js/ff/compiler/Main.mjs +4 -4
- package/output/js/ff/compiler/ModuleCache.mjs +4 -4
- package/output/js/ff/core/Array.mjs +59 -59
- package/output/js/ff/core/Atomic.mjs +36 -36
- package/output/js/ff/core/BrowserSystem.mjs +11 -11
- package/output/js/ff/core/BuildSystem.mjs +30 -30
- package/output/js/ff/core/Crypto.mjs +40 -40
- package/output/js/ff/core/Float.mjs +50 -0
- package/output/js/ff/core/HttpClient.mjs +56 -56
- package/output/js/ff/core/Json.mjs +147 -147
- package/output/js/ff/core/List.mjs +50 -50
- package/output/js/ff/core/Lock.mjs +97 -97
- package/output/js/ff/core/NodeSystem.mjs +87 -87
- package/output/js/ff/core/Ordering.mjs +8 -8
- package/output/js/ff/core/Path.mjs +231 -231
- package/output/js/ff/core/Random.mjs +56 -56
- package/output/js/ff/core/Task.mjs +71 -39
- package/output/js/ff/core/Try.mjs +98 -4
- package/package.json +1 -1
- package/postgresql/Pg.ff +1 -1
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +70 -70
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +94 -94
- package/unsafejs/UnsafeJs.ff +19 -19
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
- package/webserver/.firefly/include/package-lock.json +22 -22
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +685 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +131 -131
- package/fireflysite/GuideAll.ff +0 -21
- package/fireflysite/GuideBaseTypes.ff +0 -168
- package/fireflysite/GuideControlFlow.ff +0 -212
- package/fireflysite/assets/markdown/Example.md +0 -78
- /package/fireflysite/assets/{NotoSansMono-Regular.ttf → font/NotoSansMono-Regular.ttf} +0 -0
- /package/fireflysite/assets/{NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf → font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf} +0 -0
- /package/fireflysite/assets/{autocomplete-small.png → image/autocomplete-small.png} +0 -0
- /package/fireflysite/assets/{autocomplete.png → image/autocomplete.png} +0 -0
- /package/fireflysite/assets/{edit-time-error.png → image/edit-time-error.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-notext.png → image/firefly-logo-notext.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-yellow.png → image/firefly-logo-yellow.png} +0 -0
|
@@ -110,36 +110,36 @@ return ff_core_Random.newFromFloat_(seed_)
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export function newFromBuffer_(buffer_) {
|
|
113
|
-
|
|
114
|
-
var n = 0xefc8249d;
|
|
115
|
-
function mash(data) {
|
|
116
|
-
for(var i = 0; i < data.byteLength; i++) {
|
|
117
|
-
n += data.getUint8(i);
|
|
118
|
-
var h = 0.02519603282416938 * n;
|
|
119
|
-
n = h >>> 0;
|
|
120
|
-
h -= n;
|
|
121
|
-
h *= n;
|
|
122
|
-
n = h >>> 0;
|
|
123
|
-
h -= n;
|
|
124
|
-
n += h * 0x100000000; // 2^32
|
|
125
|
-
}
|
|
126
|
-
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
127
|
-
}
|
|
128
|
-
var space = new DataView(new Uint8Array([32]).buffer);
|
|
129
|
-
var r = {
|
|
130
|
-
s0: mash(space),
|
|
131
|
-
s1: mash(space),
|
|
132
|
-
s2: mash(space),
|
|
133
|
-
c: 1,
|
|
134
|
-
spareGauss: NaN
|
|
135
|
-
};
|
|
136
|
-
r.s0 -= mash(buffer_);
|
|
137
|
-
if(r.s0 < 0) r.s0 += 1;
|
|
138
|
-
r.s1 -= mash(buffer_);
|
|
139
|
-
if(r.s1 < 0) r.s1 += 1;
|
|
140
|
-
r.s2 -= mash(buffer_);
|
|
141
|
-
if(r.s2 < 0) r.s2 += 1;
|
|
142
|
-
return r;
|
|
113
|
+
|
|
114
|
+
var n = 0xefc8249d;
|
|
115
|
+
function mash(data) {
|
|
116
|
+
for(var i = 0; i < data.byteLength; i++) {
|
|
117
|
+
n += data.getUint8(i);
|
|
118
|
+
var h = 0.02519603282416938 * n;
|
|
119
|
+
n = h >>> 0;
|
|
120
|
+
h -= n;
|
|
121
|
+
h *= n;
|
|
122
|
+
n = h >>> 0;
|
|
123
|
+
h -= n;
|
|
124
|
+
n += h * 0x100000000; // 2^32
|
|
125
|
+
}
|
|
126
|
+
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
127
|
+
}
|
|
128
|
+
var space = new DataView(new Uint8Array([32]).buffer);
|
|
129
|
+
var r = {
|
|
130
|
+
s0: mash(space),
|
|
131
|
+
s1: mash(space),
|
|
132
|
+
s2: mash(space),
|
|
133
|
+
c: 1,
|
|
134
|
+
spareGauss: NaN
|
|
135
|
+
};
|
|
136
|
+
r.s0 -= mash(buffer_);
|
|
137
|
+
if(r.s0 < 0) r.s0 += 1;
|
|
138
|
+
r.s1 -= mash(buffer_);
|
|
139
|
+
if(r.s1 < 0) r.s1 += 1;
|
|
140
|
+
r.s2 -= mash(buffer_);
|
|
141
|
+
if(r.s2 < 0) r.s2 += 1;
|
|
142
|
+
return r;
|
|
143
143
|
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -162,24 +162,24 @@ throw new Error('Function newFromBuffer is missing on this target in async conte
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
export function Random_copy(self_) {
|
|
165
|
-
|
|
166
|
-
return {...self_};
|
|
165
|
+
|
|
166
|
+
return {...self_};
|
|
167
167
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export function Random_nextInt(self_, from_, until_) {
|
|
171
|
-
|
|
172
|
-
return Random_nextFloat(self_, from_, until_) | 0;
|
|
171
|
+
|
|
172
|
+
return Random_nextFloat(self_, from_, until_) | 0;
|
|
173
173
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
export function Random_nextFloat(self_, from_, until_) {
|
|
177
|
-
|
|
178
|
-
var t = 2091639 * self_.s0 + self_.c * 2.3283064365386963e-10; // 2^-32
|
|
179
|
-
self_.s0 = self_.s1;
|
|
180
|
-
self_.s1 = self_.s2;
|
|
181
|
-
var uniform = self_.s2 = t - (self_.c = t | 0);
|
|
182
|
-
return from_ + uniform * (until_ - from_);
|
|
177
|
+
|
|
178
|
+
var t = 2091639 * self_.s0 + self_.c * 2.3283064365386963e-10; // 2^-32
|
|
179
|
+
self_.s0 = self_.s1;
|
|
180
|
+
self_.s1 = self_.s2;
|
|
181
|
+
var uniform = self_.s2 = t - (self_.c = t | 0);
|
|
182
|
+
return from_ + uniform * (until_ - from_);
|
|
183
183
|
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -194,22 +194,22 @@ ff_core_Buffer.Buffer_setUint8(buffer_, i_, ff_core_Random.Random_nextInt(self_,
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export function Random_nextGauss(self_, mean_, standardDeviation_) {
|
|
197
|
-
|
|
198
|
-
if(!isNaN(self_.spareGauss)) {
|
|
199
|
-
const result = self_.spareGauss * standardDeviation_ + mean_;
|
|
200
|
-
self_.spareGauss = NaN;
|
|
201
|
-
return result;
|
|
202
|
-
} else {
|
|
203
|
-
let u = 0.5, v = 0.5, s = 0.5;
|
|
204
|
-
do {
|
|
205
|
-
u = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
206
|
-
v = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
207
|
-
s = u * u + v * v;
|
|
208
|
-
} while(s >= 1 || s == 0);
|
|
209
|
-
s = Math.sqrt(-2.0 * Math.log(s) / s);
|
|
210
|
-
self_.spareGauss = v * s;
|
|
211
|
-
return mean_ + standardDeviation_ * u * s;
|
|
212
|
-
}
|
|
197
|
+
|
|
198
|
+
if(!isNaN(self_.spareGauss)) {
|
|
199
|
+
const result = self_.spareGauss * standardDeviation_ + mean_;
|
|
200
|
+
self_.spareGauss = NaN;
|
|
201
|
+
return result;
|
|
202
|
+
} else {
|
|
203
|
+
let u = 0.5, v = 0.5, s = 0.5;
|
|
204
|
+
do {
|
|
205
|
+
u = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
206
|
+
v = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
207
|
+
s = u * u + v * v;
|
|
208
|
+
} while(s >= 1 || s == 0);
|
|
209
|
+
s = Math.sqrt(-2.0 * Math.log(s) / s);
|
|
210
|
+
self_.spareGauss = v * s;
|
|
211
|
+
return mean_ + standardDeviation_ * u * s;
|
|
212
|
+
}
|
|
213
213
|
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -100,39 +100,39 @@ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
export function Task_spawn(self_, body_) {
|
|
103
|
-
|
|
104
|
-
ff_core_Task.Task_throwIfAborted(self_)
|
|
105
|
-
const task = {controller: new AbortController(), subtasks: new Set(), started: performance.now() * 0.001}
|
|
106
|
-
self_.subtasks.add(task)
|
|
107
|
-
task.promise = Promise.resolve(task).then(async () => {
|
|
108
|
-
try {
|
|
109
|
-
await body_(task, task)
|
|
110
|
-
} catch(e) {
|
|
111
|
-
await ff_core_Task.Task_abort$(self_)
|
|
112
|
-
throw e
|
|
113
|
-
} finally {
|
|
114
|
-
for(const subtask of task.subtasks) subtask.controller.abort()
|
|
115
|
-
await Promise.allSettled([...task.subtasks].map(subtask => subtask.promise))
|
|
116
|
-
self_.subtasks.delete(task)
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
return task
|
|
103
|
+
|
|
104
|
+
ff_core_Task.Task_throwIfAborted(self_)
|
|
105
|
+
const task = {controller: new AbortController(), subtasks: new Set(), started: performance.now() * 0.001}
|
|
106
|
+
self_.subtasks.add(task)
|
|
107
|
+
task.promise = Promise.resolve(task).then(async () => {
|
|
108
|
+
try {
|
|
109
|
+
await body_(task, task)
|
|
110
|
+
} catch(e) {
|
|
111
|
+
await ff_core_Task.Task_abort$(self_)
|
|
112
|
+
throw e
|
|
113
|
+
} finally {
|
|
114
|
+
for(const subtask of task.subtasks) subtask.controller.abort()
|
|
115
|
+
await Promise.allSettled([...task.subtasks].map(subtask => subtask.promise))
|
|
116
|
+
self_.subtasks.delete(task)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
return task
|
|
120
120
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export function Task_throwIfAborted(self_) {
|
|
124
|
-
|
|
125
|
-
if(self_.controller.signal.aborted) {
|
|
126
|
-
const signal = self_.controller.signal
|
|
127
|
-
self_.controller = new AbortController()
|
|
128
|
-
signal.throwIfAborted()
|
|
129
|
-
}
|
|
124
|
+
|
|
125
|
+
if(self_.controller.signal.aborted) {
|
|
126
|
+
const signal = self_.controller.signal
|
|
127
|
+
self_.controller = new AbortController()
|
|
128
|
+
signal.throwIfAborted()
|
|
129
|
+
}
|
|
130
130
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export function Task_abort(self_) {
|
|
134
|
-
|
|
135
|
-
self_.controller.abort()
|
|
134
|
+
|
|
135
|
+
self_.controller.abort()
|
|
136
136
|
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -161,20 +161,20 @@ return ff_core_Pair.Pair(result_, duration_)
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export async function Task_spawn$(self_, body_, $task) {
|
|
164
|
-
|
|
165
|
-
return ff_core_Task.Task_spawn(self_, body_)
|
|
164
|
+
|
|
165
|
+
return ff_core_Task.Task_spawn(self_, body_)
|
|
166
166
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export async function Task_throwIfAborted$(self_, $task) {
|
|
170
|
-
|
|
171
|
-
ff_core_Task.Task_throwIfAborted(self_)
|
|
170
|
+
|
|
171
|
+
ff_core_Task.Task_throwIfAborted(self_)
|
|
172
172
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export async function Task_abort$(self_, $task) {
|
|
176
|
-
|
|
177
|
-
self_.controller.abort()
|
|
176
|
+
|
|
177
|
+
self_.controller.abort()
|
|
178
178
|
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -210,12 +210,28 @@ ff_core_Channel.ChannelAction_timeout(ff_core_Channel.readOr_(ff_core_Task.Task_
|
|
|
210
210
|
}))
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
export function Task_mapList(self_, list_, body_) {
|
|
214
|
+
return ff_core_Task.Task_all(self_, ff_core_List.List_map(list_, ((x_) => {
|
|
215
|
+
return (() => {
|
|
216
|
+
return body_(x_)
|
|
217
|
+
})
|
|
218
|
+
})))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function Task_raceList(self_, list_, body_) {
|
|
222
|
+
return ff_core_Task.Task_race(self_, ff_core_List.List_map(list_, ((x_) => {
|
|
223
|
+
return (() => {
|
|
224
|
+
return body_(x_)
|
|
225
|
+
})
|
|
226
|
+
})))
|
|
227
|
+
}
|
|
228
|
+
|
|
213
229
|
export function Task_all(self_, tasks_) {
|
|
214
230
|
const successChannel_ = ff_core_Task.Task_channel(self_, 0);
|
|
215
231
|
const failureChannel_ = ff_core_Task.Task_channel(self_, 0);
|
|
216
232
|
ff_core_Task.Task_spawn(self_, ((t_) => {
|
|
217
233
|
const channel_ = ff_core_Task.Task_channel(t_, 0);
|
|
218
|
-
ff_core_Try.
|
|
234
|
+
ff_core_Try.Try_catchAny(ff_core_Core.try_((() => {
|
|
219
235
|
ff_core_List.List_each(ff_core_List.List_pairs(tasks_), ((_1) => {
|
|
220
236
|
{
|
|
221
237
|
const i_ = _1.first_;
|
|
@@ -237,7 +253,7 @@ ff_core_Channel.Channel_write(successChannel_, result_)
|
|
|
237
253
|
})), ((error_) => {
|
|
238
254
|
ff_core_Channel.Channel_write(failureChannel_, error_);
|
|
239
255
|
ff_core_Task.Task_abort(t_)
|
|
240
|
-
}))
|
|
256
|
+
}))
|
|
241
257
|
}));
|
|
242
258
|
return ff_core_Channel.ChannelAction_wait(ff_core_Channel.ChannelAction_readOr(ff_core_Channel.readOr_(successChannel_, ((_w1) => {
|
|
243
259
|
return _w1
|
|
@@ -252,14 +268,14 @@ const failureChannel_ = ff_core_Task.Task_channel(self_, 0);
|
|
|
252
268
|
let live_ = ff_core_List.List_size(tasks_);
|
|
253
269
|
const started_ = ff_core_List.List_map(tasks_, ((task_) => {
|
|
254
270
|
return ff_core_Task.Task_spawn(self_, ((_) => {
|
|
255
|
-
ff_core_Try.
|
|
271
|
+
ff_core_Try.Try_catchAny(ff_core_Core.try_((() => {
|
|
256
272
|
ff_core_Channel.Channel_write(successChannel_, task_())
|
|
257
273
|
})), ((e_) => {
|
|
258
274
|
live_ -= 1;
|
|
259
275
|
if((live_ === 0)) {
|
|
260
276
|
ff_core_Channel.Channel_write(failureChannel_, e_)
|
|
261
277
|
}
|
|
262
|
-
}))
|
|
278
|
+
}))
|
|
263
279
|
}))
|
|
264
280
|
}));
|
|
265
281
|
try {
|
|
@@ -283,12 +299,28 @@ export async function Task_sleep$(self_, duration_, $task) {
|
|
|
283
299
|
}), $task))
|
|
284
300
|
}
|
|
285
301
|
|
|
302
|
+
export async function Task_mapList$(self_, list_, body_, $task) {
|
|
303
|
+
return (await ff_core_Task.Task_all$(self_, ff_core_List.List_map(list_, ((x_) => {
|
|
304
|
+
return (async ($task) => {
|
|
305
|
+
return (await body_(x_, $task))
|
|
306
|
+
})
|
|
307
|
+
})), $task))
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export async function Task_raceList$(self_, list_, body_, $task) {
|
|
311
|
+
return (await ff_core_Task.Task_race$(self_, ff_core_List.List_map(list_, ((x_) => {
|
|
312
|
+
return (async ($task) => {
|
|
313
|
+
return (await body_(x_, $task))
|
|
314
|
+
})
|
|
315
|
+
})), $task))
|
|
316
|
+
}
|
|
317
|
+
|
|
286
318
|
export async function Task_all$(self_, tasks_, $task) {
|
|
287
319
|
const successChannel_ = (await ff_core_Task.Task_channel$(self_, 0, $task));
|
|
288
320
|
const failureChannel_ = (await ff_core_Task.Task_channel$(self_, 0, $task));
|
|
289
321
|
(await ff_core_Task.Task_spawn$(self_, (async (t_, $task) => {
|
|
290
322
|
const channel_ = (await ff_core_Task.Task_channel$(t_, 0, $task));
|
|
291
|
-
|
|
323
|
+
(await ff_core_Try.Try_catchAny$((await ff_core_Core.try_$((async ($task) => {
|
|
292
324
|
(await ff_core_List.List_each$(ff_core_List.List_pairs(tasks_), (async (_1, $task) => {
|
|
293
325
|
{
|
|
294
326
|
const i_ = _1.first_;
|
|
@@ -310,7 +342,7 @@ return _w1.second_
|
|
|
310
342
|
}), $task)), (async (error_, $task) => {
|
|
311
343
|
(await ff_core_Channel.Channel_write$(failureChannel_, error_, $task));
|
|
312
344
|
(await ff_core_Task.Task_abort$(t_, $task))
|
|
313
|
-
}), $task))
|
|
345
|
+
}), $task))
|
|
314
346
|
}), $task));
|
|
315
347
|
return (await ff_core_Channel.ChannelAction_wait$((await ff_core_Channel.ChannelAction_readOr$((await ff_core_Channel.readOr_$(successChannel_, (async (_w1, $task) => {
|
|
316
348
|
return _w1
|
|
@@ -325,14 +357,14 @@ const failureChannel_ = (await ff_core_Task.Task_channel$(self_, 0, $task));
|
|
|
325
357
|
let live_ = ff_core_List.List_size(tasks_);
|
|
326
358
|
const started_ = (await ff_core_List.List_map$(tasks_, (async (task_, $task) => {
|
|
327
359
|
return (await ff_core_Task.Task_spawn$(self_, (async (_, $task) => {
|
|
328
|
-
|
|
360
|
+
(await ff_core_Try.Try_catchAny$((await ff_core_Core.try_$((async ($task) => {
|
|
329
361
|
(await ff_core_Channel.Channel_write$(successChannel_, (await task_($task)), $task))
|
|
330
362
|
}), $task)), (async (e_, $task) => {
|
|
331
363
|
live_ -= 1;
|
|
332
364
|
if((live_ === 0)) {
|
|
333
365
|
(await ff_core_Channel.Channel_write$(failureChannel_, e_, $task))
|
|
334
366
|
}
|
|
335
|
-
}), $task))
|
|
367
|
+
}), $task))
|
|
336
368
|
}), $task))
|
|
337
369
|
}), $task));
|
|
338
370
|
try {
|
|
@@ -139,6 +139,53 @@ return ff_core_Any.fromAny_(any_, ff_core_Any_HasAnyTag$E)
|
|
|
139
139
|
}));
|
|
140
140
|
if(_guard1.Some) {
|
|
141
141
|
const e_ = _guard1.value_;
|
|
142
|
+
return body_(e_, error_)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
{
|
|
146
|
+
return ff_core_Try.Try_grab(self_)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function Try_catchAny(self_, body_) {
|
|
152
|
+
{
|
|
153
|
+
const _1 = self_;
|
|
154
|
+
if(_1.Failure) {
|
|
155
|
+
const error_ = _1.error_;
|
|
156
|
+
return body_(error_)
|
|
157
|
+
}
|
|
158
|
+
{
|
|
159
|
+
return ff_core_Try.Try_grab(self_)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function Try_finally(self_, body_) {
|
|
165
|
+
{
|
|
166
|
+
const _1 = self_;
|
|
167
|
+
if(_1.Success) {
|
|
168
|
+
const value_ = _1.value_;
|
|
169
|
+
body_();
|
|
170
|
+
return value_
|
|
171
|
+
}
|
|
172
|
+
if(_1.Failure) {
|
|
173
|
+
body_();
|
|
174
|
+
return ff_core_Try.Try_grab(self_)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function Try_tryCatch(self_, body_, ff_core_Any_HasAnyTag$E) {
|
|
180
|
+
{
|
|
181
|
+
const _1 = self_;
|
|
182
|
+
if(_1.Failure) {
|
|
183
|
+
const error_ = _1.error_;
|
|
184
|
+
const _guard1 = ff_core_Option.Option_flatMap(ff_core_Error.Error_exception(error_), ((any_) => {
|
|
185
|
+
return ff_core_Any.fromAny_(any_, ff_core_Any_HasAnyTag$E)
|
|
186
|
+
}));
|
|
187
|
+
if(_guard1.Some) {
|
|
188
|
+
const e_ = _guard1.value_;
|
|
142
189
|
return ff_core_Core.try_((() => {
|
|
143
190
|
return body_(e_, error_)
|
|
144
191
|
}))
|
|
@@ -151,7 +198,7 @@ return self_
|
|
|
151
198
|
}
|
|
152
199
|
}
|
|
153
200
|
|
|
154
|
-
export function
|
|
201
|
+
export function Try_tryCatchAny(self_, body_) {
|
|
155
202
|
{
|
|
156
203
|
const _1 = self_;
|
|
157
204
|
if(_1.Failure) {
|
|
@@ -167,7 +214,7 @@ return self_
|
|
|
167
214
|
}
|
|
168
215
|
}
|
|
169
216
|
|
|
170
|
-
export function
|
|
217
|
+
export function Try_tryFinally(self_, body_) {
|
|
171
218
|
{
|
|
172
219
|
const _1 = self_;
|
|
173
220
|
if(_1.Success) {
|
|
@@ -267,6 +314,53 @@ return ff_core_Any.fromAny_(any_, ff_core_Any_HasAnyTag$E)
|
|
|
267
314
|
}));
|
|
268
315
|
if(_guard1.Some) {
|
|
269
316
|
const e_ = _guard1.value_;
|
|
317
|
+
return (await body_(e_, error_, $task))
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
{
|
|
321
|
+
return ff_core_Try.Try_grab(self_)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export async function Try_catchAny$(self_, body_, $task) {
|
|
327
|
+
{
|
|
328
|
+
const _1 = self_;
|
|
329
|
+
if(_1.Failure) {
|
|
330
|
+
const error_ = _1.error_;
|
|
331
|
+
return (await body_(error_, $task))
|
|
332
|
+
}
|
|
333
|
+
{
|
|
334
|
+
return ff_core_Try.Try_grab(self_)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export async function Try_finally$(self_, body_, $task) {
|
|
340
|
+
{
|
|
341
|
+
const _1 = self_;
|
|
342
|
+
if(_1.Success) {
|
|
343
|
+
const value_ = _1.value_;
|
|
344
|
+
(await body_($task));
|
|
345
|
+
return value_
|
|
346
|
+
}
|
|
347
|
+
if(_1.Failure) {
|
|
348
|
+
(await body_($task));
|
|
349
|
+
return ff_core_Try.Try_grab(self_)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export async function Try_tryCatch$(self_, body_, ff_core_Any_HasAnyTag$E, $task) {
|
|
355
|
+
{
|
|
356
|
+
const _1 = self_;
|
|
357
|
+
if(_1.Failure) {
|
|
358
|
+
const error_ = _1.error_;
|
|
359
|
+
const _guard1 = ff_core_Option.Option_flatMap(ff_core_Error.Error_exception(error_), ((any_) => {
|
|
360
|
+
return ff_core_Any.fromAny_(any_, ff_core_Any_HasAnyTag$E)
|
|
361
|
+
}));
|
|
362
|
+
if(_guard1.Some) {
|
|
363
|
+
const e_ = _guard1.value_;
|
|
270
364
|
return (await ff_core_Core.try_$((async ($task) => {
|
|
271
365
|
return (await body_(e_, error_, $task))
|
|
272
366
|
}), $task))
|
|
@@ -279,7 +373,7 @@ return self_
|
|
|
279
373
|
}
|
|
280
374
|
}
|
|
281
375
|
|
|
282
|
-
export async function
|
|
376
|
+
export async function Try_tryCatchAny$(self_, body_, $task) {
|
|
283
377
|
{
|
|
284
378
|
const _1 = self_;
|
|
285
379
|
if(_1.Failure) {
|
|
@@ -295,7 +389,7 @@ return self_
|
|
|
295
389
|
}
|
|
296
390
|
}
|
|
297
391
|
|
|
298
|
-
export async function
|
|
392
|
+
export async function Try_tryFinally$(self_, body_, $task) {
|
|
299
393
|
{
|
|
300
394
|
const _1 = self_;
|
|
301
395
|
if(_1.Success) {
|
package/package.json
CHANGED
package/postgresql/Pg.ff
CHANGED
package/rpc/.firefly/package.ff
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
package ff:rpc:0.0.0
|
|
1
|
+
package ff:rpc:0.0.0
|
package/rpc/Rpc.ff
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
trait I: Rpc[O] {}
|
|
2
|
-
|
|
3
|
-
capability RpcServer[I, O, C](
|
|
4
|
-
handlers: StringMap[(C, I) => O]
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
newServer[I, O, C](): RpcServer[I, O, C] {
|
|
8
|
-
RpcServer(StringMap.new())
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
extend self[I, O, C]: RpcServer[I, O, C] {
|
|
12
|
-
handle(name: String, context: C, input: I): Option[O] {
|
|
13
|
-
self.handlers.get(name).map {handler =>
|
|
14
|
-
handler(context, input)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
addCustom(
|
|
19
|
-
handler: (C, I) => O
|
|
20
|
-
): Unit {
|
|
21
|
-
let name = "TODO"
|
|
22
|
-
self.handlers.set(name) {context, input =>
|
|
23
|
-
handler(context, input)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
extend self[C]: RpcServer[Buffer, Buffer, C] {
|
|
29
|
-
add[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
30
|
-
handler: (C, I) => O
|
|
31
|
-
): Unit {
|
|
32
|
-
let name = Any.anyTag[I]().show()
|
|
33
|
-
self.handlers.set(name) {context, message =>
|
|
34
|
-
let input = Serializable.deserialize(message)
|
|
35
|
-
let output = handler(context, input)
|
|
36
|
-
Serializable.serialize(output)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
capability RpcClient(
|
|
42
|
-
binaryCall: (String, Buffer) => Buffer
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
extend self: RpcClient {
|
|
46
|
-
call[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
47
|
-
message: I
|
|
48
|
-
): O {
|
|
49
|
-
let name = Any.anyTag[I]().show()
|
|
50
|
-
let input = Serializable.serialize(message)
|
|
51
|
-
let response = self.binaryCall(name, input)
|
|
52
|
-
Serializable.deserialize(response)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
newClient(
|
|
57
|
-
httpClient: HttpClient
|
|
58
|
-
prefix: String
|
|
59
|
-
method: String = "POST"
|
|
60
|
-
): RpcClient {
|
|
61
|
-
RpcClient {name, buffer =>
|
|
62
|
-
httpClient.fetch(
|
|
63
|
-
method = method
|
|
64
|
-
url = prefix + name
|
|
65
|
-
headers = []
|
|
66
|
-
payload = Some(buffer)
|
|
67
|
-
options = FetchOptions()
|
|
68
|
-
) {_.readBuffer()}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
trait I: Rpc[O] {}
|
|
2
|
+
|
|
3
|
+
capability RpcServer[I, O, C](
|
|
4
|
+
handlers: StringMap[(C, I) => O]
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
newServer[I, O, C](): RpcServer[I, O, C] {
|
|
8
|
+
RpcServer(StringMap.new())
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
extend self[I, O, C]: RpcServer[I, O, C] {
|
|
12
|
+
handle(name: String, context: C, input: I): Option[O] {
|
|
13
|
+
self.handlers.get(name).map {handler =>
|
|
14
|
+
handler(context, input)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addCustom(
|
|
19
|
+
handler: (C, I) => O
|
|
20
|
+
): Unit {
|
|
21
|
+
let name = "TODO"
|
|
22
|
+
self.handlers.set(name) {context, input =>
|
|
23
|
+
handler(context, input)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
extend self[C]: RpcServer[Buffer, Buffer, C] {
|
|
29
|
+
add[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
30
|
+
handler: (C, I) => O
|
|
31
|
+
): Unit {
|
|
32
|
+
let name = Any.anyTag[I]().show()
|
|
33
|
+
self.handlers.set(name) {context, message =>
|
|
34
|
+
let input = Serializable.deserialize(message)
|
|
35
|
+
let output = handler(context, input)
|
|
36
|
+
Serializable.serialize(output)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
capability RpcClient(
|
|
42
|
+
binaryCall: (String, Buffer) => Buffer
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
extend self: RpcClient {
|
|
46
|
+
call[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
47
|
+
message: I
|
|
48
|
+
): O {
|
|
49
|
+
let name = Any.anyTag[I]().show()
|
|
50
|
+
let input = Serializable.serialize(message)
|
|
51
|
+
let response = self.binaryCall(name, input)
|
|
52
|
+
Serializable.deserialize(response)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
newClient(
|
|
57
|
+
httpClient: HttpClient
|
|
58
|
+
prefix: String
|
|
59
|
+
method: String = "POST"
|
|
60
|
+
): RpcClient {
|
|
61
|
+
RpcClient {name, buffer =>
|
|
62
|
+
httpClient.fetch(
|
|
63
|
+
method = method
|
|
64
|
+
url = prefix + name
|
|
65
|
+
headers = []
|
|
66
|
+
payload = Some(buffer)
|
|
67
|
+
options = FetchOptions()
|
|
68
|
+
) {_.readBuffer()}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/s3/.firefly/package.ff
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
package ff:s3:0.0.0
|
|
1
|
+
package ff:s3:0.0.0
|