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
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zipFlatten = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withTracerTiming = exports.withSchedulingPriority = exports.withRuntimeFlags = exports.withRequestBatching = exports.withMaxOpsBeforeYield = exports.withFiberRuntime = exports.withConcurrency = exports.whileLoop = exports.whenEffect = exports.updateRuntimeFlags = exports.unit = exports.uninterruptibleMask = exports.uninterruptible = exports.transplant = exports.tap = exports.sync = exports.suspend = exports.succeed = exports.step = exports.scopeFork = exports.scopeClose = exports.scopeAddFinalizerExit = exports.scopeAddFinalizer = exports.runtimeFlags = exports.runRequestBlock = exports.resolverLocally = exports.requestBlockLocally = exports.releaseMapReplace = exports.releaseMapRemove = exports.releaseMapRelease = void 0;
|
|
6
|
+
exports.exitIsExit = exports.exitInterrupt = exports.exitGetOrElse = exports.exitFromOption = exports.exitFromEither = exports.exitForEachEffect = exports.exitFlatten = exports.exitFlatMapEffect = exports.exitFlatMap = exports.exitFailCause = exports.exitFail = exports.exitExists = exports.exitDie = exports.exitCollectAll = exports.exitCauseOption = exports.exitAsUnit = exports.exitAs = exports.exit = exports.either = exports.dieSync = exports.dieMessage = exports.die = exports.deferredUnsafeMake = exports.deferredUnsafeDone = exports.deferredSync = exports.deferredSucceed = exports.deferredPoll = exports.deferredMakeAs = exports.deferredMake = exports.deferredIsDone = exports.deferredInterruptWith = exports.deferredInterrupt = exports.deferredFailSync = exports.deferredFailCauseSync = exports.deferredFailCause = exports.deferredFail = exports.deferredDone = exports.deferredDieSync = exports.deferredDie = exports.deferredCompleteWith = exports.deferredComplete = exports.deferredAwait = exports.custom = exports.currentUnhandledErrorLogLevel = exports.currentTracerTimingEnabled = exports.currentTracerSpanLinks = exports.currentTracerSpanAnnotations = exports.currentSpanFromFiber = exports.currentSchedulingPriority = exports.currentRequestBatching = exports.currentMetricLabels = exports.currentMaxOpsBeforeYield = exports.currentLogSpan = exports.currentLogLevel = exports.currentLogAnnotations = exports.currentInterruptedCause = exports.currentForkScopeOverride = exports.currentContext = exports.currentConcurrency = exports.contextWithEffect = exports.contextWith = exports.context = exports.checkInterruptible = exports.causeSquashWith = exports.causeSquash = exports.catchSome = exports.catchIf = exports.catchAllCause = exports.catchAll = exports.blocked = exports.attemptOrElse = exports.async = exports.asUnit = exports.as = exports.andThen = exports.allLogLevels = exports.acquireUseRelease = exports.YieldableError = exports.UnknownExceptionTypeId = exports.UnknownException = exports.TimeoutExceptionTypeId = exports.TimeoutException = exports.ScopeTypeId = exports.RuntimeExceptionTypeId = exports.RuntimeException = exports.RevertFlags = exports.RequestResolverTypeId = exports.RequestResolverImpl = exports.NoSuchElementExceptionTypeId = exports.NoSuchElementException = exports.InvalidPubSubCapacityExceptionTypeId = exports.InvalidPubSubCapacityException = exports.InterruptedExceptionTypeId = exports.InterruptedException = exports.IllegalArgumentExceptionTypeId = exports.IllegalArgumentException = exports.FiberRefTypeId = exports.EffectTypeId = exports.EffectErrorTypeId = exports.CloseableScopeTypeId = void 0;
|
|
7
|
+
exports.releaseMapGet = exports.releaseMapAddIfOpen = exports.releaseMapAdd = exports.provideSomeContext = exports.provideContext = exports.partitionMap = exports.originalInstance = exports.orElse = exports.orDieWith = exports.orDie = exports.onInterrupt = exports.onExit = exports.onError = exports.never = exports.metricLabels = exports.matchEffect = exports.matchCauseEffect = exports.matchCause = exports.mapInputContext = exports.mapError = exports.mapBoth = exports.map = exports.makeEffectError = exports.logLevelWarning = exports.logLevelTrace = exports.logLevelNone = exports.logLevelInfo = exports.logLevelFatal = exports.logLevelError = exports.logLevelDebug = exports.logLevelAll = exports.isUnknownException = exports.isTimeoutException = exports.isRuntimeException = exports.isRequestResolver = exports.isNoSuchElementException = exports.isInvalidCapacityError = exports.isInterruptedException = exports.isIllegalArgumentException = exports.isEffectError = exports.isEffect = exports.intoDeferred = exports.interruptibleMask = exports.interruptible = exports.interruptWith = exports.interruptFiber = exports.interruptAsFiber = exports.interrupt = exports.if_ = exports.forEachSequentialDiscard = exports.forEachSequential = exports.flip = exports.flatten = exports.flatMap = exports.fiberRefUpdateSomeAndGet = exports.fiberRefUpdateSome = exports.fiberRefUpdateAndGet = exports.fiberRefUpdate = exports.fiberRefUnsafeMakeRuntimeFlags = exports.fiberRefUnsafeMakeReadonlyArray = exports.fiberRefUnsafeMakePatch = exports.fiberRefUnsafeMakeHashSet = exports.fiberRefUnsafeMakeContext = exports.fiberRefUnsafeMake = exports.fiberRefSet = exports.fiberRefReset = exports.fiberRefModifySome = exports.fiberRefModify = exports.fiberRefLocallyWith = exports.fiberRefLocally = exports.fiberRefGetWith = exports.fiberRefGetAndUpdateSome = exports.fiberRefGetAndUpdate = exports.fiberRefGetAndSet = exports.fiberRefGet = exports.fiberRefDelete = exports.fiberIdWith = exports.fiberId = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.exitZipWith = exports.exitZipRight = exports.exitZipParRight = exports.exitZipParLeft = exports.exitZipPar = exports.exitZipLeft = exports.exitZip = exports.exitUnit = exports.exitSucceed = exports.exitMatchEffect = exports.exitMatch = exports.exitMapErrorCause = exports.exitMapError = exports.exitMapBoth = exports.exitMap = exports.exitIsSuccess = exports.exitIsInterrupted = exports.exitIsFailure = void 0;
|
|
8
|
+
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zipFlatten = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withTracerTiming = exports.withSchedulingPriority = exports.withRuntimeFlags = exports.withRequestBatching = exports.withMaxOpsBeforeYield = exports.withFiberRuntime = exports.withConcurrency = exports.whileLoop = exports.whenEffect = exports.updateRuntimeFlags = exports.unit = exports.uninterruptibleMask = exports.uninterruptible = exports.transplant = exports.tap = exports.sync = exports.suspend = exports.succeed = exports.step = exports.scopeFork = exports.scopeClose = exports.scopeAddFinalizerExit = exports.scopeAddFinalizer = exports.runtimeFlags = exports.runRequestBlock = exports.resolverLocally = exports.requestBlockLocally = exports.releaseMapReplace = exports.releaseMapRemove = exports.releaseMapRelease = exports.releaseMapMake = void 0;
|
|
9
9
|
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../Chunk.js"));
|
|
10
10
|
var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../Context.js"));
|
|
11
11
|
var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../Either.js"));
|
|
@@ -28,7 +28,6 @@ var internalCause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("
|
|
|
28
28
|
var deferred = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./deferred.js"));
|
|
29
29
|
var internalDiffer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./differ.js"));
|
|
30
30
|
var _effectable = /*#__PURE__*/require("./effectable.js");
|
|
31
|
-
var _internalize = /*#__PURE__*/require("./internalize.js");
|
|
32
31
|
var DeferredOpCodes = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./opCodes/deferred.js"));
|
|
33
32
|
var OpCodes = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./opCodes/effect.js"));
|
|
34
33
|
var _runtimeFlags = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./runtimeFlags.js"));
|
|
@@ -80,8 +79,8 @@ const makeEffectError = cause => ({
|
|
|
80
79
|
exports.makeEffectError = makeEffectError;
|
|
81
80
|
const blocked = (blockedRequests, _continue) => {
|
|
82
81
|
const effect = new EffectPrimitive("Blocked");
|
|
83
|
-
effect.
|
|
84
|
-
effect.
|
|
82
|
+
effect.effect_instruction_i0 = blockedRequests;
|
|
83
|
+
effect.effect_instruction_i1 = _continue;
|
|
85
84
|
return effect;
|
|
86
85
|
};
|
|
87
86
|
/**
|
|
@@ -90,7 +89,7 @@ const blocked = (blockedRequests, _continue) => {
|
|
|
90
89
|
exports.blocked = blocked;
|
|
91
90
|
const runRequestBlock = blockedRequests => {
|
|
92
91
|
const effect = new EffectPrimitive("RunBlocked");
|
|
93
|
-
effect.
|
|
92
|
+
effect.effect_instruction_i0 = blockedRequests;
|
|
94
93
|
return effect;
|
|
95
94
|
};
|
|
96
95
|
/** @internal */
|
|
@@ -110,9 +109,9 @@ class RevertFlags {
|
|
|
110
109
|
exports.RevertFlags = RevertFlags;
|
|
111
110
|
class EffectPrimitive {
|
|
112
111
|
_op;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
effect_instruction_i0 = undefined;
|
|
113
|
+
effect_instruction_i1 = undefined;
|
|
114
|
+
effect_instruction_i2 = undefined;
|
|
116
115
|
trace = undefined;
|
|
117
116
|
[EffectTypeId] = _effectable.effectVariance;
|
|
118
117
|
constructor(_op) {
|
|
@@ -131,9 +130,9 @@ class EffectPrimitive {
|
|
|
131
130
|
return {
|
|
132
131
|
_id: "Effect",
|
|
133
132
|
_op: this._op,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
effect_instruction_i0: (0, _Inspectable.toJSON)(this.effect_instruction_i0),
|
|
134
|
+
effect_instruction_i1: (0, _Inspectable.toJSON)(this.effect_instruction_i1),
|
|
135
|
+
effect_instruction_i2: (0, _Inspectable.toJSON)(this.effect_instruction_i2)
|
|
137
136
|
};
|
|
138
137
|
}
|
|
139
138
|
toString() {
|
|
@@ -146,9 +145,9 @@ class EffectPrimitive {
|
|
|
146
145
|
/** @internal */
|
|
147
146
|
class EffectPrimitiveFailure {
|
|
148
147
|
_op;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
effect_instruction_i0 = undefined;
|
|
149
|
+
effect_instruction_i1 = undefined;
|
|
150
|
+
effect_instruction_i2 = undefined;
|
|
152
151
|
trace = undefined;
|
|
153
152
|
[EffectTypeId] = _effectable.effectVariance;
|
|
154
153
|
constructor(_op) {
|
|
@@ -163,7 +162,7 @@ class EffectPrimitiveFailure {
|
|
|
163
162
|
return Hash.cached(this, Hash.random(this));
|
|
164
163
|
}
|
|
165
164
|
get cause() {
|
|
166
|
-
return this.
|
|
165
|
+
return this.effect_instruction_i0;
|
|
167
166
|
}
|
|
168
167
|
pipe() {
|
|
169
168
|
return (0, _Pipeable.pipeArguments)(this, arguments);
|
|
@@ -185,9 +184,9 @@ class EffectPrimitiveFailure {
|
|
|
185
184
|
/** @internal */
|
|
186
185
|
class EffectPrimitiveSuccess {
|
|
187
186
|
_op;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
effect_instruction_i0 = undefined;
|
|
188
|
+
effect_instruction_i1 = undefined;
|
|
189
|
+
effect_instruction_i2 = undefined;
|
|
191
190
|
trace = undefined;
|
|
192
191
|
[EffectTypeId] = _effectable.effectVariance;
|
|
193
192
|
constructor(_op) {
|
|
@@ -202,7 +201,7 @@ class EffectPrimitiveSuccess {
|
|
|
202
201
|
return Hash.cached(this, Hash.random(this));
|
|
203
202
|
}
|
|
204
203
|
get value() {
|
|
205
|
-
return this.
|
|
204
|
+
return this.effect_instruction_i0;
|
|
206
205
|
}
|
|
207
206
|
pipe() {
|
|
208
207
|
return (0, _Pipeable.pipeArguments)(this, arguments);
|
|
@@ -226,9 +225,8 @@ const isEffect = u => (0, _Predicate.hasProperty)(u, EffectTypeId);
|
|
|
226
225
|
/* @internal */
|
|
227
226
|
exports.isEffect = isEffect;
|
|
228
227
|
const withFiberRuntime = withRuntime => {
|
|
229
|
-
(0, _internalize.internalize)(withRuntime);
|
|
230
228
|
const effect = new EffectPrimitive(OpCodes.OP_WITH_RUNTIME);
|
|
231
|
-
effect.
|
|
229
|
+
effect.effect_instruction_i0 = withRuntime;
|
|
232
230
|
return effect;
|
|
233
231
|
};
|
|
234
232
|
/* @internal */
|
|
@@ -238,7 +236,7 @@ const acquireUseRelease = exports.acquireUseRelease = /*#__PURE__*/(0, _Function
|
|
|
238
236
|
onFailure: cause => {
|
|
239
237
|
switch (exit._tag) {
|
|
240
238
|
case OpCodes.OP_FAILURE:
|
|
241
|
-
return failCause(internalCause.parallel(exit.
|
|
239
|
+
return failCause(internalCause.parallel(exit.effect_instruction_i0, cause));
|
|
242
240
|
case OpCodes.OP_SUCCESS:
|
|
243
241
|
return failCause(cause);
|
|
244
242
|
}
|
|
@@ -252,47 +250,80 @@ const as = exports.as = /*#__PURE__*/(0, _Function.dual)(2, (self, value) => fla
|
|
|
252
250
|
const asUnit = self => as(self, void 0);
|
|
253
251
|
/* @internal */
|
|
254
252
|
exports.asUnit = asUnit;
|
|
255
|
-
const
|
|
256
|
-
(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
253
|
+
const custom = function () {
|
|
254
|
+
const wrapper = new EffectPrimitive(OpCodes.OP_COMMIT);
|
|
255
|
+
switch (arguments.length) {
|
|
256
|
+
case 2:
|
|
257
|
+
{
|
|
258
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
259
|
+
wrapper.commit = arguments[1];
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case 3:
|
|
263
|
+
{
|
|
264
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
265
|
+
wrapper.effect_instruction_i1 = arguments[1];
|
|
266
|
+
wrapper.commit = arguments[2];
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
case 4:
|
|
270
|
+
{
|
|
271
|
+
wrapper.effect_instruction_i0 = arguments[0];
|
|
272
|
+
wrapper.effect_instruction_i1 = arguments[1];
|
|
273
|
+
wrapper.effect_instruction_i2 = arguments[2];
|
|
274
|
+
wrapper.commit = arguments[3];
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
default:
|
|
278
|
+
{
|
|
279
|
+
throw new Error("Bug, you're not supposed to end up here");
|
|
280
|
+
}
|
|
265
281
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
282
|
+
return wrapper;
|
|
283
|
+
};
|
|
284
|
+
/* @internal */
|
|
285
|
+
exports.custom = custom;
|
|
286
|
+
const async = (register, blockingOn = FiberId.none) => {
|
|
287
|
+
return custom(register, function () {
|
|
288
|
+
let backingResume = undefined;
|
|
289
|
+
let pendingEffect = undefined;
|
|
290
|
+
function proxyResume(effect) {
|
|
291
|
+
if (backingResume) {
|
|
292
|
+
backingResume(effect);
|
|
293
|
+
} else if (pendingEffect === undefined) {
|
|
294
|
+
pendingEffect = effect;
|
|
295
|
+
}
|
|
271
296
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
cancelerRef =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
controllerRef.
|
|
297
|
+
const effect = new EffectPrimitive(OpCodes.OP_ASYNC);
|
|
298
|
+
effect.effect_instruction_i0 = resume => {
|
|
299
|
+
backingResume = resume;
|
|
300
|
+
if (pendingEffect) {
|
|
301
|
+
resume(pendingEffect);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
effect.effect_instruction_i1 = blockingOn;
|
|
305
|
+
let cancelerRef = undefined;
|
|
306
|
+
let controllerRef = undefined;
|
|
307
|
+
if (this.effect_instruction_i0.length !== 1) {
|
|
308
|
+
controllerRef = new AbortController();
|
|
309
|
+
cancelerRef = this.effect_instruction_i0(proxyResume, controllerRef.signal);
|
|
310
|
+
} else {
|
|
311
|
+
cancelerRef = this.effect_instruction_i0(proxyResume);
|
|
285
312
|
}
|
|
286
|
-
return cancelerRef
|
|
287
|
-
|
|
288
|
-
|
|
313
|
+
return cancelerRef || controllerRef ? onInterrupt(effect, _ => {
|
|
314
|
+
if (controllerRef) {
|
|
315
|
+
controllerRef.abort();
|
|
316
|
+
}
|
|
317
|
+
return cancelerRef ?? unit;
|
|
318
|
+
}) : effect;
|
|
319
|
+
});
|
|
320
|
+
};
|
|
289
321
|
/* @internal */
|
|
290
322
|
exports.async = async;
|
|
291
323
|
const catchAllCause = exports.catchAllCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
292
324
|
const effect = new EffectPrimitive(OpCodes.OP_ON_FAILURE);
|
|
293
|
-
effect.
|
|
294
|
-
effect.
|
|
295
|
-
(0, _internalize.internalize)(f);
|
|
325
|
+
effect.effect_instruction_i0 = self;
|
|
326
|
+
effect.effect_instruction_i1 = f;
|
|
296
327
|
return effect;
|
|
297
328
|
});
|
|
298
329
|
/* @internal */
|
|
@@ -385,7 +416,7 @@ const failSync = evaluate => flatMap(sync(evaluate), fail);
|
|
|
385
416
|
exports.failSync = failSync;
|
|
386
417
|
const failCause = cause => {
|
|
387
418
|
const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE);
|
|
388
|
-
effect.
|
|
419
|
+
effect.effect_instruction_i0 = cause;
|
|
389
420
|
return effect;
|
|
390
421
|
};
|
|
391
422
|
/* @internal */
|
|
@@ -399,10 +430,9 @@ const fiberIdWith = f => withFiberRuntime(state => f(state.id()));
|
|
|
399
430
|
/* @internal */
|
|
400
431
|
exports.fiberIdWith = fiberIdWith;
|
|
401
432
|
const flatMap = exports.flatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
402
|
-
(0, _internalize.internalize)(f);
|
|
403
433
|
const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS);
|
|
404
|
-
effect.
|
|
405
|
-
effect.
|
|
434
|
+
effect.effect_instruction_i0 = self;
|
|
435
|
+
effect.effect_instruction_i1 = f;
|
|
406
436
|
return effect;
|
|
407
437
|
});
|
|
408
438
|
/* @internal */
|
|
@@ -420,7 +450,7 @@ const andThen = exports.andThen = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
|
|
|
420
450
|
/* @internal */
|
|
421
451
|
const step = self => {
|
|
422
452
|
const effect = new EffectPrimitive("OnStep");
|
|
423
|
-
effect.
|
|
453
|
+
effect.effect_instruction_i0 = self;
|
|
424
454
|
return effect;
|
|
425
455
|
};
|
|
426
456
|
/* @internal */
|
|
@@ -441,11 +471,9 @@ const matchCause = exports.matchCause = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
441
471
|
/* @internal */
|
|
442
472
|
const matchCauseEffect = exports.matchCauseEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => {
|
|
443
473
|
const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS_AND_FAILURE);
|
|
444
|
-
effect.
|
|
445
|
-
effect.
|
|
446
|
-
effect.
|
|
447
|
-
(0, _internalize.internalize)(options.onFailure);
|
|
448
|
-
(0, _internalize.internalize)(options.onSuccess);
|
|
474
|
+
effect.effect_instruction_i0 = self;
|
|
475
|
+
effect.effect_instruction_i1 = options.onFailure;
|
|
476
|
+
effect.effect_instruction_i2 = options.onSuccess;
|
|
449
477
|
return effect;
|
|
450
478
|
});
|
|
451
479
|
/* @internal */
|
|
@@ -501,19 +529,18 @@ const interruptWith = fiberId => failCause(internalCause.interrupt(fiberId));
|
|
|
501
529
|
exports.interruptWith = interruptWith;
|
|
502
530
|
const interruptible = self => {
|
|
503
531
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
504
|
-
effect.
|
|
505
|
-
effect.
|
|
532
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption);
|
|
533
|
+
effect.effect_instruction_i1 = () => self;
|
|
506
534
|
return effect;
|
|
507
535
|
};
|
|
508
536
|
/* @internal */
|
|
509
537
|
exports.interruptible = interruptible;
|
|
510
|
-
const interruptibleMask = f => {
|
|
511
|
-
(0, _internalize.internalize)(f);
|
|
538
|
+
const interruptibleMask = f => custom(f, function () {
|
|
512
539
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
513
|
-
effect.
|
|
514
|
-
effect.
|
|
540
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption);
|
|
541
|
+
effect.effect_instruction_i1 = oldFlags => _runtimeFlags.interruption(oldFlags) ? this.effect_instruction_i0(interruptible) : this.effect_instruction_i0(uninterruptible);
|
|
515
542
|
return effect;
|
|
516
|
-
};
|
|
543
|
+
});
|
|
517
544
|
/* @internal */
|
|
518
545
|
exports.interruptibleMask = interruptibleMask;
|
|
519
546
|
const intoDeferred = exports.intoDeferred = /*#__PURE__*/(0, _Function.dual)(2, (self, deferred) => uninterruptibleMask(restore => flatMap(exit(restore(self)), exit => deferredDone(deferred, exit))));
|
|
@@ -542,7 +569,7 @@ const mapError = exports.mapError = /*#__PURE__*/(0, _Function.dual)(2, (self, f
|
|
|
542
569
|
onSuccess: succeed
|
|
543
570
|
}));
|
|
544
571
|
/* @internal */
|
|
545
|
-
const onError = exports.onError = /*#__PURE__*/(0, _Function.dual)(2, (self, cleanup) => onExit(self, exit => exitIsSuccess(exit) ? unit : cleanup(exit.
|
|
572
|
+
const onError = exports.onError = /*#__PURE__*/(0, _Function.dual)(2, (self, cleanup) => onExit(self, exit => exitIsSuccess(exit) ? unit : cleanup(exit.effect_instruction_i0)));
|
|
546
573
|
/* @internal */
|
|
547
574
|
const onExit = exports.onExit = /*#__PURE__*/(0, _Function.dual)(2, (self, cleanup) => uninterruptibleMask(restore => matchCauseEffect(restore(self), {
|
|
548
575
|
onFailure: cause1 => {
|
|
@@ -592,7 +619,7 @@ const runtimeFlags = exports.runtimeFlags = /*#__PURE__*/withFiberRuntime((_, st
|
|
|
592
619
|
/* @internal */
|
|
593
620
|
const succeed = value => {
|
|
594
621
|
const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS);
|
|
595
|
-
effect.
|
|
622
|
+
effect.effect_instruction_i0 = value;
|
|
596
623
|
return effect;
|
|
597
624
|
};
|
|
598
625
|
/* @internal */
|
|
@@ -601,9 +628,8 @@ const suspend = effect => flatMap(sync(effect), _Function.identity);
|
|
|
601
628
|
/* @internal */
|
|
602
629
|
exports.suspend = suspend;
|
|
603
630
|
const sync = evaluate => {
|
|
604
|
-
(0, _internalize.internalize)(evaluate);
|
|
605
631
|
const effect = new EffectPrimitive(OpCodes.OP_SYNC);
|
|
606
|
-
effect.
|
|
632
|
+
effect.effect_instruction_i0 = evaluate;
|
|
607
633
|
return effect;
|
|
608
634
|
};
|
|
609
635
|
/* @internal */
|
|
@@ -640,27 +666,26 @@ const attemptOrElse = exports.attemptOrElse = /*#__PURE__*/(0, _Function.dual)(3
|
|
|
640
666
|
/* @internal */
|
|
641
667
|
const uninterruptible = self => {
|
|
642
668
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
643
|
-
effect.
|
|
644
|
-
effect.
|
|
669
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption);
|
|
670
|
+
effect.effect_instruction_i1 = () => self;
|
|
645
671
|
return effect;
|
|
646
672
|
};
|
|
647
673
|
/* @internal */
|
|
648
674
|
exports.uninterruptible = uninterruptible;
|
|
649
|
-
const uninterruptibleMask = f => {
|
|
650
|
-
(0, _internalize.internalize)(f);
|
|
675
|
+
const uninterruptibleMask = f => custom(f, function () {
|
|
651
676
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
652
|
-
effect.
|
|
653
|
-
effect.
|
|
677
|
+
effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption);
|
|
678
|
+
effect.effect_instruction_i1 = oldFlags => _runtimeFlags.interruption(oldFlags) ? this.effect_instruction_i0(interruptible) : this.effect_instruction_i0(uninterruptible);
|
|
654
679
|
return effect;
|
|
655
|
-
};
|
|
680
|
+
});
|
|
656
681
|
/* @internal */
|
|
657
682
|
exports.uninterruptibleMask = uninterruptibleMask;
|
|
658
683
|
const unit = exports.unit = /*#__PURE__*/succeed(void 0);
|
|
659
684
|
/* @internal */
|
|
660
685
|
const updateRuntimeFlags = patch => {
|
|
661
686
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
662
|
-
effect.
|
|
663
|
-
effect.
|
|
687
|
+
effect.effect_instruction_i0 = patch;
|
|
688
|
+
effect.effect_instruction_i1 = void 0;
|
|
664
689
|
return effect;
|
|
665
690
|
};
|
|
666
691
|
/* @internal */
|
|
@@ -674,12 +699,9 @@ const whenEffect = exports.whenEffect = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
674
699
|
/* @internal */
|
|
675
700
|
const whileLoop = options => {
|
|
676
701
|
const effect = new EffectPrimitive(OpCodes.OP_WHILE);
|
|
677
|
-
effect.
|
|
678
|
-
effect.
|
|
679
|
-
effect.
|
|
680
|
-
(0, _internalize.internalize)(options.body);
|
|
681
|
-
(0, _internalize.internalize)(options.step);
|
|
682
|
-
(0, _internalize.internalize)(options.while);
|
|
702
|
+
effect.effect_instruction_i0 = options.while;
|
|
703
|
+
effect.effect_instruction_i1 = options.body;
|
|
704
|
+
effect.effect_instruction_i2 = options.step;
|
|
683
705
|
return effect;
|
|
684
706
|
};
|
|
685
707
|
/* @internal */
|
|
@@ -690,8 +712,8 @@ const withRequestBatching = exports.withRequestBatching = /*#__PURE__*/(0, _Func
|
|
|
690
712
|
/* @internal */
|
|
691
713
|
const withRuntimeFlags = exports.withRuntimeFlags = /*#__PURE__*/(0, _Function.dual)(2, (self, update) => {
|
|
692
714
|
const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS);
|
|
693
|
-
effect.
|
|
694
|
-
effect.
|
|
715
|
+
effect.effect_instruction_i0 = update;
|
|
716
|
+
effect.effect_instruction_i1 = () => self;
|
|
695
717
|
return effect;
|
|
696
718
|
});
|
|
697
719
|
/** @internal */
|
|
@@ -1271,7 +1293,7 @@ exports.exitIsSuccess = exitIsSuccess;
|
|
|
1271
1293
|
const exitIsInterrupted = self => {
|
|
1272
1294
|
switch (self._tag) {
|
|
1273
1295
|
case OpCodes.OP_FAILURE:
|
|
1274
|
-
return internalCause.isInterrupted(self.
|
|
1296
|
+
return internalCause.isInterrupted(self.effect_instruction_i0);
|
|
1275
1297
|
case OpCodes.OP_SUCCESS:
|
|
1276
1298
|
return false;
|
|
1277
1299
|
}
|
|
@@ -1282,7 +1304,7 @@ const exitAs = exports.exitAs = /*#__PURE__*/(0, _Function.dual)(2, (self, value
|
|
|
1282
1304
|
switch (self._tag) {
|
|
1283
1305
|
case OpCodes.OP_FAILURE:
|
|
1284
1306
|
{
|
|
1285
|
-
return exitFailCause(self.
|
|
1307
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1286
1308
|
}
|
|
1287
1309
|
case OpCodes.OP_SUCCESS:
|
|
1288
1310
|
{
|
|
@@ -1297,7 +1319,7 @@ exports.exitAsUnit = exitAsUnit;
|
|
|
1297
1319
|
const exitCauseOption = self => {
|
|
1298
1320
|
switch (self._tag) {
|
|
1299
1321
|
case OpCodes.OP_FAILURE:
|
|
1300
|
-
return Option.some(self.
|
|
1322
|
+
return Option.some(self.effect_instruction_i0);
|
|
1301
1323
|
case OpCodes.OP_SUCCESS:
|
|
1302
1324
|
return Option.none();
|
|
1303
1325
|
}
|
|
@@ -1315,7 +1337,7 @@ const exitExists = exports.exitExists = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
1315
1337
|
case OpCodes.OP_FAILURE:
|
|
1316
1338
|
return false;
|
|
1317
1339
|
case OpCodes.OP_SUCCESS:
|
|
1318
|
-
return refinement(self.
|
|
1340
|
+
return refinement(self.effect_instruction_i0);
|
|
1319
1341
|
}
|
|
1320
1342
|
});
|
|
1321
1343
|
/** @internal */
|
|
@@ -1324,7 +1346,7 @@ const exitFail = error => exitFailCause(internalCause.fail(error));
|
|
|
1324
1346
|
exports.exitFail = exitFail;
|
|
1325
1347
|
const exitFailCause = cause => {
|
|
1326
1348
|
const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE);
|
|
1327
|
-
effect.
|
|
1349
|
+
effect.effect_instruction_i0 = cause;
|
|
1328
1350
|
return effect;
|
|
1329
1351
|
};
|
|
1330
1352
|
/** @internal */
|
|
@@ -1333,11 +1355,11 @@ const exitFlatMap = exports.exitFlatMap = /*#__PURE__*/(0, _Function.dual)(2, (s
|
|
|
1333
1355
|
switch (self._tag) {
|
|
1334
1356
|
case OpCodes.OP_FAILURE:
|
|
1335
1357
|
{
|
|
1336
|
-
return exitFailCause(self.
|
|
1358
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1337
1359
|
}
|
|
1338
1360
|
case OpCodes.OP_SUCCESS:
|
|
1339
1361
|
{
|
|
1340
|
-
return f(self.
|
|
1362
|
+
return f(self.effect_instruction_i0);
|
|
1341
1363
|
}
|
|
1342
1364
|
}
|
|
1343
1365
|
});
|
|
@@ -1346,11 +1368,11 @@ const exitFlatMapEffect = exports.exitFlatMapEffect = /*#__PURE__*/(0, _Function
|
|
|
1346
1368
|
switch (self._tag) {
|
|
1347
1369
|
case OpCodes.OP_FAILURE:
|
|
1348
1370
|
{
|
|
1349
|
-
return succeed(exitFailCause(self.
|
|
1371
|
+
return succeed(exitFailCause(self.effect_instruction_i0));
|
|
1350
1372
|
}
|
|
1351
1373
|
case OpCodes.OP_SUCCESS:
|
|
1352
1374
|
{
|
|
1353
|
-
return f(self.
|
|
1375
|
+
return f(self.effect_instruction_i0);
|
|
1354
1376
|
}
|
|
1355
1377
|
}
|
|
1356
1378
|
});
|
|
@@ -1362,11 +1384,11 @@ const exitForEachEffect = exports.exitForEachEffect = /*#__PURE__*/(0, _Function
|
|
|
1362
1384
|
switch (self._tag) {
|
|
1363
1385
|
case OpCodes.OP_FAILURE:
|
|
1364
1386
|
{
|
|
1365
|
-
return succeed(exitFailCause(self.
|
|
1387
|
+
return succeed(exitFailCause(self.effect_instruction_i0));
|
|
1366
1388
|
}
|
|
1367
1389
|
case OpCodes.OP_SUCCESS:
|
|
1368
1390
|
{
|
|
1369
|
-
return exit(f(self.
|
|
1391
|
+
return exit(f(self.effect_instruction_i0));
|
|
1370
1392
|
}
|
|
1371
1393
|
}
|
|
1372
1394
|
});
|
|
@@ -1394,9 +1416,9 @@ exports.exitFromOption = exitFromOption;
|
|
|
1394
1416
|
const exitGetOrElse = exports.exitGetOrElse = /*#__PURE__*/(0, _Function.dual)(2, (self, orElse) => {
|
|
1395
1417
|
switch (self._tag) {
|
|
1396
1418
|
case OpCodes.OP_FAILURE:
|
|
1397
|
-
return orElse(self.
|
|
1419
|
+
return orElse(self.effect_instruction_i0);
|
|
1398
1420
|
case OpCodes.OP_SUCCESS:
|
|
1399
|
-
return self.
|
|
1421
|
+
return self.effect_instruction_i0;
|
|
1400
1422
|
}
|
|
1401
1423
|
});
|
|
1402
1424
|
/** @internal */
|
|
@@ -1406,9 +1428,9 @@ exports.exitInterrupt = exitInterrupt;
|
|
|
1406
1428
|
const exitMap = exports.exitMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
1407
1429
|
switch (self._tag) {
|
|
1408
1430
|
case OpCodes.OP_FAILURE:
|
|
1409
|
-
return exitFailCause(self.
|
|
1431
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1410
1432
|
case OpCodes.OP_SUCCESS:
|
|
1411
|
-
return exitSucceed(f(self.
|
|
1433
|
+
return exitSucceed(f(self.effect_instruction_i0));
|
|
1412
1434
|
}
|
|
1413
1435
|
});
|
|
1414
1436
|
/** @internal */
|
|
@@ -1418,27 +1440,27 @@ const exitMapBoth = exports.exitMapBoth = /*#__PURE__*/(0, _Function.dual)(2, (s
|
|
|
1418
1440
|
}) => {
|
|
1419
1441
|
switch (self._tag) {
|
|
1420
1442
|
case OpCodes.OP_FAILURE:
|
|
1421
|
-
return exitFailCause((0, _Function.pipe)(self.
|
|
1443
|
+
return exitFailCause((0, _Function.pipe)(self.effect_instruction_i0, internalCause.map(onFailure)));
|
|
1422
1444
|
case OpCodes.OP_SUCCESS:
|
|
1423
|
-
return exitSucceed(onSuccess(self.
|
|
1445
|
+
return exitSucceed(onSuccess(self.effect_instruction_i0));
|
|
1424
1446
|
}
|
|
1425
1447
|
});
|
|
1426
1448
|
/** @internal */
|
|
1427
1449
|
const exitMapError = exports.exitMapError = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
1428
1450
|
switch (self._tag) {
|
|
1429
1451
|
case OpCodes.OP_FAILURE:
|
|
1430
|
-
return exitFailCause((0, _Function.pipe)(self.
|
|
1452
|
+
return exitFailCause((0, _Function.pipe)(self.effect_instruction_i0, internalCause.map(f)));
|
|
1431
1453
|
case OpCodes.OP_SUCCESS:
|
|
1432
|
-
return exitSucceed(self.
|
|
1454
|
+
return exitSucceed(self.effect_instruction_i0);
|
|
1433
1455
|
}
|
|
1434
1456
|
});
|
|
1435
1457
|
/** @internal */
|
|
1436
1458
|
const exitMapErrorCause = exports.exitMapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
1437
1459
|
switch (self._tag) {
|
|
1438
1460
|
case OpCodes.OP_FAILURE:
|
|
1439
|
-
return exitFailCause(f(self.
|
|
1461
|
+
return exitFailCause(f(self.effect_instruction_i0));
|
|
1440
1462
|
case OpCodes.OP_SUCCESS:
|
|
1441
|
-
return exitSucceed(self.
|
|
1463
|
+
return exitSucceed(self.effect_instruction_i0);
|
|
1442
1464
|
}
|
|
1443
1465
|
});
|
|
1444
1466
|
/** @internal */
|
|
@@ -1448,9 +1470,9 @@ const exitMatch = exports.exitMatch = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
1448
1470
|
}) => {
|
|
1449
1471
|
switch (self._tag) {
|
|
1450
1472
|
case OpCodes.OP_FAILURE:
|
|
1451
|
-
return onFailure(self.
|
|
1473
|
+
return onFailure(self.effect_instruction_i0);
|
|
1452
1474
|
case OpCodes.OP_SUCCESS:
|
|
1453
|
-
return onSuccess(self.
|
|
1475
|
+
return onSuccess(self.effect_instruction_i0);
|
|
1454
1476
|
}
|
|
1455
1477
|
});
|
|
1456
1478
|
/** @internal */
|
|
@@ -1460,15 +1482,15 @@ const exitMatchEffect = exports.exitMatchEffect = /*#__PURE__*/(0, _Function.dua
|
|
|
1460
1482
|
}) => {
|
|
1461
1483
|
switch (self._tag) {
|
|
1462
1484
|
case OpCodes.OP_FAILURE:
|
|
1463
|
-
return onFailure(self.
|
|
1485
|
+
return onFailure(self.effect_instruction_i0);
|
|
1464
1486
|
case OpCodes.OP_SUCCESS:
|
|
1465
|
-
return onSuccess(self.
|
|
1487
|
+
return onSuccess(self.effect_instruction_i0);
|
|
1466
1488
|
}
|
|
1467
1489
|
});
|
|
1468
1490
|
/** @internal */
|
|
1469
1491
|
const exitSucceed = value => {
|
|
1470
1492
|
const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS);
|
|
1471
|
-
effect.
|
|
1493
|
+
effect.effect_instruction_i0 = value;
|
|
1472
1494
|
return effect;
|
|
1473
1495
|
};
|
|
1474
1496
|
/** @internal */
|
|
@@ -1514,10 +1536,10 @@ const exitZipWith = exports.exitZipWith = /*#__PURE__*/(0, _Function.dual)(3, (s
|
|
|
1514
1536
|
{
|
|
1515
1537
|
switch (that._tag) {
|
|
1516
1538
|
case OpCodes.OP_SUCCESS:
|
|
1517
|
-
return exitFailCause(self.
|
|
1539
|
+
return exitFailCause(self.effect_instruction_i0);
|
|
1518
1540
|
case OpCodes.OP_FAILURE:
|
|
1519
1541
|
{
|
|
1520
|
-
return exitFailCause(onFailure(self.
|
|
1542
|
+
return exitFailCause(onFailure(self.effect_instruction_i0, that.effect_instruction_i0));
|
|
1521
1543
|
}
|
|
1522
1544
|
}
|
|
1523
1545
|
}
|
|
@@ -1525,9 +1547,9 @@ const exitZipWith = exports.exitZipWith = /*#__PURE__*/(0, _Function.dual)(3, (s
|
|
|
1525
1547
|
{
|
|
1526
1548
|
switch (that._tag) {
|
|
1527
1549
|
case OpCodes.OP_SUCCESS:
|
|
1528
|
-
return exitSucceed(onSuccess(self.
|
|
1550
|
+
return exitSucceed(onSuccess(self.effect_instruction_i0, that.effect_instruction_i0));
|
|
1529
1551
|
case OpCodes.OP_FAILURE:
|
|
1530
|
-
return exitFailCause(that.
|
|
1552
|
+
return exitFailCause(that.effect_instruction_i0);
|
|
1531
1553
|
}
|
|
1532
1554
|
}
|
|
1533
1555
|
}
|