@fncts/io 0.0.15 → 0.0.18
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/Cached/internal.d.ts +1 -1
- package/CancellerState.d.ts +1 -1
- package/Channel/ChildExecutorDecision/definition.d.ts +1 -1
- package/Channel/UpstreamPullRequest/definition.d.ts +1 -1
- package/Channel/UpstreamPullStrategy/definition.d.ts +1 -1
- package/Channel/api/mergeAllWith.d.ts +1 -1
- package/Channel/internal/ChannelExecutor.d.ts +1 -1
- package/Channel/internal/ChannelState.d.ts +2 -2
- package/Channel/internal/MergeDecision.d.ts +1 -1
- package/Channel/internal/MergeState.d.ts +1 -1
- package/Channel/internal/SingleProducerAsyncInput.d.ts +1 -1
- package/Fiber/FiberContext.d.ts +18 -18
- package/Fiber/definition.d.ts +2 -2
- package/FiberRef/api.d.ts +2 -2
- package/FiberRef/definition.d.ts +2 -2
- package/FiberRef/unsafe.d.ts +6 -0
- package/FiberRefs/definition.d.ts +1 -1
- package/FiberState/definition.d.ts +2 -2
- package/FiberStatus/definition.d.ts +1 -1
- package/Future/definition.d.ts +1 -1
- package/Hub/definition.d.ts +1 -1
- package/IO/api/core-scope.d.ts +4 -3
- package/IO/api/interrupt.d.ts +2 -2
- package/IO/api/supervised.d.ts +10 -0
- package/IO/api.d.ts +7 -10
- package/IO/definition.d.ts +16 -139
- package/IO.d.ts +1 -0
- package/IOEnv/definition.d.ts +1 -1
- package/Layer/definition.d.ts +2 -2
- package/Ref/definition.d.ts +3 -3
- package/RuntimeConfig.d.ts +1 -1
- package/STM/definition.d.ts +5 -5
- package/STM/internal/CommitState.d.ts +1 -1
- package/STM/internal/Entry.d.ts +2 -2
- package/STM/internal/Journal.d.ts +6 -6
- package/STM/internal/TryCommit.d.ts +2 -2
- package/STM/internal/Versioned.d.ts +1 -1
- package/Schedule/Decision.d.ts +1 -1
- package/Scope/ReleaseMap/definition.d.ts +1 -1
- package/Scope/definition.d.ts +2 -2
- package/ScopedRef/definition.d.ts +1 -1
- package/State/internal.d.ts +1 -1
- package/Stream/api.d.ts +1 -1
- package/Stream/definition.d.ts +1 -1
- package/Stream/internal/DebounceState.d.ts +4 -4
- package/Stream/internal/Handoff.d.ts +5 -5
- package/Stream/internal/Pull.d.ts +1 -1
- package/Stream/internal/SinkEndReason.d.ts +1 -1
- package/TExit/definition.d.ts +3 -3
- package/TReentrantLock/definition.d.ts +1 -1
- package/TRef/definition.d.ts +1 -1
- package/TxnId.d.ts +1 -1
- package/_cjs/Clock/definition.cjs +1 -1
- package/_cjs/Clock/definition.cjs.map +1 -1
- package/_cjs/Console/definition.cjs +1 -1
- package/_cjs/Console/definition.cjs.map +1 -1
- package/_cjs/Fiber/FiberContext.cjs +161 -294
- package/_cjs/Fiber/FiberContext.cjs.map +1 -1
- package/_cjs/FiberRef/api.cjs +19 -10
- package/_cjs/FiberRef/api.cjs.map +1 -1
- package/_cjs/FiberRef/unsafe.cjs +9 -1
- package/_cjs/FiberRef/unsafe.cjs.map +1 -1
- package/_cjs/IO/api/core-scope.cjs +23 -15
- package/_cjs/IO/api/core-scope.cjs.map +1 -1
- package/_cjs/IO/api/ensuringChildren.cjs +4 -2
- package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +17 -9
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/supervised.cjs +26 -0
- package/_cjs/IO/api/supervised.cjs.map +1 -0
- package/_cjs/IO/api/withChildren.cjs +4 -2
- package/_cjs/IO/api/withChildren.cjs.map +1 -1
- package/_cjs/IO/api.cjs +69 -63
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +8 -226
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO.cjs +13 -0
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +1 -1
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Random/definition.cjs +1 -1
- package/_cjs/Random/definition.cjs.map +1 -1
- package/_cjs/Scope/definition.cjs +1 -1
- package/_cjs/Scope/definition.cjs.map +1 -1
- package/_mjs/Clock/definition.mjs +1 -1
- package/_mjs/Clock/definition.mjs.map +1 -1
- package/_mjs/Console/definition.mjs +1 -1
- package/_mjs/Console/definition.mjs.map +1 -1
- package/_mjs/Fiber/FiberContext.mjs +161 -293
- package/_mjs/Fiber/FiberContext.mjs.map +1 -1
- package/_mjs/FiberRef/api.mjs +18 -9
- package/_mjs/FiberRef/api.mjs.map +1 -1
- package/_mjs/FiberRef/unsafe.mjs +6 -0
- package/_mjs/FiberRef/unsafe.mjs.map +1 -1
- package/_mjs/IO/api/core-scope.mjs +21 -16
- package/_mjs/IO/api/core-scope.mjs.map +1 -1
- package/_mjs/IO/api/ensuringChildren.mjs +3 -2
- package/_mjs/IO/api/ensuringChildren.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +14 -6
- package/_mjs/IO/api/interrupt.mjs.map +1 -1
- package/_mjs/IO/api/supervised.mjs +14 -0
- package/_mjs/IO/api/supervised.mjs.map +1 -0
- package/_mjs/IO/api/withChildren.mjs +3 -2
- package/_mjs/IO/api/withChildren.mjs.map +1 -1
- package/_mjs/IO/api.mjs +67 -60
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +5 -184
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO.mjs +1 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +1 -1
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Random/definition.mjs +1 -1
- package/_mjs/Random/definition.mjs.map +1 -1
- package/_mjs/Scope/definition.mjs +1 -1
- package/_mjs/Scope/definition.mjs.map +1 -1
- package/_src/Clock/definition.ts +1 -1
- package/_src/Console/definition.ts +1 -1
- package/_src/Fiber/FiberContext.ts +21 -111
- package/_src/FiberRef/api.ts +15 -7
- package/_src/FiberRef/unsafe.ts +5 -0
- package/_src/IO/api/core-scope.ts +12 -10
- package/_src/IO/api/interrupt.ts +8 -3
- package/_src/IO/api/supervised.ts +14 -0
- package/_src/IO/api.ts +25 -26
- package/_src/IO/definition.ts +8 -158
- package/_src/IO.ts +1 -0
- package/_src/Layer/api.ts +1 -1
- package/_src/Random/definition.ts +1 -1
- package/_src/Scope/definition.ts +1 -1
- package/package.json +4 -3
@@ -1,13 +1,13 @@
|
|
1
1
|
import { ExitTag } from "@fncts/base/data/Exit";
|
2
2
|
|
3
3
|
import { FiberScope } from "../../FiberScope.js";
|
4
|
-
import { Fork,
|
4
|
+
import { Fork, IO, Race } from "../definition.js";
|
5
5
|
|
6
6
|
/**
|
7
7
|
* @tsplus getter fncts.io.IO daemonChildren
|
8
8
|
*/
|
9
9
|
export function daemonChildren<R, E, A>(self: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
10
|
-
return IO.defer(
|
10
|
+
return IO.defer(FiberRef.forkScopeOverride.locally(Just(FiberScope.global))(self));
|
11
11
|
}
|
12
12
|
|
13
13
|
/**
|
@@ -15,7 +15,9 @@ export function daemonChildren<R, E, A>(self: IO<R, E, A>, __tsplusTrace?: strin
|
|
15
15
|
*
|
16
16
|
* @tsplus static fncts.io.IOOps forkScope
|
17
17
|
*/
|
18
|
-
export const forkScope: UIO<FiberScope> =
|
18
|
+
export const forkScope: UIO<FiberScope> = IO.withFiberContext((fiber) =>
|
19
|
+
IO(fiber.unsafeGetRef(FiberRef.forkScopeOverride).getOrElse(fiber.scope)),
|
20
|
+
);
|
19
21
|
|
20
22
|
/**
|
21
23
|
* Retrieves the scope that will be used to supervise forked effects.
|
@@ -23,14 +25,14 @@ export const forkScope: UIO<FiberScope> = new GetForkScope(IO.succeedNow);
|
|
23
25
|
* @tsplus static fncts.io.IOOps forkScopeWith
|
24
26
|
*/
|
25
27
|
export function forkScopeWith<R, E, A>(f: (_: FiberScope) => IO<R, E, A>, __tsplusTrace?: string) {
|
26
|
-
return
|
28
|
+
return forkScope.flatMap(f);
|
27
29
|
}
|
28
30
|
|
29
31
|
export class ForkScopeRestore {
|
30
32
|
constructor(private scope: FiberScope) {}
|
31
33
|
|
32
34
|
readonly restore = <R, E, A>(ma: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> =>
|
33
|
-
|
35
|
+
FiberRef.forkScopeOverride.locally(Just(this.scope))(ma);
|
34
36
|
}
|
35
37
|
|
36
38
|
/**
|
@@ -45,8 +47,8 @@ export function forkScopeMask_<R, E, A>(
|
|
45
47
|
f: (restore: ForkScopeRestore) => IO<R, E, A>,
|
46
48
|
__tsplusTrace?: string,
|
47
49
|
): IO<R, E, A> {
|
48
|
-
return IO.forkScopeWith(
|
49
|
-
(
|
50
|
+
return IO.forkScopeWith((scope) =>
|
51
|
+
FiberRef.forkScopeOverride.locally(Just(newScope))(f(new ForkScopeRestore(scope))),
|
50
52
|
);
|
51
53
|
}
|
52
54
|
|
@@ -103,7 +105,7 @@ export type Grafter = <R, E, A>(effect: IO<R, E, A>) => IO<R, E, A>;
|
|
103
105
|
* @tsplus static fncts.io.IOOps transplant
|
104
106
|
*/
|
105
107
|
export function transplant<R, E, A>(f: (_: Grafter) => IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
106
|
-
return forkScopeWith((scope) => f((e) =>
|
108
|
+
return forkScopeWith((scope) => f((e) => FiberRef.forkScopeOverride.locally(Just(scope))(e)));
|
107
109
|
}
|
108
110
|
|
109
111
|
/**
|
@@ -124,7 +126,7 @@ export function forkDaemon<R, E, A>(ma: IO<R, E, A>, __tsplusTrace?: string): UR
|
|
124
126
|
* @tsplus fluent fncts.io.IO overrideForkScope
|
125
127
|
*/
|
126
128
|
export function overrideForkScope_<R, E, A>(ma: IO<R, E, A>, scope: FiberScope, __tsplusTrace?: string): IO<R, E, A> {
|
127
|
-
return
|
129
|
+
return FiberRef.forkScopeOverride.locally(Just(scope))(ma);
|
128
130
|
}
|
129
131
|
|
130
132
|
/**
|
@@ -134,5 +136,5 @@ export function overrideForkScope_<R, E, A>(ma: IO<R, E, A>, scope: FiberScope,
|
|
134
136
|
* @tsplus getter fncts.io.IO defaultForkScope
|
135
137
|
*/
|
136
138
|
export function defaultForkScope<R, E, A>(ma: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
137
|
-
return
|
139
|
+
return FiberRef.forkScopeOverride.locally(Nothing())(ma);
|
138
140
|
}
|
package/_src/IO/api/interrupt.ts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import { SetInterrupt } from "../definition.js";
|
2
|
-
|
3
1
|
/**
|
4
2
|
* Returns an effect that is interrupted as if by the specified fiber.
|
5
3
|
*
|
@@ -30,7 +28,14 @@ export function setInterruptStatus_<R, E, A>(
|
|
30
28
|
flag: InterruptStatus,
|
31
29
|
__tsplusTrace?: string,
|
32
30
|
): IO<R, E, A> {
|
33
|
-
return
|
31
|
+
return IO.withFiberContext((fiber) => {
|
32
|
+
const b = flag.toBoolean;
|
33
|
+
if (fiber.unsafeIsInterruptible !== b) {
|
34
|
+
fiber.interruptStatus.push(b);
|
35
|
+
fiber.unsafeRestoreInterruptStatus();
|
36
|
+
}
|
37
|
+
return self;
|
38
|
+
});
|
34
39
|
}
|
35
40
|
|
36
41
|
/**
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Returns an IO with the behavior of this one, but where all child
|
4
|
+
* fibers forked in the effect are reported to the specified supervisor.
|
5
|
+
*
|
6
|
+
* @tsplus fluent fncts.io.IO supervised
|
7
|
+
*/
|
8
|
+
export function supervised_<R, E, A>(
|
9
|
+
fa: IO<R, E, A>,
|
10
|
+
supervisor: Supervisor<any>,
|
11
|
+
__tsplusTrace?: string,
|
12
|
+
): IO<R, E, A> {
|
13
|
+
return FiberRef.currentSupervisor.locally(supervisor)(fa);
|
14
|
+
}
|
package/_src/IO/api.ts
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
+
import type { FiberStatus } from "../FiberStatus.js";
|
1
2
|
import type * as P from "@fncts/base/typeclass";
|
2
3
|
import type { _E, _R } from "@fncts/base/types";
|
3
4
|
import type { FiberContext } from "@fncts/io/Fiber/FiberContext";
|
4
5
|
import type { Canceler } from "@fncts/io/IO/definition";
|
5
6
|
|
6
7
|
import { identity, pipe, tuple } from "@fncts/base/data/function";
|
8
|
+
import { Stateful } from "@fncts/io/IO/definition";
|
7
9
|
import {
|
8
10
|
Async,
|
9
11
|
Chain,
|
10
12
|
Defer,
|
11
13
|
DeferWith,
|
12
|
-
Ensuring,
|
13
14
|
Fail,
|
14
|
-
FiberRefModifyAll,
|
15
15
|
Fork,
|
16
|
-
GetDescriptor,
|
17
|
-
GetInterrupt,
|
18
16
|
IO,
|
19
17
|
IOError,
|
20
18
|
Logged,
|
21
19
|
Match,
|
22
|
-
SetRuntimeConfig,
|
23
20
|
Succeed,
|
24
21
|
SucceedNow,
|
25
|
-
Supervise,
|
26
22
|
Yield,
|
27
23
|
} from "@fncts/io/IO/definition";
|
28
24
|
|
@@ -358,7 +354,7 @@ export function checkInterruptible<R, E, A>(
|
|
358
354
|
f: (i: InterruptStatus) => IO<R, E, A>,
|
359
355
|
__tsplusTrace?: string,
|
360
356
|
): IO<R, E, A> {
|
361
|
-
return
|
357
|
+
return IO.withFiberContext((fiber) => f(InterruptStatus.fromBoolean(fiber.unsafeIsInterruptible)));
|
362
358
|
}
|
363
359
|
|
364
360
|
/**
|
@@ -515,7 +511,7 @@ export const descriptor = descriptorWith(IO.succeedNow);
|
|
515
511
|
* @tsplus static fncts.io.IOOps descriptorWith
|
516
512
|
*/
|
517
513
|
export function descriptorWith<R, E, A>(f: (d: FiberDescriptor) => IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
518
|
-
return
|
514
|
+
return IO.withFiberContext((fiber) => f(fiber.unsafeGetDescriptor()));
|
519
515
|
}
|
520
516
|
|
521
517
|
/**
|
@@ -535,7 +531,10 @@ export function ensuring_<R, E, A, R1>(
|
|
535
531
|
finalizer: IO<R1, never, any>,
|
536
532
|
__tsplusTrace?: string,
|
537
533
|
): IO<R | R1, E, A> {
|
538
|
-
return
|
534
|
+
return IO.withFiberContext((fiber) => {
|
535
|
+
fiber.unsafeAddFinalizer(finalizer);
|
536
|
+
return self;
|
537
|
+
});
|
539
538
|
}
|
540
539
|
|
541
540
|
/**
|
@@ -1801,7 +1800,7 @@ export function sandboxWith_<R, E, A, E1>(
|
|
1801
1800
|
* @tsplus static fncts.io.IOOps setRuntimeConfig
|
1802
1801
|
*/
|
1803
1802
|
export function setRuntimeConfig(runtimeConfig: Lazy<RuntimeConfig>, __tsplusTrace?: string): UIO<void> {
|
1804
|
-
return IO.
|
1803
|
+
return IO.withFiberContext((fiber) => IO((fiber.runtimeConfig = runtimeConfig())));
|
1805
1804
|
}
|
1806
1805
|
|
1807
1806
|
/**
|
@@ -1839,21 +1838,6 @@ export function succeed<A>(effect: Lazy<A>, __tsplusTrace?: string): UIO<A> {
|
|
1839
1838
|
return new Succeed(effect, __tsplusTrace);
|
1840
1839
|
}
|
1841
1840
|
|
1842
|
-
/**
|
1843
|
-
*
|
1844
|
-
* Returns an IO with the behavior of this one, but where all child
|
1845
|
-
* fibers forked in the effect are reported to the specified supervisor.
|
1846
|
-
*
|
1847
|
-
* @tsplus fluent fncts.io.IO supervised
|
1848
|
-
*/
|
1849
|
-
export function supervised_<R, E, A>(
|
1850
|
-
fa: IO<R, E, A>,
|
1851
|
-
supervisor: Supervisor<any>,
|
1852
|
-
__tsplusTrace?: string,
|
1853
|
-
): IO<R, E, A> {
|
1854
|
-
return new Supervise(fa, supervisor);
|
1855
|
-
}
|
1856
|
-
|
1857
1841
|
/**
|
1858
1842
|
* @tsplus fluent fncts.io.IO summarized
|
1859
1843
|
*/
|
@@ -2051,7 +2035,22 @@ export function updateFiberRefs(
|
|
2051
2035
|
f: (fiberId: FiberId.Runtime, fiberRefs: FiberRefs) => FiberRefs,
|
2052
2036
|
__tsplusTrace?: string,
|
2053
2037
|
): UIO<void> {
|
2054
|
-
return
|
2038
|
+
return IO.withFiberContext((fiber) =>
|
2039
|
+
IO(() => {
|
2040
|
+
const newFiberRefs = f(fiber.fiberId, FiberRefs(fiber.fiberRefLocals.get));
|
2041
|
+
fiber.fiberRefLocals.set(newFiberRefs.fiberRefLocals);
|
2042
|
+
}),
|
2043
|
+
);
|
2044
|
+
}
|
2045
|
+
|
2046
|
+
/**
|
2047
|
+
* @tsplus static fncts.io.IOOps withFiberContext
|
2048
|
+
*/
|
2049
|
+
export function withFiberContext<R, E, A>(
|
2050
|
+
onState: (fiber: FiberContext<E, A>, status: FiberStatus) => IO<R, E, A>,
|
2051
|
+
__tsplusTrace?: string,
|
2052
|
+
): IO<R, E, A> {
|
2053
|
+
return new Stateful(onState, __tsplusTrace);
|
2055
2054
|
}
|
2056
2055
|
|
2057
2056
|
/**
|
package/_src/IO/definition.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { FiberStatus } from "../FiberStatus.js";
|
1
2
|
import type { Trace as Trace_ } from "@fncts/base/data/Trace";
|
2
3
|
import type { FiberContext } from "@fncts/io/Fiber/FiberContext";
|
3
4
|
|
@@ -7,7 +8,7 @@ export type IOTypeId = typeof IOTypeId;
|
|
7
8
|
export interface IOF extends HKT {
|
8
9
|
type: IO<this["R"], this["E"], this["A"]>;
|
9
10
|
variance: {
|
10
|
-
R: "
|
11
|
+
R: "+";
|
11
12
|
E: "+";
|
12
13
|
A: "+";
|
13
14
|
};
|
@@ -66,22 +67,9 @@ export const enum IOTag {
|
|
66
67
|
Fail = "Fail",
|
67
68
|
Yield = "Yield",
|
68
69
|
Race = "Race",
|
69
|
-
SetInterrupt = "SetInterrupt",
|
70
|
-
GetInterrupt = "GetInterrupt",
|
71
|
-
GetDescriptor = "GetDescriptor",
|
72
|
-
Supervise = "Supervise",
|
73
|
-
FiberRefModify = "FiberRefModify",
|
74
|
-
FiberRefLocally = "FiberRefLocally",
|
75
|
-
FiberRefDelete = "FiberRefDelete",
|
76
|
-
FiberRefWith = "FiberRefWith",
|
77
|
-
FiberRefModifyAll = "FiberRefModifyAll",
|
78
|
-
GetForkScope = "GetForkScope",
|
79
|
-
OverrideForkScope = "OverrideForkScope",
|
80
70
|
Trace = "Trace",
|
81
|
-
GetRuntimeConfig = "GetRuntimeConfig",
|
82
|
-
Ensuring = "Ensuring",
|
83
71
|
Logged = "Logged",
|
84
|
-
|
72
|
+
Stateful = "Stateful",
|
85
73
|
}
|
86
74
|
|
87
75
|
export function isIO(u: unknown): u is IO<any, any, any> {
|
@@ -236,134 +224,16 @@ export class Race<R, E, A, R1, E1, A1, R2, E2, A2, R3, E3, A3> extends IO<R | R1
|
|
236
224
|
}
|
237
225
|
}
|
238
226
|
|
239
|
-
|
240
|
-
|
241
|
-
*/
|
242
|
-
export class SetInterrupt<R, E, A> extends IO<R, E, A> {
|
243
|
-
readonly _tag = IOTag.SetInterrupt;
|
244
|
-
|
245
|
-
constructor(readonly io: IO<R, E, A>, readonly flag: InterruptStatus, readonly trace?: string) {
|
246
|
-
super();
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
/**
|
251
|
-
* @internal
|
252
|
-
*/
|
253
|
-
export class GetInterrupt<R, E, A> extends IO<R, E, A> {
|
254
|
-
readonly _tag = IOTag.GetInterrupt;
|
255
|
-
|
256
|
-
constructor(readonly f: (_: InterruptStatus) => IO<R, E, A>, readonly trace?: string) {
|
257
|
-
super();
|
258
|
-
}
|
259
|
-
}
|
260
|
-
|
261
|
-
/**
|
262
|
-
* @internal
|
263
|
-
*/
|
264
|
-
export class GetDescriptor<R, E, A> extends IO<R, E, A> {
|
265
|
-
readonly _tag = IOTag.GetDescriptor;
|
266
|
-
|
267
|
-
constructor(readonly f: (_: FiberDescriptor) => IO<R, E, A>, readonly trace?: string) {
|
268
|
-
super();
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
/**
|
273
|
-
* @internal
|
274
|
-
*/
|
275
|
-
export class Supervise<R, E, A> extends IO<R, E, A> {
|
276
|
-
readonly _tag = IOTag.Supervise;
|
277
|
-
|
278
|
-
constructor(readonly io: IO<R, E, A>, readonly supervisor: Supervisor<any>, readonly trace?: string) {
|
279
|
-
super();
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
/**
|
284
|
-
* @internal
|
285
|
-
*/
|
286
|
-
export class FiberRefModify<A, B> extends IO<never, never, B> {
|
287
|
-
readonly _tag = IOTag.FiberRefModify;
|
288
|
-
|
289
|
-
constructor(readonly fiberRef: FiberRef<unknown>, readonly f: (a: A) => readonly [B, A], readonly trace?: string) {
|
290
|
-
super();
|
291
|
-
}
|
292
|
-
}
|
293
|
-
|
294
|
-
export class FiberRefLocally<V, R, E, A> extends IO<R, E, A> {
|
295
|
-
readonly _tag = IOTag.FiberRefLocally;
|
227
|
+
export class Stateful<R, E, A> extends IO<R, E, A> {
|
228
|
+
readonly _tag = IOTag.Stateful;
|
296
229
|
constructor(
|
297
|
-
readonly
|
298
|
-
readonly fiberRef: FiberRef<V>,
|
299
|
-
readonly io: IO<R, E, A>,
|
230
|
+
readonly onState: (fiber: FiberContext<E, A>, status: FiberStatus) => IO<R, E, A>,
|
300
231
|
readonly trace?: string,
|
301
232
|
) {
|
302
233
|
super();
|
303
234
|
}
|
304
235
|
}
|
305
236
|
|
306
|
-
export class FiberRefDelete extends IO<never, never, void> {
|
307
|
-
readonly _tag = IOTag.FiberRefDelete;
|
308
|
-
constructor(readonly fiberRef: FiberRef<unknown>, readonly trace?: string) {
|
309
|
-
super();
|
310
|
-
}
|
311
|
-
}
|
312
|
-
|
313
|
-
export class FiberRefWith<A, P, R, E, B> extends IO<R, E, B> {
|
314
|
-
readonly _tag = IOTag.FiberRefWith;
|
315
|
-
constructor(readonly fiberRef: FiberRef<A>, readonly f: (a: A) => IO<R, E, B>, readonly trace?: string) {
|
316
|
-
super();
|
317
|
-
}
|
318
|
-
}
|
319
|
-
|
320
|
-
export class FiberRefModifyAll<A> extends IO<never, never, A> {
|
321
|
-
readonly _tag = IOTag.FiberRefModifyAll;
|
322
|
-
constructor(
|
323
|
-
readonly f: (fiberId: FiberId.Runtime, fiberRefs: FiberRefs) => readonly [A, FiberRefs],
|
324
|
-
readonly trace?: string,
|
325
|
-
) {
|
326
|
-
super();
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
/**
|
331
|
-
* @internal
|
332
|
-
*/
|
333
|
-
export class GetForkScope<R, E, A> extends IO<R, E, A> {
|
334
|
-
readonly _tag = IOTag.GetForkScope;
|
335
|
-
|
336
|
-
constructor(readonly f: (_: FiberScope) => IO<R, E, A>, readonly trace?: string) {
|
337
|
-
super();
|
338
|
-
}
|
339
|
-
}
|
340
|
-
|
341
|
-
/**
|
342
|
-
* @internal
|
343
|
-
*/
|
344
|
-
export class OverrideForkScope<R, E, A> extends IO<R, E, A> {
|
345
|
-
readonly _tag = IOTag.OverrideForkScope;
|
346
|
-
|
347
|
-
constructor(readonly io: IO<R, E, A>, readonly forkScope: Maybe<FiberScope>, readonly trace?: string) {
|
348
|
-
super();
|
349
|
-
}
|
350
|
-
}
|
351
|
-
|
352
|
-
export class GetRuntimeConfig<R, E, A> extends IO<R, E, A> {
|
353
|
-
readonly _tag = IOTag.GetRuntimeConfig;
|
354
|
-
|
355
|
-
constructor(readonly f: (_: RuntimeConfig) => IO<R, E, A>, readonly trace?: string) {
|
356
|
-
super();
|
357
|
-
}
|
358
|
-
}
|
359
|
-
|
360
|
-
export class Ensuring<R, E, A, R1> extends IO<R | R1, E, A> {
|
361
|
-
readonly _tag = IOTag.Ensuring;
|
362
|
-
constructor(readonly io: IO<R, E, A>, readonly finalizer: IO<R1, never, any>, readonly trace?: string) {
|
363
|
-
super();
|
364
|
-
}
|
365
|
-
}
|
366
|
-
|
367
237
|
export class Logged extends IO<never, never, void> {
|
368
238
|
readonly _tag = IOTag.Logged;
|
369
239
|
constructor(
|
@@ -378,13 +248,6 @@ export class Logged extends IO<never, never, void> {
|
|
378
248
|
}
|
379
249
|
}
|
380
250
|
|
381
|
-
export class SetRuntimeConfig extends IO<never, never, void> {
|
382
|
-
readonly _tag = IOTag.SetRuntimeConfig;
|
383
|
-
constructor(readonly runtimeConfig: RuntimeConfig, readonly trace?: string) {
|
384
|
-
super();
|
385
|
-
}
|
386
|
-
}
|
387
|
-
|
388
251
|
export type Instruction =
|
389
252
|
| Chain<any, any, any, any, any, any>
|
390
253
|
| SucceedNow<any>
|
@@ -393,27 +256,14 @@ export type Instruction =
|
|
393
256
|
| Async<any, any, any, any>
|
394
257
|
| Match<any, any, any, any, any, any, any, any, any>
|
395
258
|
| Fork<any, any, any>
|
396
|
-
| SetInterrupt<any, any, any>
|
397
|
-
| GetInterrupt<any, any, any>
|
398
259
|
| Fail<any>
|
399
|
-
| GetDescriptor<any, any, any>
|
400
260
|
| Yield
|
401
261
|
| Defer<any, any, any>
|
402
262
|
| DeferWith<any, any, any>
|
403
|
-
|
|
404
|
-
| FiberRefLocally<any, any, any, any>
|
405
|
-
| FiberRefDelete
|
406
|
-
| FiberRefWith<any, any, any, any, any>
|
407
|
-
| FiberRefModifyAll<any>
|
263
|
+
| Stateful<any, any, any>
|
408
264
|
| Race<any, any, any, any, any, any, any, any, any, any, any, any>
|
409
|
-
| Supervise<any, any, any>
|
410
|
-
| GetForkScope<any, any, any>
|
411
|
-
| OverrideForkScope<any, any, any>
|
412
265
|
| Trace
|
413
|
-
|
|
414
|
-
| Ensuring<any, any, any, any>
|
415
|
-
| Logged
|
416
|
-
| SetRuntimeConfig;
|
266
|
+
| Logged;
|
417
267
|
|
418
268
|
/**
|
419
269
|
* @tsplus macro identity
|
package/_src/IO.ts
CHANGED
@@ -46,6 +46,7 @@ export * from "./IO/api/scopeWith.js";
|
|
46
46
|
export * from "./IO/api/sequenceT.js";
|
47
47
|
export * from "./IO/api/sleep.js";
|
48
48
|
export * from "./IO/api/stateful.js";
|
49
|
+
export * from "./IO/api/supervised.js";
|
49
50
|
export * from "./IO/api/timeout.js";
|
50
51
|
export * from "./IO/api/withChildren.js";
|
51
52
|
export * from "./IO/api/withEarlyRelease.js";
|
package/_src/Layer/api.ts
CHANGED
@@ -285,7 +285,7 @@ export function retry_<RIn, E, ROut, S, RIn1>(
|
|
285
285
|
schedule: Schedule.WithState<S, RIn1, E, any>,
|
286
286
|
__tsplusTrace?: string,
|
287
287
|
): Layer<RIn | RIn1, E, ROut> {
|
288
|
-
const tag = Tag<{ readonly state: S }>();
|
288
|
+
const tag = Tag<{ readonly state: S }>("fncts.io.Layer.retryState");
|
289
289
|
return Layer.succeedNow({ state: schedule.initial }, tag).flatMap((environment) =>
|
290
290
|
retryLoop(self, schedule, environment.get(tag).state, tag),
|
291
291
|
);
|
package/_src/Scope/definition.ts
CHANGED
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fncts/io",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.18",
|
4
4
|
"dependencies": {
|
5
|
-
"@fncts/base": "0.0.
|
6
|
-
"@fncts/
|
5
|
+
"@fncts/base": "0.0.18",
|
6
|
+
"@fncts/transformers": "0.0.2",
|
7
|
+
"@fncts/typelevel": "0.0.14"
|
7
8
|
},
|
8
9
|
"exports": {
|
9
10
|
"./*": {
|