@fncts/io 0.0.42 → 0.0.43
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/IO/api.d.ts +6 -0
- package/IO.d.ts +1 -0
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -8
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +14 -23
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +4 -16
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +18 -33
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +2 -8
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +4 -7
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
- package/_cjs/IO/api.cjs +26 -42
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +3 -6
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +11 -0
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +2 -5
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +1 -4
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +8 -35
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/DerivedAll.cjs +8 -35
- package/_cjs/Ref/DerivedAll.cjs.map +1 -1
- package/_cjs/STM/api/core-api.cjs +1 -4
- package/_cjs/STM/api/core-api.cjs.map +1 -1
- package/_cjs/STM/api.cjs +4 -16
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +1 -7
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +1 -7
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Stream/api/zipAllWith.cjs +1 -4
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWithChunks.cjs +1 -4
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +16 -37
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/TRef/definition.cjs +20 -74
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +2 -8
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +14 -23
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
- package/_mjs/Channel/api/mergeWith.mjs +4 -16
- package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +18 -33
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +2 -8
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
- package/_mjs/IO/api/asyncInterrupt.mjs +4 -7
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
- package/_mjs/IO/api.mjs +24 -40
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +3 -6
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +1 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +2 -5
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Push/api.mjs +1 -4
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Ref/Derived.mjs +8 -35
- package/_mjs/Ref/Derived.mjs.map +1 -1
- package/_mjs/Ref/DerivedAll.mjs +8 -35
- package/_mjs/Ref/DerivedAll.mjs.map +1 -1
- package/_mjs/STM/api/core-api.mjs +1 -4
- package/_mjs/STM/api/core-api.mjs.map +1 -1
- package/_mjs/STM/api.mjs +4 -16
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/Schedule/api.mjs +1 -7
- package/_mjs/Schedule/api.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +1 -7
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Stream/api/zipAllWith.mjs +1 -4
- package/_mjs/Stream/api/zipAllWith.mjs.map +1 -1
- package/_mjs/Stream/api/zipWithChunks.mjs +1 -4
- package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +16 -37
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/TRef/definition.mjs +20 -74
- package/_mjs/TRef/definition.mjs.map +1 -1
- package/_src/Channel/api/mapOutConcurrentIO.ts +5 -5
- package/_src/Channel/api/mergeAllWith.ts +9 -9
- package/_src/Channel/api/mergeWith.ts +16 -16
- package/_src/Channel/api.ts +12 -32
- package/_src/Channel/internal/SingleProducerAsyncInput.ts +2 -2
- package/_src/IO/api/asyncInterrupt.ts +4 -4
- package/_src/IO/api.ts +25 -19
- package/_src/IO/runtime.ts +3 -6
- package/_src/IO.ts +1 -0
- package/_src/Layer/api.ts +1 -4
- package/_src/Push/api.ts +4 -4
- package/_src/Ref/Derived.ts +18 -20
- package/_src/Ref/DerivedAll.ts +18 -21
- package/_src/STM/api/core-api.ts +1 -1
- package/_src/STM/api.ts +4 -4
- package/_src/Schedule/api.ts +8 -8
- package/_src/Sink/api.ts +8 -8
- package/_src/Stream/api/zipAllWith.ts +4 -4
- package/_src/Stream/api/zipWithChunks.ts +4 -4
- package/_src/Stream/api.ts +20 -22
- package/_src/TRef/definition.ts +33 -36
- package/_src/index.ts +1 -0
- package/index.d.ts +1 -0
- package/package.json +4 -4
package/_src/Ref/Derived.ts
CHANGED
@@ -35,8 +35,8 @@ export class Derived<EA, EB, A, B> extends RefInternal<never, never, EA, EB, A,
|
|
35
35
|
new Derived<EC, ED, C, D>((f) =>
|
36
36
|
f(
|
37
37
|
value,
|
38
|
-
(s) => getEither(s).match(
|
39
|
-
(c) => ca(c).flatMap((a) => setEither(a).match(
|
38
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
39
|
+
(c) => ca(c).flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
40
40
|
),
|
41
41
|
),
|
42
42
|
);
|
@@ -54,43 +54,41 @@ export class Derived<EA, EB, A, B> extends RefInternal<never, never, EA, EB, A,
|
|
54
54
|
new DerivedAll<EC, ED, C, D>((f) =>
|
55
55
|
f(
|
56
56
|
value,
|
57
|
-
(s) => getEither(s).match(
|
57
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
58
58
|
(c) => (s) =>
|
59
59
|
getEither(s)
|
60
|
-
.match(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
.flatMap((a) => setEither(a).match(
|
60
|
+
.match(
|
61
|
+
(eb) => Either.left(ec(eb)),
|
62
|
+
(b) => ca(c)(b),
|
63
|
+
)
|
64
|
+
.flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
65
65
|
),
|
66
66
|
),
|
67
67
|
);
|
68
68
|
}
|
69
69
|
|
70
70
|
get get(): FIO<EB, B> {
|
71
|
-
return this.use((value, getEither) =>
|
72
|
-
value.get.flatMap((s) => getEither(s).match({ Left: IO.failNow, Right: IO.succeedNow })),
|
73
|
-
);
|
71
|
+
return this.use((value, getEither) => value.get.flatMap((s) => getEither(s).match(IO.failNow, IO.succeedNow)));
|
74
72
|
}
|
75
73
|
|
76
74
|
set(a: A): FIO<EA, void> {
|
77
|
-
return this.use((value, _, setEither) => setEither(a).match(
|
75
|
+
return this.use((value, _, setEither) => setEither(a).match(IO.failNow, (s) => value.set(s)));
|
78
76
|
}
|
79
77
|
|
80
78
|
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): IO<never, EA | EB, C> {
|
81
79
|
return this.use(
|
82
80
|
(value, getEither, setEither) =>
|
83
81
|
value.modify((s) =>
|
84
|
-
getEither(s).match(
|
85
|
-
|
86
|
-
|
82
|
+
getEither(s).match(
|
83
|
+
(e) => tuple(Either.left(e), s),
|
84
|
+
(a1) => {
|
87
85
|
const [b, a2] = f(a1);
|
88
|
-
return setEither(a2).match(
|
89
|
-
|
90
|
-
|
91
|
-
|
86
|
+
return setEither(a2).match(
|
87
|
+
(e) => tuple(Either.left(e), s),
|
88
|
+
(s) => tuple(Either.right<EA | EB, C>(b), s),
|
89
|
+
);
|
92
90
|
},
|
93
|
-
|
91
|
+
),
|
94
92
|
).absolve,
|
95
93
|
);
|
96
94
|
}
|
package/_src/Ref/DerivedAll.ts
CHANGED
@@ -34,9 +34,8 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
|
|
34
34
|
new DerivedAll((f) =>
|
35
35
|
f(
|
36
36
|
value,
|
37
|
-
(s) => getEither(s).match(
|
38
|
-
(c) => (s) =>
|
39
|
-
ca(c).flatMap((a) => setEither(a)(s).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
|
37
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
38
|
+
(c) => (s) => ca(c).flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
40
39
|
),
|
41
40
|
),
|
42
41
|
);
|
@@ -54,30 +53,28 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
|
|
54
53
|
new DerivedAll((f) =>
|
55
54
|
f(
|
56
55
|
value,
|
57
|
-
(s) => getEither(s).match(
|
56
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
58
57
|
(c) => (s) =>
|
59
58
|
getEither(s)
|
60
|
-
.match(
|
61
|
-
.flatMap((a) => setEither(a)(s).match(
|
59
|
+
.match((e) => Either.left(ec(e)), ca(c))
|
60
|
+
.flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
62
61
|
),
|
63
62
|
),
|
64
63
|
);
|
65
64
|
}
|
66
65
|
|
67
66
|
get get(): FIO<EB, B> {
|
68
|
-
return this.use((value, getEither) =>
|
69
|
-
value.get.flatMap((s) => getEither(s).match({ Left: IO.failNow, Right: IO.succeedNow })),
|
70
|
-
);
|
67
|
+
return this.use((value, getEither) => value.get.flatMap((s) => getEither(s).match(IO.failNow, IO.succeedNow)));
|
71
68
|
}
|
72
69
|
|
73
70
|
set(a: A): FIO<EA, void> {
|
74
71
|
return this.use(
|
75
72
|
(value, _, setEither) =>
|
76
73
|
value.modify((s) =>
|
77
|
-
setEither(a)(s).match(
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
setEither(a)(s).match(
|
75
|
+
(e) => [Either.left(e), s] as [Either<EA, void>, typeof s],
|
76
|
+
(s) => [Either.right(undefined), s],
|
77
|
+
),
|
81
78
|
).absolve,
|
82
79
|
);
|
83
80
|
}
|
@@ -86,16 +83,16 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
|
|
86
83
|
return this.use(
|
87
84
|
(value, getEither, setEither) =>
|
88
85
|
value.modify((s) =>
|
89
|
-
getEither(s).match(
|
90
|
-
|
91
|
-
|
86
|
+
getEither(s).match(
|
87
|
+
(e) => tuple(Either.left(e), s),
|
88
|
+
(a1) => {
|
92
89
|
const [b, a2] = f(a1);
|
93
|
-
return setEither(a2)(s).match(
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
return setEither(a2)(s).match(
|
91
|
+
(e) => tuple(Either.left(e), s),
|
92
|
+
(s) => tuple(Either.right<EA | EB, C>(b), s),
|
93
|
+
);
|
97
94
|
},
|
98
|
-
|
95
|
+
),
|
99
96
|
).absolve,
|
100
97
|
);
|
101
98
|
}
|
package/_src/STM/api/core-api.ts
CHANGED
package/_src/STM/api.ts
CHANGED
@@ -429,7 +429,7 @@ export function foreach<A, R, E, B>(
|
|
429
429
|
* @tsplus static fncts.io.STMOps fromEither
|
430
430
|
*/
|
431
431
|
export function fromEither<E, A>(e: Lazy<Either<E, A>>, __tsplusTrace?: string): STM<never, E, A> {
|
432
|
-
return STM.defer(e().match(
|
432
|
+
return STM.defer(e().match(STM.failNow, STM.succeedNow));
|
433
433
|
}
|
434
434
|
|
435
435
|
/**
|
@@ -438,7 +438,7 @@ export function fromEither<E, A>(e: Lazy<Either<E, A>>, __tsplusTrace?: string):
|
|
438
438
|
* @tsplus static fncts.io.STMOps fromEitherNow
|
439
439
|
*/
|
440
440
|
export function fromEitherNow<E, A>(e: Either<E, A>, __tsplusTrace?: string): STM<never, E, A> {
|
441
|
-
return e.match(
|
441
|
+
return e.match(STM.failNow, STM.succeedNow);
|
442
442
|
}
|
443
443
|
|
444
444
|
/**
|
@@ -553,7 +553,7 @@ export function isSuccess<R, E, A>(stm: STM<R, E, A>, __tsplusTrace?: string) {
|
|
553
553
|
export function left<R, E, B, C>(stm: STM<R, E, Either<B, C>>, __tsplusTrace?: string): STM<R, Maybe<E>, B> {
|
554
554
|
return stm.matchSTM(
|
555
555
|
(e) => STM.fail(Just(e)),
|
556
|
-
(bc) => bc.match(
|
556
|
+
(bc) => bc.match(STM.succeedNow, () => STM.failNow(Nothing())),
|
557
557
|
);
|
558
558
|
}
|
559
559
|
|
@@ -564,7 +564,7 @@ export function left<R, E, B, C>(stm: STM<R, E, Either<B, C>>, __tsplusTrace?: s
|
|
564
564
|
*/
|
565
565
|
export function leftOrFail<C, E1>(orFail: (c: C) => E1, __tsplusTrace?: string) {
|
566
566
|
return <R, E, B>(stm: STM<R, E, Either<B, C>>): STM<R, E | E1, B> => {
|
567
|
-
return stm.flatMap((bc) => bc.match(
|
567
|
+
return stm.flatMap((bc) => bc.match(STM.succeedNow, (c) => STM.fail(orFail(c))));
|
568
568
|
};
|
569
569
|
}
|
570
570
|
|
package/_src/Schedule/api.ts
CHANGED
@@ -618,17 +618,17 @@ export function reconsiderIO<S, O, R1, O1>(
|
|
618
618
|
decision.match(
|
619
619
|
() =>
|
620
620
|
f(state, out, decision).map((r) =>
|
621
|
-
r.match(
|
622
|
-
|
623
|
-
|
624
|
-
|
621
|
+
r.match(
|
622
|
+
(out1) => [state, out1, Decision.Done],
|
623
|
+
([out1, _]) => [state, out1, Decision.Done],
|
624
|
+
),
|
625
625
|
),
|
626
626
|
() =>
|
627
627
|
f(state, out, decision).map((r) =>
|
628
|
-
r.match(
|
629
|
-
|
630
|
-
|
631
|
-
|
628
|
+
r.match(
|
629
|
+
(out1) => [state, out1, Decision.Done],
|
630
|
+
([out1, interval]) => [state, out1, Decision.continueWith(interval)],
|
631
|
+
),
|
632
632
|
),
|
633
633
|
),
|
634
634
|
),
|
package/_src/Sink/api.ts
CHANGED
@@ -567,20 +567,20 @@ function fromPushPull<R, E, In, L, Z>(
|
|
567
567
|
(inp: Conc<In>) =>
|
568
568
|
Channel.fromIO(push(Just(inp))).matchChannel(
|
569
569
|
([r, leftovers]) =>
|
570
|
-
r.match(
|
571
|
-
|
572
|
-
|
573
|
-
|
570
|
+
r.match(
|
571
|
+
(e) => Channel.writeNow(leftovers) > Channel.failNow(e),
|
572
|
+
(z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
|
573
|
+
),
|
574
574
|
() => fromPushPull(push),
|
575
575
|
),
|
576
576
|
Channel.failNow,
|
577
577
|
() =>
|
578
578
|
Channel.fromIO(push(Nothing())).matchChannel(
|
579
579
|
([r, leftovers]) =>
|
580
|
-
r.match(
|
581
|
-
|
582
|
-
|
583
|
-
|
580
|
+
r.match(
|
581
|
+
(e) => Channel.writeNow(leftovers) > Channel.failNow(e),
|
582
|
+
(z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
|
583
|
+
),
|
584
584
|
() => Channel.fromIO(IO.halt(new Error("empty sink"))),
|
585
585
|
),
|
586
586
|
);
|
@@ -132,8 +132,8 @@ function zipWithChunks<A, B, C>(
|
|
132
132
|
__tsplusTrace?: string,
|
133
133
|
): readonly [Conc<C>, State<A, B>] {
|
134
134
|
const [out, r] = zipChunks(leftChunk, rightChunk, f);
|
135
|
-
return r.match(
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
return r.match(
|
136
|
+
(leftChunk) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
|
137
|
+
(rightChunk) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
|
138
|
+
);
|
139
139
|
}
|
@@ -73,10 +73,10 @@ function handleSuccess<A1, A2, A3>(
|
|
73
73
|
__tsplusTrace?: string,
|
74
74
|
): readonly [Conc<A3>, State<A1, A2>] {
|
75
75
|
const [out, remaining] = f(leftChunk, rightChunk);
|
76
|
-
return remaining.match(
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
return remaining.match(
|
77
|
+
(l) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
|
78
|
+
(r) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
|
79
|
+
);
|
80
80
|
}
|
81
81
|
|
82
82
|
/**
|
package/_src/Stream/api.ts
CHANGED
@@ -3,7 +3,7 @@ import type { Canceler } from "../IO.js";
|
|
3
3
|
import type { PDequeue, PEnqueue, PQueue } from "../Queue.js";
|
4
4
|
import type { SinkEndReason } from "./internal/SinkEndReason.js";
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { identity, tuple } from "@fncts/base/data/function";
|
7
7
|
|
8
8
|
import { MergeDecision } from "../Channel/internal/MergeDecision.js";
|
9
9
|
import { Hub } from "../Hub.js";
|
@@ -56,9 +56,7 @@ export function aggregateAsyncWithin<R1, E1, A1, B, R2, C>(
|
|
56
56
|
__tsplusTrace?: string,
|
57
57
|
) {
|
58
58
|
return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, B> => {
|
59
|
-
return stream
|
60
|
-
.aggregateAsyncWithinEither(sink, schedule)
|
61
|
-
.filterMap((cb) => cb.match({ Left: () => Nothing(), Right: Maybe.just }));
|
59
|
+
return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
|
62
60
|
};
|
63
61
|
}
|
64
62
|
|
@@ -167,14 +165,14 @@ export function aggregateAsyncWithinEither<R1, E1, A1, B, R2, C>(
|
|
167
165
|
(scheduleExit, sinkFiber) =>
|
168
166
|
IO.fromExit(scheduleExit).matchCauseIO(
|
169
167
|
(cause) =>
|
170
|
-
cause.failureOrCause.match(
|
171
|
-
|
168
|
+
cause.failureOrCause.match(
|
169
|
+
() =>
|
172
170
|
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
173
171
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
174
|
-
|
172
|
+
(cause) =>
|
175
173
|
handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
|
176
174
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
177
|
-
|
175
|
+
),
|
178
176
|
(c) =>
|
179
177
|
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
180
178
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
|
@@ -257,8 +255,8 @@ export function asyncInterrupt<R, E, A>(
|
|
257
255
|
}),
|
258
256
|
),
|
259
257
|
);
|
260
|
-
return eitherStream.match(
|
261
|
-
|
258
|
+
return eitherStream.match(
|
259
|
+
(canceler) => {
|
262
260
|
const loop: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.unwrap(
|
263
261
|
output.take
|
264
262
|
.flatMap((take) => take.done)
|
@@ -269,8 +267,8 @@ export function asyncInterrupt<R, E, A>(
|
|
269
267
|
);
|
270
268
|
return new Stream(loop).ensuring(canceler);
|
271
269
|
},
|
272
|
-
|
273
|
-
|
270
|
+
(stream) => Stream.unwrap(output.shutdown.as(stream)),
|
271
|
+
);
|
274
272
|
}),
|
275
273
|
);
|
276
274
|
}
|
@@ -338,10 +336,10 @@ export function asyncIO<R, E, A, R1 = R, E1 = E>(
|
|
338
336
|
.matchCauseIO(
|
339
337
|
(cause) =>
|
340
338
|
output.shutdown.as(
|
341
|
-
cause.failureOrCause.match(
|
342
|
-
|
343
|
-
|
344
|
-
|
339
|
+
cause.failureOrCause.match(
|
340
|
+
(maybeError) => maybeError.match(() => Channel.endNow(undefined), Channel.failNow),
|
341
|
+
Channel.failCauseNow,
|
342
|
+
),
|
345
343
|
),
|
346
344
|
(as) => IO.succeed(Channel.writeNow(as) > loop),
|
347
345
|
),
|
@@ -579,7 +577,7 @@ function bufferSignalConsumer<R, E, A>(
|
|
579
577
|
*/
|
580
578
|
export function catchAll<R1, E, E1, A1>(f: (e: E) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
581
579
|
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
|
582
|
-
return stream.catchAllCause((cause) => cause.failureOrCause.match(
|
580
|
+
return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
|
583
581
|
};
|
584
582
|
}
|
585
583
|
|
@@ -3230,7 +3228,7 @@ export function toPull<R, E, A>(
|
|
3230
3228
|
__tsplusTrace?: string,
|
3231
3229
|
): IO<R | Scope, never, IO<R, Maybe<E>, Conc<A>>> {
|
3232
3230
|
return stream.channel.toPull.map((io) =>
|
3233
|
-
io.mapError(Maybe.just).flatMap((r) => r.match(
|
3231
|
+
io.mapError(Maybe.just).flatMap((r) => r.match(() => IO.failNow(Nothing()), IO.succeedNow)),
|
3234
3232
|
);
|
3235
3233
|
}
|
3236
3234
|
|
@@ -3487,22 +3485,22 @@ export function zipWithLatest<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A,
|
|
3487
3485
|
Stream.repeatIOMaybe(left)
|
3488
3486
|
.mergeEither(Stream.repeatIOMaybe(right))
|
3489
3487
|
.mapIO((ab) =>
|
3490
|
-
ab.match(
|
3491
|
-
|
3488
|
+
ab.match(
|
3489
|
+
(leftChunk) =>
|
3492
3490
|
latest.modify(([_, rightLatest]) =>
|
3493
3491
|
tuple(
|
3494
3492
|
leftChunk.map((a) => f(a, rightLatest)),
|
3495
3493
|
tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
|
3496
3494
|
),
|
3497
3495
|
),
|
3498
|
-
|
3496
|
+
(rightChunk) =>
|
3499
3497
|
latest.modify(([leftLatest, _]) =>
|
3500
3498
|
tuple(
|
3501
3499
|
rightChunk.map((b) => f(leftLatest, b)),
|
3502
3500
|
tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
|
3503
3501
|
),
|
3504
3502
|
),
|
3505
|
-
|
3503
|
+
),
|
3506
3504
|
)
|
3507
3505
|
.flatMap(Stream.fromChunkNow),
|
3508
3506
|
),
|
package/_src/TRef/definition.ts
CHANGED
@@ -162,8 +162,8 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
162
162
|
(getEither, setEither, value, atomic) =>
|
163
163
|
new Derived((f) =>
|
164
164
|
f(
|
165
|
-
(s) => getEither(s).match(
|
166
|
-
(c) => ca(c).flatMap((a) => setEither(a).match(
|
165
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
166
|
+
(c) => ca(c).flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
167
167
|
value,
|
168
168
|
atomic,
|
169
169
|
),
|
@@ -181,11 +181,11 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
181
181
|
(getEither, setEither, value, atomic) =>
|
182
182
|
new DerivedAll((f) =>
|
183
183
|
f(
|
184
|
-
(s) => getEither(s).match(
|
184
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
185
185
|
(c) => (s) =>
|
186
186
|
getEither(s)
|
187
|
-
.match(
|
188
|
-
.flatMap((a) => setEither(a).match(
|
187
|
+
.match((e) => Either.left(ec(e)), ca(c))
|
188
|
+
.flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
189
189
|
value,
|
190
190
|
atomic,
|
191
191
|
),
|
@@ -195,29 +195,27 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
195
195
|
|
196
196
|
get get(): STM<never, EB, B> {
|
197
197
|
return this.use((getEither, _setEither, value, _atomic) =>
|
198
|
-
value.get.flatMap((s) => getEither(s).match(
|
198
|
+
value.get.flatMap((s) => getEither(s).match(STM.failNow, STM.succeedNow)),
|
199
199
|
);
|
200
200
|
}
|
201
201
|
|
202
202
|
set(a: A, __tsplusTrace?: string | undefined): STM<never, EA, void> {
|
203
|
-
return this.use((_getEither, setEither, value, _atomic) =>
|
204
|
-
setEither(a).match({ Left: STM.failNow, Right: (s) => value.set(s) }),
|
205
|
-
);
|
203
|
+
return this.use((_getEither, setEither, value, _atomic) => setEither(a).match(STM.failNow, (s) => value.set(s)));
|
206
204
|
}
|
207
205
|
|
208
206
|
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): STM<never, EA | EB, C> {
|
209
207
|
return this.use((getEither, setEither, value, _atomic) =>
|
210
208
|
value.modify((s) =>
|
211
|
-
getEither(s).match(
|
212
|
-
|
213
|
-
|
209
|
+
getEither(s).match(
|
210
|
+
(e) => [Either.left<EA | EB, C>(e), s],
|
211
|
+
(a1) => {
|
214
212
|
const [b, a2] = f(a1);
|
215
|
-
return setEither(a2).match(
|
216
|
-
|
217
|
-
|
218
|
-
|
213
|
+
return setEither(a2).match(
|
214
|
+
(e) => [Either.left(e), s],
|
215
|
+
(s) => [Either.right(b), s],
|
216
|
+
);
|
219
217
|
},
|
220
|
-
|
218
|
+
),
|
221
219
|
),
|
222
220
|
).absolve;
|
223
221
|
}
|
@@ -258,9 +256,8 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
258
256
|
(getEither, setEither, value, atomic) =>
|
259
257
|
new DerivedAll((f) =>
|
260
258
|
f(
|
261
|
-
(s) => getEither(s).match(
|
262
|
-
(c) => (s) =>
|
263
|
-
ca(c).flatMap((a) => setEither(a)(s).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
|
259
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
260
|
+
(c) => (s) => ca(c).flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
264
261
|
value,
|
265
262
|
atomic,
|
266
263
|
),
|
@@ -278,11 +275,11 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
278
275
|
(getEither, setEither, value, atomic) =>
|
279
276
|
new DerivedAll((f) =>
|
280
277
|
f(
|
281
|
-
(s) => getEither(s).match(
|
278
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
282
279
|
(c) => (s) =>
|
283
280
|
getEither(s)
|
284
|
-
.match(
|
285
|
-
.flatMap((a) => setEither(a)(s).match(
|
281
|
+
.match((e) => Either.left(ec(e)), ca(c))
|
282
|
+
.flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
286
283
|
value,
|
287
284
|
atomic,
|
288
285
|
),
|
@@ -292,17 +289,17 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
292
289
|
|
293
290
|
get get(): STM<never, EB, B> {
|
294
291
|
return this.use((getEither, _setEither, value, _atomic) =>
|
295
|
-
value.get.flatMap((s) => getEither(s).match(
|
292
|
+
value.get.flatMap((s) => getEither(s).match(STM.failNow, STM.succeedNow)),
|
296
293
|
);
|
297
294
|
}
|
298
295
|
|
299
296
|
set(a: A, __tsplusTrace?: string | undefined): STM<never, EA, void> {
|
300
297
|
return this.use((_getEither, setEither, value, _atomic) =>
|
301
298
|
value.modify((s) =>
|
302
|
-
setEither(a)(s).match(
|
303
|
-
|
304
|
-
|
305
|
-
|
299
|
+
setEither(a)(s).match(
|
300
|
+
(e) => [Either.left(e), s] as [Either<EA, void>, typeof s],
|
301
|
+
(s) => [Either.right(undefined), s],
|
302
|
+
),
|
306
303
|
),
|
307
304
|
).absolve;
|
308
305
|
}
|
@@ -310,16 +307,16 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
310
307
|
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): STM<never, EA | EB, C> {
|
311
308
|
return this.use((getEither, setEither, value, atomic) =>
|
312
309
|
value.modify((s) =>
|
313
|
-
getEither(s).match(
|
314
|
-
|
315
|
-
|
310
|
+
getEither(s).match(
|
311
|
+
(e) => [Either.left<EA | EB, C>(e), s],
|
312
|
+
(a1) => {
|
316
313
|
const [b, a2] = f(a1);
|
317
|
-
return setEither(a2)(s).match(
|
318
|
-
|
319
|
-
|
320
|
-
|
314
|
+
return setEither(a2)(s).match(
|
315
|
+
(e) => [Either.left(e), s],
|
316
|
+
(s) => [Either.right(b), s],
|
317
|
+
);
|
321
318
|
},
|
322
|
-
|
319
|
+
),
|
323
320
|
),
|
324
321
|
).absolve;
|
325
322
|
}
|
package/_src/index.ts
CHANGED
@@ -38,6 +38,7 @@ export type {} from "./IO.js";
|
|
38
38
|
export type {} from "./Hub.js";
|
39
39
|
export type {} from "./Future.js";
|
40
40
|
export type {} from "./FiberStatus.js";
|
41
|
+
export type {} from "./FiberSet.js";
|
41
42
|
export type {} from "./FiberScope.js";
|
42
43
|
export type {} from "./FiberRefs.js";
|
43
44
|
export type {} from "./FiberRef.js";
|
package/index.d.ts
CHANGED
@@ -36,6 +36,7 @@ export type {} from "./IO.js";
|
|
36
36
|
export type {} from "./Hub.js";
|
37
37
|
export type {} from "./Future.js";
|
38
38
|
export type {} from "./FiberStatus.js";
|
39
|
+
export type {} from "./FiberSet.js";
|
39
40
|
export type {} from "./FiberScope.js";
|
40
41
|
export type {} from "./FiberRefs.js";
|
41
42
|
export type {} from "./FiberRef.js";
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fncts/io",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.43",
|
4
4
|
"dependencies": {
|
5
|
-
"@fncts/base": "0.0.
|
6
|
-
"@fncts/transformers": "0.0.
|
7
|
-
"@fncts/typelevel": "0.0.
|
5
|
+
"@fncts/base": "0.0.35",
|
6
|
+
"@fncts/transformers": "0.0.9",
|
7
|
+
"@fncts/typelevel": "0.0.18"
|
8
8
|
},
|
9
9
|
"exports": {
|
10
10
|
"./*": {
|