@fncts/io 0.0.2 → 0.0.5
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/Channel/UpstreamPullRequest/api.d.ts +1 -1
- package/Channel/api.d.ts +2 -2
- package/Clock/api.d.ts +3 -1
- package/Clock/definition.d.ts +3 -1
- package/Clock/live.d.ts +2 -0
- package/Fiber/api/interruptFork.d.ts +1 -1
- package/FiberRef/constructors.d.ts +0 -53
- package/FiberRef/unsafe.d.ts +53 -0
- package/FiberRef.d.ts +1 -0
- package/Future/constructors.d.ts +3 -3
- package/IO/api/asyncIO.d.ts +6 -0
- package/IO/api/ensuringChildren.d.ts +7 -0
- package/IO/api/sequenceT.d.ts +2 -3
- package/IO/api/sleep.d.ts +3 -1
- package/IO/api/timeout.d.ts +14 -0
- package/IO/api.d.ts +2 -2
- package/IO/definition.d.ts +8 -4
- package/IO.d.ts +3 -0
- package/IOSpec.d.ts +10 -1
- package/InterruptStatus/constructors.d.ts +3 -3
- package/Latch.d.ts +3 -0
- package/Schedule/Decision.d.ts +1 -1
- package/Schedule/api.d.ts +1 -1
- package/Schedule.d.ts +0 -1
- package/Scope/Finalizer/definition.d.ts +1 -1
- package/Scope/ReleaseMap/definition.d.ts +1 -1
- package/Stream/api.d.ts +5 -22
- package/Stream/internal/DebounceState.d.ts +3 -3
- package/Stream/internal/Handoff.d.ts +9 -9
- package/Stream/internal/SinkEndReason.d.ts +6 -18
- package/TFuture/definition.d.ts +1 -1
- package/TSemaphore/definition.d.ts +1 -1
- package/_cjs/Cached.cjs +3 -3
- package/_cjs/Channel/ChildExecutorDecision.cjs +2 -2
- package/_cjs/Channel/UpstreamPullRequest/api.cjs +3 -3
- package/_cjs/Channel/UpstreamPullRequest/api.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullRequest.cjs +2 -2
- package/_cjs/Channel/UpstreamPullStrategy.cjs +1 -1
- package/_cjs/Channel/api/interruptWhen.cjs +1 -1
- package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
- package/_cjs/Channel/api/mapOutIOC.cjs +1 -1
- package/_cjs/Channel/api/mapOutIOC.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +6 -6
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +14 -14
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/core-api.cjs +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +2 -2
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +8 -7
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/Channel.cjs +3 -3
- package/_cjs/Clock/api.cjs.map +1 -1
- package/_cjs/Clock/live.cjs +1 -1
- package/_cjs/Clock/live.cjs.map +1 -1
- package/_cjs/Clock.cjs +3 -3
- package/_cjs/Console.cjs +3 -3
- package/_cjs/Fiber/FiberContext.cjs +58 -57
- package/_cjs/Fiber/FiberContext.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptFork.cjs +1 -1
- package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
- package/_cjs/Fiber/constructors.cjs +2 -2
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/Fiber.cjs +23 -23
- package/_cjs/FiberRef/constructors.cjs +3 -84
- package/_cjs/FiberRef/constructors.cjs.map +1 -1
- package/_cjs/FiberRef/unsafe.cjs +94 -0
- package/_cjs/FiberRef/unsafe.cjs.map +1 -0
- package/_cjs/FiberRef.cjs +18 -5
- package/_cjs/FiberRef.cjs.map +1 -1
- package/_cjs/FiberRefs/join.cjs +2 -2
- package/_cjs/FiberRefs/join.cjs.map +1 -1
- package/_cjs/FiberRefs.cjs +3 -3
- package/_cjs/FiberScope.cjs +2 -2
- package/_cjs/FiberState/constructors.cjs +1 -1
- package/_cjs/FiberState.cjs +3 -3
- package/_cjs/FiberStatus/constructors.cjs +1 -1
- package/_cjs/FiberStatus.cjs +2 -2
- package/_cjs/Future/constructors.cjs +2 -4
- package/_cjs/Future/constructors.cjs.map +1 -1
- package/_cjs/Future.cjs +3 -3
- package/_cjs/Hub.cjs +2 -2
- package/_cjs/IO/api/asyncIO.cjs +37 -0
- package/_cjs/IO/api/asyncIO.cjs.map +1 -0
- package/_cjs/IO/api/concurrency.cjs +1 -1
- package/_cjs/IO/api/core-scope.cjs +1 -1
- package/_cjs/IO/api/ensuringChildren.cjs +24 -0
- package/_cjs/IO/api/ensuringChildren.cjs.map +1 -0
- package/_cjs/IO/api/environment.cjs +1 -1
- package/_cjs/IO/api/interrupt.cjs +5 -5
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/sleep.cjs.map +1 -1
- package/_cjs/IO/api/timeout.cjs +42 -0
- package/_cjs/IO/api/timeout.cjs.map +1 -0
- package/_cjs/IO/api.cjs +41 -40
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +9 -6
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +2 -2
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +86 -47
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/IOEnv/services.cjs +1 -1
- package/_cjs/IOEnv.cjs +3 -3
- package/_cjs/InterruptStatus/constructors.cjs +3 -7
- package/_cjs/InterruptStatus/constructors.cjs.map +1 -1
- package/_cjs/InterruptStatus.cjs +2 -2
- package/_cjs/Layer/api.cjs +5 -3
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Layer.cjs +3 -3
- package/_cjs/Logger.cjs +3 -3
- package/_cjs/Queue/api.cjs +7 -7
- package/_cjs/Queue.cjs +5 -5
- package/_cjs/Random.cjs +3 -3
- package/_cjs/Ref/Atomic/Atomic.cjs +3 -3
- package/_cjs/Ref/Atomic/api.cjs +10 -6
- package/_cjs/Ref/Atomic/api.cjs.map +1 -1
- package/_cjs/Ref/Atomic.cjs +2 -2
- package/_cjs/Ref/Derived.cjs +2 -2
- package/_cjs/Ref/DerivedAll.cjs +1 -1
- package/_cjs/Ref/Synchronized/api.cjs +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +1 -1
- package/_cjs/Ref/api/get.cjs +1 -1
- package/_cjs/Ref/api/match.cjs +1 -1
- package/_cjs/Ref/api/matchAll.cjs +1 -1
- package/_cjs/Ref/api/modify.cjs +1 -1
- package/_cjs/Ref/api/set.cjs +1 -1
- package/_cjs/Ref/api.cjs +8 -8
- package/_cjs/Ref/constructors.cjs +1 -1
- package/_cjs/Ref.cjs +9 -9
- package/_cjs/STM/api/core-api.cjs +1 -1
- package/_cjs/STM/api/core-constructors.cjs +1 -1
- package/_cjs/STM/api.cjs +2 -2
- package/_cjs/STM/driver.cjs +1 -1
- package/_cjs/STM/internal/Entry.cjs +1 -1
- package/_cjs/STM/internal/Journal.cjs +2 -2
- package/_cjs/STM.cjs +5 -5
- package/_cjs/Schedule/Decision.cjs.map +1 -1
- package/_cjs/Schedule/api/driver.cjs +11 -9
- package/_cjs/Schedule/api/driver.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +49 -49
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Schedule.cjs +4 -17
- package/_cjs/Schedule.cjs.map +1 -1
- package/_cjs/Scope/Finalizer/definition.cjs +6 -4
- package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
- package/_cjs/Scope/Finalizer.cjs +1 -1
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +1 -1
- package/_cjs/Scope/ReleaseMap/api.cjs +1 -1
- package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -1
- package/_cjs/Scope/ReleaseMap/definition.cjs +4 -2
- package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap.cjs +3 -3
- package/_cjs/Scope/api.cjs +1 -1
- package/_cjs/Scope.cjs +2 -2
- package/_cjs/ScopedRef.cjs +2 -2
- package/_cjs/Sink/api.cjs +1 -1
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Sink.cjs +2 -2
- package/_cjs/State/api.cjs +2 -2
- package/_cjs/State/definition.cjs +1 -1
- package/_cjs/State.cjs +2 -2
- package/_cjs/Stream/api/zipAllWith.cjs +1 -1
- package/_cjs/Stream/api/zipWith.cjs +1 -1
- package/_cjs/Stream/api.cjs +308 -308
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/Stream/internal/DebounceState.cjs.map +1 -1
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
- package/_cjs/Stream/internal/SinkEndReason.cjs +2 -37
- package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -1
- package/_cjs/Stream.cjs +2 -2
- package/_cjs/Supervisor/constructors.cjs +1 -1
- package/_cjs/Supervisor.cjs +3 -3
- package/_cjs/TExit/constructors.cjs +1 -1
- package/_cjs/TExit.cjs +2 -2
- package/_cjs/TFuture/definition.cjs +4 -2
- package/_cjs/TFuture/definition.cjs.map +1 -1
- package/_cjs/TFuture.cjs +3 -3
- package/_cjs/TRef/api.cjs +2 -2
- package/_cjs/TRef/constructors.cjs +3 -3
- package/_cjs/TRef.cjs +3 -3
- package/_cjs/TSemaphore/api.cjs +1 -1
- package/_cjs/TSemaphore/definition.cjs +4 -2
- package/_cjs/TSemaphore/definition.cjs.map +1 -1
- package/_cjs/TSemaphore.cjs +3 -3
- package/_cjs/collection/immutable/Conc.cjs +3 -3
- package/_mjs/Channel/UpstreamPullRequest/api.mjs +1 -2
- package/_mjs/Channel/UpstreamPullRequest/api.mjs.map +1 -1
- package/_mjs/Channel/api/interruptWhen.mjs +1 -1
- package/_mjs/Channel/api/interruptWhen.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutIOC.mjs +1 -1
- package/_mjs/Channel/api/mapOutIOC.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
- package/_mjs/Channel/api/mergeWith.mjs +6 -6
- package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +14 -14
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +2 -2
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +8 -7
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
- package/_mjs/Clock/api.mjs.map +1 -1
- package/_mjs/Clock/live.mjs +1 -1
- package/_mjs/Clock/live.mjs.map +1 -1
- package/_mjs/Fiber/FiberContext.mjs +58 -57
- package/_mjs/Fiber/FiberContext.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptFork.mjs +1 -1
- package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +1 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/FiberRef/constructors.mjs +3 -66
- package/_mjs/FiberRef/constructors.mjs.map +1 -1
- package/_mjs/FiberRef/unsafe.mjs +66 -0
- package/_mjs/FiberRef/unsafe.mjs.map +1 -0
- package/_mjs/FiberRef.mjs +2 -1
- package/_mjs/FiberRef.mjs.map +1 -1
- package/_mjs/FiberRefs/join.mjs +2 -2
- package/_mjs/FiberRefs/join.mjs.map +1 -1
- package/_mjs/Future/constructors.mjs +3 -4
- package/_mjs/Future/constructors.mjs.map +1 -1
- package/_mjs/IO/api/asyncIO.mjs +20 -0
- package/_mjs/IO/api/asyncIO.mjs.map +1 -0
- package/_mjs/IO/api/concurrency.mjs +1 -1
- package/_mjs/IO/api/ensuringChildren.mjs +11 -0
- package/_mjs/IO/api/ensuringChildren.mjs.map +1 -0
- package/_mjs/IO/api/environment.mjs +1 -1
- package/_mjs/IO/api/interrupt.mjs +4 -4
- package/_mjs/IO/api/interrupt.mjs.map +1 -1
- package/_mjs/IO/api/sleep.mjs.map +1 -1
- package/_mjs/IO/api/timeout.mjs +23 -0
- package/_mjs/IO/api/timeout.mjs.map +1 -0
- package/_mjs/IO/api.mjs +41 -40
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +6 -4
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +2 -2
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +3 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/IOEnv/services.mjs +1 -1
- package/_mjs/InterruptStatus/constructors.mjs +3 -3
- package/_mjs/InterruptStatus/constructors.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +4 -3
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Ref/Atomic/api.mjs +10 -6
- package/_mjs/Ref/Atomic/api.mjs.map +1 -1
- package/_mjs/Schedule/Decision.mjs.map +1 -1
- package/_mjs/Schedule/api/driver.mjs +10 -9
- package/_mjs/Schedule/api/driver.mjs.map +1 -1
- package/_mjs/Schedule/api.mjs +49 -49
- package/_mjs/Schedule/api.mjs.map +1 -1
- package/_mjs/Schedule.mjs +0 -1
- package/_mjs/Schedule.mjs.map +1 -1
- package/_mjs/Scope/Finalizer/definition.mjs +5 -4
- package/_mjs/Scope/Finalizer/definition.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap/definition.mjs +3 -2
- package/_mjs/Scope/ReleaseMap/definition.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +1 -1
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +308 -302
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/Stream/internal/DebounceState.mjs.map +1 -1
- package/_mjs/Stream/internal/Handoff.mjs.map +1 -1
- package/_mjs/Stream/internal/SinkEndReason.mjs +1 -30
- package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -1
- package/_mjs/TFuture/definition.mjs +3 -2
- package/_mjs/TFuture/definition.mjs.map +1 -1
- package/_mjs/TSemaphore/definition.mjs +3 -2
- package/_mjs/TSemaphore/definition.mjs.map +1 -1
- package/_src/Channel/UpstreamPullRequest/api.ts +2 -3
- package/_src/Channel/api.ts +3 -3
- package/_src/Channel/internal/ChannelExecutor.ts +2 -2
- package/_src/Channel/internal/SingleProducerAsyncInput.ts +1 -0
- package/_src/Clock/api.ts +1 -1
- package/_src/Clock/definition.ts +1 -1
- package/_src/Clock/live.ts +2 -2
- package/_src/Fiber/FiberContext.ts +3 -2
- package/_src/Fiber/api/interruptFork.ts +1 -1
- package/_src/Fiber/constructors.ts +1 -1
- package/_src/FiberRef/constructors.ts +1 -78
- package/_src/FiberRef/unsafe.ts +79 -0
- package/_src/FiberRef.ts +1 -0
- package/_src/FiberRefs/join.ts +2 -2
- package/_src/Future/constructors.ts +1 -1
- package/_src/IO/api/asyncIO.ts +16 -0
- package/_src/IO/api/ensuringChildren.ts +11 -0
- package/_src/IO/api/interrupt.ts +2 -1
- package/_src/IO/api/sequenceT.ts +1 -1
- package/_src/IO/api/sleep.ts +1 -1
- package/_src/IO/api/timeout.ts +19 -0
- package/_src/IO/api.ts +6 -4
- package/_src/IO/definition.ts +8 -4
- package/_src/IO.ts +3 -0
- package/_src/InterruptStatus/constructors.ts +2 -0
- package/_src/Layer/api.ts +1 -1
- package/_src/Ref/Atomic/api.ts +4 -0
- package/_src/Schedule/Decision.ts +0 -2
- package/_src/Schedule/api/driver.ts +1 -1
- package/_src/Schedule/api.ts +0 -3
- package/_src/Schedule.ts +0 -1
- package/_src/Scope/Finalizer/definition.ts +1 -1
- package/_src/Scope/ReleaseMap/definition.ts +1 -1
- package/_src/Stream/api.ts +199 -134
- package/_src/Stream/internal/DebounceState.ts +2 -2
- package/_src/Stream/internal/Handoff.ts +9 -9
- package/_src/Stream/internal/SinkEndReason.ts +7 -25
- package/_src/TFuture/definition.ts +2 -2
- package/_src/TSemaphore/definition.ts +1 -1
- package/package.json +3 -3
- package/runTests.d.ts +1 -0
- package/Schedule/Interval.d.ts +0 -71
- package/_cjs/Schedule/Interval.cjs +0 -154
- package/_cjs/Schedule/Interval.cjs.map +0 -1
- package/_mjs/Schedule/Interval.mjs +0 -114
- package/_mjs/Schedule/Interval.mjs.map +0 -1
- package/_src/Schedule/Interval.ts +0 -103
@@ -1,8 +1,4 @@
|
|
1
|
-
import type { LogSpan } from "@fncts/io/LogSpan";
|
2
|
-
|
3
1
|
import { identity } from "@fncts/base/data/function";
|
4
|
-
import { Patch } from "@fncts/base/data/Patch";
|
5
|
-
import { FiberRefInternal } from "@fncts/io/FiberRef/definition";
|
6
2
|
|
7
3
|
function makeWith<Value, Patch>(
|
8
4
|
ref: Lazy<FiberRef.WithPatch<Value, Patch>>,
|
@@ -13,49 +9,6 @@ function makeWith<Value, Patch>(
|
|
13
9
|
);
|
14
10
|
}
|
15
11
|
|
16
|
-
/**
|
17
|
-
* @tsplus static fncts.io.FiberRefOps unsafeMakePatch
|
18
|
-
*/
|
19
|
-
export function unsafeMakePatch<Value, Patch>(
|
20
|
-
initial: Value,
|
21
|
-
diff: (oldValue: Value, newValue: Value) => Patch,
|
22
|
-
combine: (first: Patch, second: Patch) => Patch,
|
23
|
-
patch: (patch: Patch) => (oldValue: Value) => Value,
|
24
|
-
fork: Patch,
|
25
|
-
): FiberRef.WithPatch<Value, Patch> {
|
26
|
-
return new FiberRefInternal(initial, diff, combine, patch, fork);
|
27
|
-
}
|
28
|
-
|
29
|
-
/**
|
30
|
-
* @tsplus static fncts.io.FiberRefOps unsafeMakeEnvironment
|
31
|
-
*/
|
32
|
-
export function unsafeMakeEnvironment<A>(initial: Environment<A>): FiberRef.WithPatch<Environment<A>, Patch<A, A>> {
|
33
|
-
return FiberRef.unsafeMakePatch(
|
34
|
-
initial,
|
35
|
-
Patch.diff,
|
36
|
-
(first, second) => first.compose(second),
|
37
|
-
(patch) => (value) => patch(value),
|
38
|
-
Patch.empty(),
|
39
|
-
);
|
40
|
-
}
|
41
|
-
|
42
|
-
/**
|
43
|
-
* @tsplus static fncts.io.FiberRefOps unsafeMake
|
44
|
-
*/
|
45
|
-
export function unsafeMake<A>(
|
46
|
-
initial: A,
|
47
|
-
fork: (a: A) => A = identity,
|
48
|
-
join: (a0: A, a1: A) => A = (_, a) => a,
|
49
|
-
): FiberRef.WithPatch<A, (_: A) => A> {
|
50
|
-
return FiberRef.unsafeMakePatch(
|
51
|
-
initial,
|
52
|
-
(_, newValue) => () => newValue,
|
53
|
-
(first, second) => (value) => second(first(value)),
|
54
|
-
(patch) => (value) => join(value, patch(value)),
|
55
|
-
fork,
|
56
|
-
);
|
57
|
-
}
|
58
|
-
|
59
12
|
/**
|
60
13
|
* @tsplus static fncts.io.FiberRefOps make
|
61
14
|
*/
|
@@ -64,35 +17,5 @@ export function make<A>(
|
|
64
17
|
fork: (a: A) => A = identity,
|
65
18
|
join: (a: A, a1: A) => A = (_, a) => a,
|
66
19
|
): IO<Has<Scope>, never, FiberRef<A>> {
|
67
|
-
return makeWith(unsafeMake(initial, fork, join));
|
20
|
+
return makeWith(FiberRef.unsafeMake(initial, fork, join));
|
68
21
|
}
|
69
|
-
|
70
|
-
/**
|
71
|
-
* @tsplus static fncts.io.FiberRefOps forkScopeOverride
|
72
|
-
*/
|
73
|
-
export const forkScopeOverride = FiberRef.unsafeMake<Maybe<FiberScope>>(Nothing());
|
74
|
-
|
75
|
-
/**
|
76
|
-
* @tsplus static fncts.io.FiberRefOps currentEnvironment
|
77
|
-
*/
|
78
|
-
export const currentEnvironment = FiberRef.unsafeMakeEnvironment<unknown>(Environment.empty);
|
79
|
-
|
80
|
-
/**
|
81
|
-
* @tsplus static fncts.io.FiberRefOps fiberName
|
82
|
-
*/
|
83
|
-
export const fiberName = FiberRef.unsafeMake<Maybe<string>>(Nothing());
|
84
|
-
|
85
|
-
/**
|
86
|
-
* @tsplus static fncts.io.FiberRefOps currentLogLevel
|
87
|
-
*/
|
88
|
-
export const currentLogLevel = FiberRef.unsafeMake<LogLevel>(LogLevel.Info);
|
89
|
-
|
90
|
-
/**
|
91
|
-
* @tsplus static fncts.io.FiberRefOps currentLogSpan
|
92
|
-
*/
|
93
|
-
export const currentLogSpan = FiberRef.unsafeMake<List<LogSpan>>(Nil());
|
94
|
-
|
95
|
-
/**
|
96
|
-
* @tsplus static fncts.io.FiberRefOps currentLogAnnotations
|
97
|
-
*/
|
98
|
-
export const currentLogAnnotations = FiberRef.unsafeMake<HashMap<string, string>>(HashMap.makeDefault());
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import type { LogSpan } from "../LogSpan.js";
|
2
|
+
|
3
|
+
import { identity } from "@fncts/base/data/function";
|
4
|
+
import { Patch } from "@fncts/base/data/Patch";
|
5
|
+
|
6
|
+
import { FiberRefInternal } from "./definition.js";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @tsplus static fncts.io.FiberRefOps unsafeMakePatch
|
10
|
+
*/
|
11
|
+
export function unsafeMakePatch<Value, Patch>(
|
12
|
+
initial: Value,
|
13
|
+
diff: (oldValue: Value, newValue: Value) => Patch,
|
14
|
+
combine: (first: Patch, second: Patch) => Patch,
|
15
|
+
patch: (patch: Patch) => (oldValue: Value) => Value,
|
16
|
+
fork: Patch,
|
17
|
+
): FiberRef.WithPatch<Value, Patch> {
|
18
|
+
return new FiberRefInternal(initial, diff, combine, patch, fork);
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @tsplus static fncts.io.FiberRefOps unsafeMakeEnvironment
|
23
|
+
*/
|
24
|
+
export function unsafeMakeEnvironment<A>(initial: Environment<A>): FiberRef.WithPatch<Environment<A>, Patch<A, A>> {
|
25
|
+
return FiberRef.unsafeMakePatch(
|
26
|
+
initial,
|
27
|
+
Patch.diff,
|
28
|
+
(first, second) => first.compose(second),
|
29
|
+
(patch) => (value) => patch(value),
|
30
|
+
Patch.empty(),
|
31
|
+
);
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @tsplus static fncts.io.FiberRefOps unsafeMake
|
36
|
+
*/
|
37
|
+
export function unsafeMake<A>(
|
38
|
+
initial: A,
|
39
|
+
fork: (a: A) => A = identity,
|
40
|
+
join: (a0: A, a1: A) => A = (_, a) => a,
|
41
|
+
): FiberRef.WithPatch<A, (_: A) => A> {
|
42
|
+
return FiberRef.unsafeMakePatch(
|
43
|
+
initial,
|
44
|
+
(_, newValue) => () => newValue,
|
45
|
+
(first, second) => (value) => second(first(value)),
|
46
|
+
(patch) => (value) => join(value, patch(value)),
|
47
|
+
fork,
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @tsplus static fncts.io.FiberRefOps forkScopeOverride
|
53
|
+
*/
|
54
|
+
export const forkScopeOverride = FiberRef.unsafeMake<Maybe<FiberScope>>(Nothing(), () => Nothing());
|
55
|
+
|
56
|
+
/**
|
57
|
+
* @tsplus static fncts.io.FiberRefOps currentEnvironment
|
58
|
+
*/
|
59
|
+
export const currentEnvironment = FiberRef.unsafeMakeEnvironment<unknown>(Environment.empty);
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @tsplus static fncts.io.FiberRefOps fiberName
|
63
|
+
*/
|
64
|
+
export const fiberName = FiberRef.unsafeMake<Maybe<string>>(Nothing());
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @tsplus static fncts.io.FiberRefOps currentLogLevel
|
68
|
+
*/
|
69
|
+
export const currentLogLevel = FiberRef.unsafeMake<LogLevel>(LogLevel.Info);
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @tsplus static fncts.io.FiberRefOps currentLogSpan
|
73
|
+
*/
|
74
|
+
export const currentLogSpan = FiberRef.unsafeMake<List<LogSpan>>(Nil());
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @tsplus static fncts.io.FiberRefOps currentLogAnnotations
|
78
|
+
*/
|
79
|
+
export const currentLogAnnotations = FiberRef.unsafeMake<HashMap<string, string>>(HashMap.makeDefault());
|
package/_src/FiberRef.ts
CHANGED
package/_src/FiberRefs/join.ts
CHANGED
@@ -40,8 +40,8 @@ export function join(self: FiberRefs, fiberId: FiberId.Runtime, that: FiberRefs)
|
|
40
40
|
}
|
41
41
|
|
42
42
|
function compareFiberId(left: FiberId.Runtime, right: FiberId.Runtime): number {
|
43
|
-
const compare = Number.Ord.
|
44
|
-
return compare === 0 ? Number.Ord.
|
43
|
+
const compare = Number.Ord.compare(left.startTime, right.startTime);
|
44
|
+
return compare === 0 ? Number.Ord.compare(left.id, right.id) : compare;
|
45
45
|
}
|
46
46
|
|
47
47
|
/**
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* @tsplus static fncts.io.IOOps asyncIO
|
3
|
+
*/
|
4
|
+
export function asyncIO<R, E, A>(register: (k: (_: IO<R, E, A>) => void) => IO<R, E, void>): IO<R, E, A> {
|
5
|
+
return Do((Δ) => {
|
6
|
+
const f = Δ(Future.make<E, A>());
|
7
|
+
const r = Δ(IO.runtime<R>());
|
8
|
+
const a = Δ(
|
9
|
+
IO.uninterruptibleMask(({ restore }) => {
|
10
|
+
const io = register((k) => r.unsafeRunAsync(k.fulfill(f)));
|
11
|
+
return restore(io.catchAllCause((cause) => f.failCause(cause))).fork > restore(f.await);
|
12
|
+
}),
|
13
|
+
);
|
14
|
+
return a;
|
15
|
+
});
|
16
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @tsplus fluent fncts.io.IO ensuringChildren
|
3
|
+
*/
|
4
|
+
export function ensuringChildren<R, E, A, R1>(
|
5
|
+
self: IO<R, E, A>,
|
6
|
+
children: (_: Conc<Fiber.Runtime<any, any>>) => IO<R1, never, void>,
|
7
|
+
): IO<R & R1, E, A> {
|
8
|
+
return Supervisor.track.flatMap((supervisor) =>
|
9
|
+
self.supervised(supervisor).ensuring(supervisor.value.flatMap(children)),
|
10
|
+
);
|
11
|
+
}
|
package/_src/IO/api/interrupt.ts
CHANGED
@@ -100,7 +100,8 @@ export function onInterrupt_<R, E, A, R1>(
|
|
100
100
|
): IO<R & R1, E, A> {
|
101
101
|
return uninterruptibleMask(({ restore }) =>
|
102
102
|
restore(ma).matchCauseIO(
|
103
|
-
(cause) =>
|
103
|
+
(cause) =>
|
104
|
+
cause.interrupted ? cleanup(cause.interruptors).apSecond(IO.failCauseNow(cause)) : IO.failCauseNow(cause),
|
104
105
|
IO.succeedNow,
|
105
106
|
),
|
106
107
|
);
|
package/_src/IO/api/sequenceT.ts
CHANGED
@@ -7,6 +7,6 @@ import { identity, unsafeCoerce } from "@fncts/base/data/function";
|
|
7
7
|
*/
|
8
8
|
export function sequenceT<T extends ReadonlyNonEmptyArray<IO<any, any, any>>>(
|
9
9
|
...ios: T
|
10
|
-
): IO<_R<T[number]>, _E<T[number]>, { [K in keyof T]: _A<T[K]> }> {
|
10
|
+
): IO<HKT._R<T[number]>, HKT._E<T[number]>, { [K in keyof T]: HKT._A<T[K]> }> {
|
11
11
|
return unsafeCoerce(IO.foreach(ios, identity));
|
12
12
|
}
|
package/_src/IO/api/sleep.ts
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* @tsplus fluent fncts.io.IO timeoutTo
|
3
|
+
*/
|
4
|
+
export function timeoutTo<R, E, A, B, B1>(
|
5
|
+
self: IO<R, E, A>,
|
6
|
+
duration: Lazy<Duration>,
|
7
|
+
b: Lazy<B>,
|
8
|
+
f: (a: A) => B1,
|
9
|
+
__tsplusTrace?: string,
|
10
|
+
): IO<R, E, B | B1> {
|
11
|
+
return self.map(f).raceFirst(IO.sleep(duration).interruptible.as(b));
|
12
|
+
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @tsplus fluent fncts.io.IO timeout
|
16
|
+
*/
|
17
|
+
export function timeout<R, E, A>(self: IO<R, E, A>, duration: Lazy<Duration>): IO<R, E, Maybe<A>> {
|
18
|
+
return self.timeoutTo(duration, Nothing(), Maybe.just);
|
19
|
+
}
|
package/_src/IO/api.ts
CHANGED
@@ -761,12 +761,14 @@ export function foldLeft_<A, B, R, E>(
|
|
761
761
|
/**
|
762
762
|
* Combines an array of `IO`s using a `Monoid`
|
763
763
|
*
|
764
|
-
* @constrained
|
765
764
|
* @tsplus static fncts.io.IOOps foldMap
|
766
765
|
*/
|
767
|
-
export function foldMap_<M>(
|
768
|
-
|
769
|
-
|
766
|
+
export function foldMap_<R, E, A, M>(
|
767
|
+
as: Iterable<IO<R, E, A>>,
|
768
|
+
f: (a: A) => M,
|
769
|
+
/** @tsplus auto */ M: P.Monoid<M>,
|
770
|
+
): IO<R, E, M> {
|
771
|
+
return IO.foldLeft(as, M.nat, (m, a) => a.map((a) => M.combine(m, f(a))));
|
770
772
|
}
|
771
773
|
|
772
774
|
function foldRightLoop<A, B, R, E>(
|
package/_src/IO/definition.ts
CHANGED
@@ -4,15 +4,19 @@ import type { FiberContext } from "@fncts/io/Fiber/FiberContext";
|
|
4
4
|
export const IOTypeId = Symbol.for("fncts.io.IO");
|
5
5
|
export type IOTypeId = typeof IOTypeId;
|
6
6
|
|
7
|
+
export interface IOF extends IO<any, any, any> {}
|
8
|
+
|
7
9
|
/**
|
8
10
|
* @tsplus type fncts.io.IO
|
9
11
|
* @tsplus companion fncts.io.IOOps
|
10
12
|
*/
|
11
13
|
export abstract class IO<R, E, A> {
|
12
14
|
readonly _typeId: IOTypeId = IOTypeId;
|
13
|
-
readonly
|
14
|
-
readonly
|
15
|
-
readonly
|
15
|
+
readonly [HKT.F]!: IOF;
|
16
|
+
readonly [HKT.R]!: (_: R) => void;
|
17
|
+
readonly [HKT.E]!: () => E;
|
18
|
+
readonly [HKT.A]!: () => A;
|
19
|
+
readonly [HKT.T]!: IO<HKT._R<this>, HKT._E<this>, HKT._A<this>>;
|
16
20
|
}
|
17
21
|
|
18
22
|
/**
|
@@ -407,7 +411,7 @@ export type Instruction =
|
|
407
411
|
| SetRuntimeConfig;
|
408
412
|
|
409
413
|
/**
|
410
|
-
* @
|
414
|
+
* @tsplus macro identity
|
411
415
|
*/
|
412
416
|
export function concrete(_: IO<any, any, any>): Instruction {
|
413
417
|
// @ts-expect-error
|
package/_src/IO.ts
CHANGED
@@ -11,6 +11,7 @@ export * from "./IO/api/acquireReleaseInterruptible.js";
|
|
11
11
|
export * from "./IO/api/acquireReleaseInterruptibleExit.js";
|
12
12
|
export * from "./IO/api/addFinalizer.js";
|
13
13
|
export * from "./IO/api/addFinalizerExit.js";
|
14
|
+
export * from "./IO/api/asyncIO.js";
|
14
15
|
export * from "./IO/api/bracket.js";
|
15
16
|
export * from "./IO/api/bracketExit.js";
|
16
17
|
export * from "./IO/api/clockWith.js";
|
@@ -18,6 +19,7 @@ export * from "./IO/api/concurrency.js";
|
|
18
19
|
export * from "./IO/api/concurrentFinalizers.js";
|
19
20
|
export * from "./IO/api/consoleWith.js";
|
20
21
|
export * from "./IO/api/core-scope.js";
|
22
|
+
export * from "./IO/api/ensuringChildren.js";
|
21
23
|
export * from "./IO/api/environment.js";
|
22
24
|
export * from "./IO/api/foreachC.js";
|
23
25
|
export * from "./IO/api/foreachExec.js";
|
@@ -43,6 +45,7 @@ export * from "./IO/api/scopeWith.js";
|
|
43
45
|
export * from "./IO/api/sequenceT.js";
|
44
46
|
export * from "./IO/api/sleep.js";
|
45
47
|
export * from "./IO/api/stateful.js";
|
48
|
+
export * from "./IO/api/timeout.js";
|
46
49
|
export * from "./IO/api/withChildren.js";
|
47
50
|
export * from "./IO/api/withFinalizer.js";
|
48
51
|
export * from "./IO/api/withFinalizerExit.js";
|
package/_src/Layer/api.ts
CHANGED
@@ -282,7 +282,7 @@ function retryUpdate<S, RIn, E, X>(
|
|
282
282
|
.flatMap(([state, _, decision]) =>
|
283
283
|
decision._tag === DecisionTag.Done
|
284
284
|
? IO.failNow(e)
|
285
|
-
: Clock.sleep(decision.interval.startMilliseconds
|
285
|
+
: Clock.sleep(Duration.fromInterval(now, decision.interval.startMilliseconds)).as({ state }),
|
286
286
|
),
|
287
287
|
),
|
288
288
|
tag,
|
package/_src/Ref/Atomic/api.ts
CHANGED
@@ -29,6 +29,7 @@ export function getAndUpdateJust<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
|
|
29
29
|
return IO.succeed(() => {
|
30
30
|
const v = self.unsafeGet;
|
31
31
|
const o = f(v);
|
32
|
+
Maybe.concrete(o);
|
32
33
|
if (o._tag === "Just") {
|
33
34
|
self.unsafeSet(o.value);
|
34
35
|
}
|
@@ -56,6 +57,7 @@ export function modifyJust<A, B>(self: Atomic<A>, def: B, f: (a: A) => Maybe<rea
|
|
56
57
|
const v = self.unsafeGet;
|
57
58
|
const o = f(v);
|
58
59
|
|
60
|
+
Maybe.concrete(o);
|
59
61
|
if (o._tag === "Just") {
|
60
62
|
self.unsafeSet(o.value[1]);
|
61
63
|
return o.value[0];
|
@@ -91,6 +93,7 @@ export function updateJust<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
|
|
91
93
|
return IO.succeed(() => {
|
92
94
|
const o = f(self.unsafeGet);
|
93
95
|
|
96
|
+
Maybe.concrete(o);
|
94
97
|
if (o._tag === "Just") {
|
95
98
|
self.unsafeSet(o.value);
|
96
99
|
}
|
@@ -104,6 +107,7 @@ export function updateJustAndGet<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
|
|
104
107
|
return IO.succeed(() => {
|
105
108
|
const o = f(self.unsafeGet);
|
106
109
|
|
110
|
+
Maybe.concrete(o);
|
107
111
|
if (o._tag === "Just") {
|
108
112
|
self.unsafeSet(o.value);
|
109
113
|
}
|
@@ -19,7 +19,7 @@ export function driver<State, Env, In, Out>(
|
|
19
19
|
(interval) =>
|
20
20
|
ref
|
21
21
|
.set([Just(out), state1])
|
22
|
-
.apSecond(Clock.sleep(interval.startMilliseconds
|
22
|
+
.apSecond(Clock.sleep(Duration.fromInterval(now, interval.startMilliseconds)))
|
23
23
|
.as(out),
|
24
24
|
),
|
25
25
|
);
|
package/_src/Schedule/api.ts
CHANGED
package/_src/Schedule.ts
CHANGED