effect 2.4.4 → 2.4.6
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/dist/cjs/Channel.js +10 -2
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Effect.js +26 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/internal/cause.js +2 -2
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/channel.js +75 -1
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +0 -2
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +148 -126
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +29 -29
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer.js +2 -2
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/runtime.js +4 -6
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/stm/core.js +36 -36
- package/dist/cjs/internal/stm/core.js.map +1 -1
- package/dist/cjs/internal/stream.js +2 -73
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Channel.d.ts +8 -0
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +38 -2
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/ReadonlyArray.d.ts +2 -2
- package/dist/dts/ReadonlyArray.d.ts.map +1 -1
- package/dist/esm/Channel.js +8 -0
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Effect.js +22 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/internal/cause.js +2 -2
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/channel.js +73 -0
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js +0 -2
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +144 -123
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +29 -29
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer.js +2 -2
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/runtime.js +4 -6
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/stm/core.js +36 -36
- package/dist/esm/internal/stm/core.js.map +1 -1
- package/dist/esm/internal/stream.js +2 -73
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Channel.ts +17 -0
- package/src/Effect.ts +45 -2
- package/src/Exit.ts +2 -2
- package/src/ReadonlyArray.ts +2 -2
- package/src/internal/cause.ts +2 -2
- package/src/internal/channel.ts +92 -0
- package/src/internal/core-effect.ts +0 -2
- package/src/internal/core.ts +167 -134
- package/src/internal/fiberRuntime.ts +30 -30
- package/src/internal/layer.ts +4 -4
- package/src/internal/runtime.ts +4 -6
- package/src/internal/stm/core.ts +49 -49
- package/src/internal/stream.ts +2 -82
- package/src/internal/version.ts +1 -1
- package/dist/cjs/internal/internalize.js +0 -15
- package/dist/cjs/internal/internalize.js.map +0 -1
- package/dist/dts/internal/internalize.d.ts +0 -2
- package/dist/dts/internal/internalize.d.ts.map +0 -1
- package/dist/esm/internal/internalize.js +0 -8
- package/dist/esm/internal/internalize.js.map +0 -1
- package/src/internal/internalize.ts +0 -5
|
@@ -20,7 +20,6 @@ import * as internalCause from "./cause.js";
|
|
|
20
20
|
import * as deferred from "./deferred.js";
|
|
21
21
|
import * as internalDiffer from "./differ.js";
|
|
22
22
|
import { effectVariance, StructuralCommitPrototype } from "./effectable.js";
|
|
23
|
-
import { internalize } from "./internalize.js";
|
|
24
23
|
import * as DeferredOpCodes from "./opCodes/deferred.js";
|
|
25
24
|
import * as OpCodes from "./opCodes/effect.js";
|
|
26
25
|
import * as _runtimeFlags from "./runtimeFlags.js";
|
|
@@ -45,8 +44,8 @@ export const makeEffectError = cause => ({
|
|
|
45
44
|
*/
|
|
46
45
|
export const blocked = (blockedRequests, _continue) => {
|
|
47
46
|
const effect = new EffectPrimitive("Blocked");
|
|
48
|
-
effect.
|
|
49
|
-
effect.
|
|
47
|
+
effect.effect_instruction_i0 = blockedRequests;
|
|
48
|
+
effect.effect_instruction_i1 = _continue;
|
|
50
49
|
return effect;
|
|
51
50
|
};
|
|
52
51
|
/**
|
|
@@ -54,7 +53,7 @@ export const blocked = (blockedRequests, _continue) => {
|
|
|
54
53
|
*/
|
|
55
54
|
export const runRequestBlock = blockedRequests => {
|
|
56
55
|
const effect = new EffectPrimitive("RunBlocked");
|
|
57
|
-
effect.
|
|
56
|
+
effect.effect_instruction_i0 = blockedRequests;
|
|
58
57
|
return effect;
|
|
59
58
|
};
|
|
60
59
|
/** @internal */
|
|
@@ -72,9 +71,9 @@ export class RevertFlags {
|
|
|
72
71
|
/** @internal */
|
|
73
72
|
class EffectPrimitive {
|
|
74
73
|
_op;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
effect_instruction_i0 = undefined;
|
|
75
|
+
effect_instruction_i1 = undefined;
|
|
76
|
+
effect_instruction_i2 = undefined;
|
|
78
77
|
trace = undefined;
|
|
79
78
|
[EffectTypeId] = effectVariance;
|
|
80
79
|
constructor(_op) {
|
|
@@ -93,9 +92,9 @@ class EffectPrimitive {
|
|
|
93
92
|
return {
|
|
94
93
|
_id: "Effect",
|
|
95
94
|
_op: this._op,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
effect_instruction_i0: toJSON(this.effect_instruction_i0),
|
|
96
|
+
effect_instruction_i1: toJSON(this.effect_instruction_i1),
|
|
97
|
+
effect_instruction_i2: toJSON(this.effect_instruction_i2)
|
|
99
98
|
};
|
|
100
99
|
}
|
|
101
100
|
toString() {
|
|
@@ -108,9 +107,9 @@ class EffectPrimitive {
|
|
|
108
107
|
/** @internal */
|
|
109
108
|
class EffectPrimitiveFailure {
|
|
110
109
|
_op;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
effect_instruction_i0 = undefined;
|
|
111
|
+
effect_instruction_i1 = undefined;
|
|
112
|
+
effect_instruction_i2 = undefined;
|
|
114
113
|
trace = undefined;
|
|
115
114
|
[EffectTypeId] = effectVariance;
|
|
116
115
|
constructor(_op) {
|
|
@@ -125,7 +124,7 @@ class EffectPrimitiveFailure {
|
|
|
125
124
|
return Hash.cached(this, Hash.random(this));
|
|
126
125
|
}
|
|
127
126
|
get cause() {
|
|
128
|
-
return this.
|
|
127
|
+
return this.effect_instruction_i0;
|
|
129
128
|
}
|
|
130
129
|
pipe() {
|
|
131
130
|
return pipeArguments(this, arguments);
|
|
@@ -147,9 +146,9 @@ class EffectPrimitiveFailure {
|
|
|
147
146
|
/** @internal */
|
|
148
147
|
class EffectPrimitiveSuccess {
|
|
149
148
|
_op;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
effect_instruction_i0 = undefined;
|
|
150
|
+
effect_instruction_i1 = undefined;
|
|
151
|
+
effect_instruction_i2 = undefined;
|
|
153
152
|
trace = undefined;
|
|
154
153
|
[EffectTypeId] = effectVariance;
|
|
155
154
|
constructor(_op) {
|
|
@@ -164,7 +163,7 @@ class EffectPrimitiveSuccess {
|
|
|
164
163
|
return Hash.cached(this, Hash.random(this));
|
|
165
164
|
}
|
|
166
165
|
get value() {
|
|
167
|
-
return this.
|
|
166
|
+
return this.effect_instruction_i0;
|
|
168
167
|
}
|
|
169
168
|
pipe() {
|
|
170
169
|
return pipeArguments(this, arguments);
|
|
@@ -187,9 +186,8 @@ class EffectPrimitiveSuccess {
|
|
|
187
186
|
export const isEffect = u => hasProperty(u, EffectTypeId);
|
|
188
187
|
/* @internal */
|
|
189
188
|
export const withFiberRuntime = withRuntime => {
|
|
190
|
-
internalize(withRuntime);
|
|
191
189
|
const effect = new EffectPrimitive(OpCodes.OP_WITH_RUNTIME);
|
|
192
|
-
effect.
|
|
190
|
+
effect.effect_instruction_i0 = withRuntime;
|
|
193
191
|
return effect;
|
|
194
192
|
};
|
|
195
193
|
/* @internal */
|
|
@@ -198,7 +196,7 @@ export const acquireUseRelease = /*#__PURE__*/dual(3, (acquire, use, release) =>
|
|
|
198
196
|
onFailure: cause => {
|
|
199
197
|
switch (exit._tag) {
|
|
200
198
|
case OpCodes.OP_FAILURE:
|
|
201
|
-
return failCause(internalCause.parallel(exit.
|
|
199
|
+
return failCause(internalCause.parallel(exit.effect_instruction_i0, cause));
|
|
202
200
|
case OpCodes.OP_SUCCESS:
|
|
203
201
|
return failCause(cause);
|
|
204
202
|
}
|
|
@@ -211,46 +209,78 @@ export const as = /*#__PURE__*/dual(2, (self, value) => flatMap(self, () => succ
|
|
|
211
209
|
/* @internal */
|
|
212
210
|
export const asUnit = self => as(self, void 0);
|
|
213
211
|
/* @internal */
|
|
214
|
-
export const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
export const custom = function () {
|
|
213
|
+
const wrapper = new EffectPrimitive(OpCodes.OP_COMMIT);
|
|
214
|
+
switch (arguments.length) {
|
|
215
|
+
case 2:
|
|
216
|
+
{
|
|
217
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
218
|
+
wrapper.commit = arguments[1];
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 3:
|
|
222
|
+
{
|
|
223
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
224
|
+
wrapper.effect_instruction_i1 = arguments[1];
|
|
225
|
+
wrapper.commit = arguments[2];
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 4:
|
|
229
|
+
{
|
|
230
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
231
|
+
wrapper.effect_instruction_i1 = arguments[1];
|
|
232
|
+
wrapper.effect_instruction_i2 = arguments[2];
|
|
233
|
+
wrapper.commit = arguments[3];
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
default:
|
|
237
|
+
{
|
|
238
|
+
throw new Error("Bug, you're not supposed to end up here");
|
|
239
|
+
}
|
|
224
240
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
241
|
+
return wrapper;
|
|
242
|
+
};
|
|
243
|
+
/* @internal */
|
|
244
|
+
export const async = (register, blockingOn = FiberId.none) => {
|
|
245
|
+
return custom(register, function () {
|
|
246
|
+
let backingResume = undefined;
|
|
247
|
+
let pendingEffect = undefined;
|
|
248
|
+
function proxyResume(effect) {
|
|
249
|
+
if (backingResume) {
|
|
250
|
+
backingResume(effect);
|
|
251
|
+
} else if (pendingEffect === undefined) {
|
|
252
|
+
pendingEffect = effect;
|
|
253
|
+
}
|
|
230
254
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
cancelerRef =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
controllerRef.
|
|
255
|
+
const effect = new EffectPrimitive(OpCodes.OP_ASYNC);
|
|
256
|
+
effect.effect_instruction_i0 = resume => {
|
|
257
|
+
backingResume = resume;
|
|
258
|
+
if (pendingEffect) {
|
|
259
|
+
resume(pendingEffect);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
effect.effect_instruction_i1 = blockingOn;
|
|
263
|
+
let cancelerRef = undefined;
|
|
264
|
+
let controllerRef = undefined;
|
|
265
|
+
if (this.effect_instruction_i0.length !== 1) {
|
|
266
|
+
controllerRef = new AbortController();
|
|
267
|
+
cancelerRef = this.effect_instruction_i0(proxyResume, controllerRef.signal);
|
|
268
|
+
} else {
|
|
269
|
+
cancelerRef = this.effect_instruction_i0(proxyResume);
|
|
244
270
|
}
|
|
245
|
-
return cancelerRef
|
|
246
|
-
|
|
247
|
-
|
|
271
|
+
return cancelerRef || controllerRef ? onInterrupt(effect, _ => {
|
|
272
|
+
if (controllerRef) {
|
|
273
|
+
controllerRef.abort();
|
|
274
|
+
}
|
|
275
|
+
return cancelerRef ?? unit;
|
|
276
|
+
}) : effect;
|
|
277
|
+
});
|
|
278
|
+
};
|
|
248
279
|
/* @internal */
|
|
249
280
|
export const catchAllCause = /*#__PURE__*/dual(2, (self, f) => {
|
|
250
281
|
const effect = new EffectPrimitive(OpCodes.OP_ON_FAILURE);
|
|
251
|
-
effect.
|
|
252
|
-
effect.
|
|
253
|
-
internalize(f);
|
|
282
|
+
effect.effect_instruction_i0 = self;
|
|
283
|
+
effect.effect_instruction_i1 = f;
|
|
254
284
|
return effect;
|
|
255
285
|
});
|
|
256
286
|
/* @internal */
|
|
@@ -334,7 +364,7 @@ export const failSync = evaluate => flatMap(sync(evaluate), fail);
|
|
|
334
364
|
/* @internal */
|
|
335
365
|
export const failCause = cause => {
|
|
336
366
|
const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE);
|
|
337
|
-
effect.
|
|
367
|
+
effect.effect_instruction_i0 = cause;
|
|
338
368
|
return effect;
|
|
339
369
|
};
|
|
340
370
|
/* @internal */
|
|
@@ -345,10 +375,9 @@ export const fiberId = /*#__PURE__*/withFiberRuntime(state => succeed(state.id()
|
|
|
345
375
|
export const fiberIdWith = f => withFiberRuntime(state => f(state.id()));
|
|
346
376
|
/* @internal */
|
|
347
377
|
export const flatMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
348
|
-
internalize(f);
|
|
349
378
|
const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS);
|
|
350
|
-
effect.
|
|
351
|
-
effect.
|
|
379
|
+
effect.effect_instruction_i0 = self;
|
|
380
|
+
effect.effect_instruction_i1 = f;
|
|
352
381
|
return effect;
|
|
353
382
|
});
|
|
354
383
|
/* @internal */
|
|
@@ -366,7 +395,7 @@ export const andThen = /*#__PURE__*/dual(2, (self, f) => flatMap(self, a => {
|
|
|
366
395
|
/* @internal */
|
|
367
396
|
export const step = self => {
|
|
368
397
|
const effect = new EffectPrimitive("OnStep");
|
|
369
|
-
effect.
|
|
398
|
+
effect.effect_instruction_i0 = self;
|
|
370
399
|
return effect;
|
|
371
400
|
};
|
|
372
401
|
/* @internal */
|
|
@@ -384,11 +413,9 @@ export const matchCause = /*#__PURE__*/dual(2, (self, options) => matchCauseEffe
|
|
|
384
413
|
/* @internal */
|
|
385
414
|
export const matchCauseEffect = /*#__PURE__*/dual(2, (self, options) => {
|
|
386
415
|
const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS_AND_FAILURE);
|
|
387
|
-
effect.
|
|
388
|
-
effect.
|
|
389
|
-
effect.
|
|
390
|
-
internalize(options.onFailure);
|
|
391
|
-
internalize(options.onSuccess);
|
|
416
|
+
effect.effect_instruction_i0 = self;
|
|
417
|
+
effect.effect_instruction_i1 = options.onFailure;
|
|
418
|
+
effect.effect_instruction_i2 = options.onSuccess;
|
|
392
419
|
return effect;
|
|
393
420
|
});
|
|
394
421
|
/* @internal */
|
|
@@ -443,18 +470,17 @@ export const interruptWith = fiberId => failCause(internalCause.interrupt(fiberI
|
|
|
443
470
|
/* @internal */
|
|
444
471
|
export const interruptible = self => {
|
|
445
472
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
446
|
-
effect.
|
|
447
|
-
effect.
|
|
473
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption);
|
|
474
|
+
effect.effect_instruction_i1 = () => self;
|
|
448
475
|
return effect;
|
|
449
476
|
};
|
|
450
477
|
/* @internal */
|
|
451
|
-
export const interruptibleMask = f => {
|
|
452
|
-
internalize(f);
|
|
478
|
+
export const interruptibleMask = f => custom(f, function () {
|
|
453
479
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
454
|
-
effect.
|
|
455
|
-
effect.
|
|
480
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption);
|
|
481
|
+
effect.effect_instruction_i1 = oldFlags => _runtimeFlags.interruption(oldFlags) ? this.effect_instruction_i0(interruptible) : this.effect_instruction_i0(uninterruptible);
|
|
456
482
|
return effect;
|
|
457
|
-
};
|
|
483
|
+
});
|
|
458
484
|
/* @internal */
|
|
459
485
|
export const intoDeferred = /*#__PURE__*/dual(2, (self, deferred) => uninterruptibleMask(restore => flatMap(exit(restore(self)), exit => deferredDone(deferred, exit))));
|
|
460
486
|
/* @internal */
|
|
@@ -482,7 +508,7 @@ export const mapError = /*#__PURE__*/dual(2, (self, f) => matchCauseEffect(self,
|
|
|
482
508
|
onSuccess: succeed
|
|
483
509
|
}));
|
|
484
510
|
/* @internal */
|
|
485
|
-
export const onError = /*#__PURE__*/dual(2, (self, cleanup) => onExit(self, exit => exitIsSuccess(exit) ? unit : cleanup(exit.
|
|
511
|
+
export const onError = /*#__PURE__*/dual(2, (self, cleanup) => onExit(self, exit => exitIsSuccess(exit) ? unit : cleanup(exit.effect_instruction_i0)));
|
|
486
512
|
/* @internal */
|
|
487
513
|
export const onExit = /*#__PURE__*/dual(2, (self, cleanup) => uninterruptibleMask(restore => matchCauseEffect(restore(self), {
|
|
488
514
|
onFailure: cause1 => {
|
|
@@ -530,16 +556,15 @@ export const runtimeFlags = /*#__PURE__*/withFiberRuntime((_, status) => succeed
|
|
|
530
556
|
/* @internal */
|
|
531
557
|
export const succeed = value => {
|
|
532
558
|
const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS);
|
|
533
|
-
effect.
|
|
559
|
+
effect.effect_instruction_i0 = value;
|
|
534
560
|
return effect;
|
|
535
561
|
};
|
|
536
562
|
/* @internal */
|
|
537
563
|
export const suspend = effect => flatMap(sync(effect), identity);
|
|
538
564
|
/* @internal */
|
|
539
565
|
export const sync = evaluate => {
|
|
540
|
-
internalize(evaluate);
|
|
541
566
|
const effect = new EffectPrimitive(OpCodes.OP_SYNC);
|
|
542
|
-
effect.
|
|
567
|
+
effect.effect_instruction_i0 = evaluate;
|
|
543
568
|
return effect;
|
|
544
569
|
};
|
|
545
570
|
/* @internal */
|
|
@@ -574,25 +599,24 @@ export const attemptOrElse = /*#__PURE__*/dual(3, (self, that, onSuccess) => mat
|
|
|
574
599
|
/* @internal */
|
|
575
600
|
export const uninterruptible = self => {
|
|
576
601
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
577
|
-
effect.
|
|
578
|
-
effect.
|
|
602
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption);
|
|
603
|
+
effect.effect_instruction_i1 = () => self;
|
|
579
604
|
return effect;
|
|
580
605
|
};
|
|
581
606
|
/* @internal */
|
|
582
|
-
export const uninterruptibleMask = f => {
|
|
583
|
-
internalize(f);
|
|
607
|
+
export const uninterruptibleMask = f => custom(f, function () {
|
|
584
608
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
585
|
-
effect.
|
|
586
|
-
effect.
|
|
609
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption);
|
|
610
|
+
effect.effect_instruction_i1 = oldFlags => _runtimeFlags.interruption(oldFlags) ? this.effect_instruction_i0(interruptible) : this.effect_instruction_i0(uninterruptible);
|
|
587
611
|
return effect;
|
|
588
|
-
};
|
|
612
|
+
});
|
|
589
613
|
/* @internal */
|
|
590
614
|
export const unit = /*#__PURE__*/succeed(void 0);
|
|
591
615
|
/* @internal */
|
|
592
616
|
export const updateRuntimeFlags = patch => {
|
|
593
617
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
594
|
-
effect.
|
|
595
|
-
effect.
|
|
618
|
+
effect.effect_instruction_i0 = patch;
|
|
619
|
+
effect.effect_instruction_i1 = void 0;
|
|
596
620
|
return effect;
|
|
597
621
|
};
|
|
598
622
|
/* @internal */
|
|
@@ -605,12 +629,9 @@ export const whenEffect = /*#__PURE__*/dual(2, (self, condition) => flatMap(cond
|
|
|
605
629
|
/* @internal */
|
|
606
630
|
export const whileLoop = options => {
|
|
607
631
|
const effect = new EffectPrimitive(OpCodes.OP_WHILE);
|
|
608
|
-
effect.
|
|
609
|
-
effect.
|
|
610
|
-
effect.
|
|
611
|
-
internalize(options.body);
|
|
612
|
-
internalize(options.step);
|
|
613
|
-
internalize(options.while);
|
|
632
|
+
effect.effect_instruction_i0 = options.while;
|
|
633
|
+
effect.effect_instruction_i1 = options.body;
|
|
634
|
+
effect.effect_instruction_i2 = options.step;
|
|
614
635
|
return effect;
|
|
615
636
|
};
|
|
616
637
|
/* @internal */
|
|
@@ -620,8 +641,8 @@ export const withRequestBatching = /*#__PURE__*/dual(2, (self, requestBatching)
|
|
|
620
641
|
/* @internal */
|
|
621
642
|
export const withRuntimeFlags = /*#__PURE__*/dual(2, (self, update) => {
|
|
622
643
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
623
|
-
effect.
|
|
624
|
-
effect.
|
|
644
|
+
effect.effect_instruction_i0 = update;
|
|
645
|
+
effect.effect_instruction_i1 = () => self;
|
|
625
646
|
return effect;
|
|
626
647
|
});
|
|
627
648
|
/** @internal */
|
|
@@ -1171,7 +1192,7 @@ export const exitIsSuccess = self => self._tag === "Success";
|
|
|
1171
1192
|
export const exitIsInterrupted = self => {
|
|
1172
1193
|
switch (self._tag) {
|
|
1173
1194
|
case OpCodes.OP_FAILURE:
|
|
1174
|
-
return internalCause.isInterrupted(self.
|
|
1195
|
+
return internalCause.isInterrupted(self.effect_instruction_i0);
|
|
1175
1196
|
case OpCodes.OP_SUCCESS:
|
|
1176
1197
|
return false;
|
|
1177
1198
|
}
|
|
@@ -1181,7 +1202,7 @@ export const exitAs = /*#__PURE__*/dual(2, (self, value) => {
|
|
|
1181
1202
|
switch (self._tag) {
|
|
1182
1203
|
case OpCodes.OP_FAILURE:
|
|
1183
1204
|
{
|
|
1184
|
-
return exitFailCause(self.
|
|
1205
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1185
1206
|
}
|
|
1186
1207
|
case OpCodes.OP_SUCCESS:
|
|
1187
1208
|
{
|
|
@@ -1195,7 +1216,7 @@ export const exitAsUnit = self => exitAs(self, void 0);
|
|
|
1195
1216
|
export const exitCauseOption = self => {
|
|
1196
1217
|
switch (self._tag) {
|
|
1197
1218
|
case OpCodes.OP_FAILURE:
|
|
1198
|
-
return Option.some(self.
|
|
1219
|
+
return Option.some(self.effect_instruction_i0);
|
|
1199
1220
|
case OpCodes.OP_SUCCESS:
|
|
1200
1221
|
return Option.none();
|
|
1201
1222
|
}
|
|
@@ -1210,7 +1231,7 @@ export const exitExists = /*#__PURE__*/dual(2, (self, refinement) => {
|
|
|
1210
1231
|
case OpCodes.OP_FAILURE:
|
|
1211
1232
|
return false;
|
|
1212
1233
|
case OpCodes.OP_SUCCESS:
|
|
1213
|
-
return refinement(self.
|
|
1234
|
+
return refinement(self.effect_instruction_i0);
|
|
1214
1235
|
}
|
|
1215
1236
|
});
|
|
1216
1237
|
/** @internal */
|
|
@@ -1218,7 +1239,7 @@ export const exitFail = error => exitFailCause(internalCause.fail(error));
|
|
|
1218
1239
|
/** @internal */
|
|
1219
1240
|
export const exitFailCause = cause => {
|
|
1220
1241
|
const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE);
|
|
1221
|
-
effect.
|
|
1242
|
+
effect.effect_instruction_i0 = cause;
|
|
1222
1243
|
return effect;
|
|
1223
1244
|
};
|
|
1224
1245
|
/** @internal */
|
|
@@ -1226,11 +1247,11 @@ export const exitFlatMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1226
1247
|
switch (self._tag) {
|
|
1227
1248
|
case OpCodes.OP_FAILURE:
|
|
1228
1249
|
{
|
|
1229
|
-
return exitFailCause(self.
|
|
1250
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1230
1251
|
}
|
|
1231
1252
|
case OpCodes.OP_SUCCESS:
|
|
1232
1253
|
{
|
|
1233
|
-
return f(self.
|
|
1254
|
+
return f(self.effect_instruction_i0);
|
|
1234
1255
|
}
|
|
1235
1256
|
}
|
|
1236
1257
|
});
|
|
@@ -1239,11 +1260,11 @@ export const exitFlatMapEffect = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1239
1260
|
switch (self._tag) {
|
|
1240
1261
|
case OpCodes.OP_FAILURE:
|
|
1241
1262
|
{
|
|
1242
|
-
return succeed(exitFailCause(self.
|
|
1263
|
+
return succeed(exitFailCause(self.effect_instruction_i0));
|
|
1243
1264
|
}
|
|
1244
1265
|
case OpCodes.OP_SUCCESS:
|
|
1245
1266
|
{
|
|
1246
|
-
return f(self.
|
|
1267
|
+
return f(self.effect_instruction_i0);
|
|
1247
1268
|
}
|
|
1248
1269
|
}
|
|
1249
1270
|
});
|
|
@@ -1254,11 +1275,11 @@ export const exitForEachEffect = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1254
1275
|
switch (self._tag) {
|
|
1255
1276
|
case OpCodes.OP_FAILURE:
|
|
1256
1277
|
{
|
|
1257
|
-
return succeed(exitFailCause(self.
|
|
1278
|
+
return succeed(exitFailCause(self.effect_instruction_i0));
|
|
1258
1279
|
}
|
|
1259
1280
|
case OpCodes.OP_SUCCESS:
|
|
1260
1281
|
{
|
|
1261
|
-
return exit(f(self.
|
|
1282
|
+
return exit(f(self.effect_instruction_i0));
|
|
1262
1283
|
}
|
|
1263
1284
|
}
|
|
1264
1285
|
});
|
|
@@ -1284,9 +1305,9 @@ export const exitFromOption = option => {
|
|
|
1284
1305
|
export const exitGetOrElse = /*#__PURE__*/dual(2, (self, orElse) => {
|
|
1285
1306
|
switch (self._tag) {
|
|
1286
1307
|
case OpCodes.OP_FAILURE:
|
|
1287
|
-
return orElse(self.
|
|
1308
|
+
return orElse(self.effect_instruction_i0);
|
|
1288
1309
|
case OpCodes.OP_SUCCESS:
|
|
1289
|
-
return self.
|
|
1310
|
+
return self.effect_instruction_i0;
|
|
1290
1311
|
}
|
|
1291
1312
|
});
|
|
1292
1313
|
/** @internal */
|
|
@@ -1295,9 +1316,9 @@ export const exitInterrupt = fiberId => exitFailCause(internalCause.interrupt(fi
|
|
|
1295
1316
|
export const exitMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
1296
1317
|
switch (self._tag) {
|
|
1297
1318
|
case OpCodes.OP_FAILURE:
|
|
1298
|
-
return exitFailCause(self.
|
|
1319
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1299
1320
|
case OpCodes.OP_SUCCESS:
|
|
1300
|
-
return exitSucceed(f(self.
|
|
1321
|
+
return exitSucceed(f(self.effect_instruction_i0));
|
|
1301
1322
|
}
|
|
1302
1323
|
});
|
|
1303
1324
|
/** @internal */
|
|
@@ -1307,27 +1328,27 @@ export const exitMapBoth = /*#__PURE__*/dual(2, (self, {
|
|
|
1307
1328
|
}) => {
|
|
1308
1329
|
switch (self._tag) {
|
|
1309
1330
|
case OpCodes.OP_FAILURE:
|
|
1310
|
-
return exitFailCause(pipe(self.
|
|
1331
|
+
return exitFailCause(pipe(self.effect_instruction_i0, internalCause.map(onFailure)));
|
|
1311
1332
|
case OpCodes.OP_SUCCESS:
|
|
1312
|
-
return exitSucceed(onSuccess(self.
|
|
1333
|
+
return exitSucceed(onSuccess(self.effect_instruction_i0));
|
|
1313
1334
|
}
|
|
1314
1335
|
});
|
|
1315
1336
|
/** @internal */
|
|
1316
1337
|
export const exitMapError = /*#__PURE__*/dual(2, (self, f) => {
|
|
1317
1338
|
switch (self._tag) {
|
|
1318
1339
|
case OpCodes.OP_FAILURE:
|
|
1319
|
-
return exitFailCause(pipe(self.
|
|
1340
|
+
return exitFailCause(pipe(self.effect_instruction_i0, internalCause.map(f)));
|
|
1320
1341
|
case OpCodes.OP_SUCCESS:
|
|
1321
|
-
return exitSucceed(self.
|
|
1342
|
+
return exitSucceed(self.effect_instruction_i0);
|
|
1322
1343
|
}
|
|
1323
1344
|
});
|
|
1324
1345
|
/** @internal */
|
|
1325
1346
|
export const exitMapErrorCause = /*#__PURE__*/dual(2, (self, f) => {
|
|
1326
1347
|
switch (self._tag) {
|
|
1327
1348
|
case OpCodes.OP_FAILURE:
|
|
1328
|
-
return exitFailCause(f(self.
|
|
1349
|
+
return exitFailCause(f(self.effect_instruction_i0));
|
|
1329
1350
|
case OpCodes.OP_SUCCESS:
|
|
1330
|
-
return exitSucceed(self.
|
|
1351
|
+
return exitSucceed(self.effect_instruction_i0);
|
|
1331
1352
|
}
|
|
1332
1353
|
});
|
|
1333
1354
|
/** @internal */
|
|
@@ -1337,9 +1358,9 @@ export const exitMatch = /*#__PURE__*/dual(2, (self, {
|
|
|
1337
1358
|
}) => {
|
|
1338
1359
|
switch (self._tag) {
|
|
1339
1360
|
case OpCodes.OP_FAILURE:
|
|
1340
|
-
return onFailure(self.
|
|
1361
|
+
return onFailure(self.effect_instruction_i0);
|
|
1341
1362
|
case OpCodes.OP_SUCCESS:
|
|
1342
|
-
return onSuccess(self.
|
|
1363
|
+
return onSuccess(self.effect_instruction_i0);
|
|
1343
1364
|
}
|
|
1344
1365
|
});
|
|
1345
1366
|
/** @internal */
|
|
@@ -1349,15 +1370,15 @@ export const exitMatchEffect = /*#__PURE__*/dual(2, (self, {
|
|
|
1349
1370
|
}) => {
|
|
1350
1371
|
switch (self._tag) {
|
|
1351
1372
|
case OpCodes.OP_FAILURE:
|
|
1352
|
-
return onFailure(self.
|
|
1373
|
+
return onFailure(self.effect_instruction_i0);
|
|
1353
1374
|
case OpCodes.OP_SUCCESS:
|
|
1354
|
-
return onSuccess(self.
|
|
1375
|
+
return onSuccess(self.effect_instruction_i0);
|
|
1355
1376
|
}
|
|
1356
1377
|
});
|
|
1357
1378
|
/** @internal */
|
|
1358
1379
|
export const exitSucceed = value => {
|
|
1359
1380
|
const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS);
|
|
1360
|
-
effect.
|
|
1381
|
+
effect.effect_instruction_i0 = value;
|
|
1361
1382
|
return effect;
|
|
1362
1383
|
};
|
|
1363
1384
|
/** @internal */
|
|
@@ -1402,10 +1423,10 @@ export const exitZipWith = /*#__PURE__*/dual(3, (self, that, {
|
|
|
1402
1423
|
{
|
|
1403
1424
|
switch (that._tag) {
|
|
1404
1425
|
case OpCodes.OP_SUCCESS:
|
|
1405
|
-
return exitFailCause(self.
|
|
1426
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1406
1427
|
case OpCodes.OP_FAILURE:
|
|
1407
1428
|
{
|
|
1408
|
-
return exitFailCause(onFailure(self.
|
|
1429
|
+
return exitFailCause(onFailure(self.effect_instruction_i0, that.effect_instruction_i0));
|
|
1409
1430
|
}
|
|
1410
1431
|
}
|
|
1411
1432
|
}
|
|
@@ -1413,9 +1434,9 @@ export const exitZipWith = /*#__PURE__*/dual(3, (self, that, {
|
|
|
1413
1434
|
{
|
|
1414
1435
|
switch (that._tag) {
|
|
1415
1436
|
case OpCodes.OP_SUCCESS:
|
|
1416
|
-
return exitSucceed(onSuccess(self.
|
|
1437
|
+
return exitSucceed(onSuccess(self.effect_instruction_i0, that.effect_instruction_i0));
|
|
1417
1438
|
case OpCodes.OP_FAILURE:
|
|
1418
|
-
return exitFailCause(that.
|
|
1439
|
+
return exitFailCause(that.effect_instruction_i0);
|
|
1419
1440
|
}
|
|
1420
1441
|
}
|
|
1421
1442
|
}
|