@fncts/io 0.0.34 → 0.0.36
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/Fiber/FiberRuntime.d.ts +7 -7
- package/Fiber/constructors.d.ts +5 -0
- package/IO/api/all.d.ts +41 -0
- package/IO/api/concurrency.d.ts +11 -0
- package/IO/api/interrupt.d.ts +1 -1
- package/IO/api/raceWith.d.ts +2 -1
- package/IO/api.d.ts +7 -2
- package/IO/definition.d.ts +103 -127
- package/IO.d.ts +1 -0
- package/Push/api.d.ts +86 -36
- package/Push/definition.d.ts +28 -13
- package/Push/internal.d.ts +7 -11
- package/RefSubject/Atomic.d.ts +8 -11
- package/RefSubject/Synchronized/definition.d.ts +4 -6
- package/RefSubject/api.d.ts +0 -1
- package/RefSubject/definition.d.ts +6 -8
- package/STM/definition.d.ts +19 -2
- package/Sink/api.d.ts +24 -24
- package/Subject/Atomic.d.ts +4 -6
- package/Subject/definition.d.ts +2 -2
- package/_cjs/Channel/api/runScoped.cjs +1 -1
- package/_cjs/Channel/api/runScoped.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +2 -2
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Fiber/FiberRuntime.cjs +110 -98
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
- package/_cjs/Fiber/constructors.cjs +10 -2
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/Future/api.cjs +1 -1
- package/_cjs/Future/api.cjs.map +1 -1
- package/_cjs/IO/api/all.cjs +33 -0
- package/_cjs/IO/api/all.cjs.map +1 -0
- package/_cjs/IO/api/asyncIO.cjs +1 -1
- package/_cjs/IO/api/asyncIO.cjs.map +1 -1
- package/_cjs/IO/api/bracketExit.cjs +1 -1
- package/_cjs/IO/api/bracketExit.cjs.map +1 -1
- package/_cjs/IO/api/concurrency.cjs +25 -4
- package/_cjs/IO/api/concurrency.cjs.map +1 -1
- package/_cjs/IO/api/disconnect.cjs +1 -1
- package/_cjs/IO/api/disconnect.cjs.map +1 -1
- package/_cjs/IO/api/foreachConcurrent.cjs +1 -1
- package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
- package/_cjs/IO/api/foreachExec.cjs +1 -1
- package/_cjs/IO/api/foreachExec.cjs.map +1 -1
- package/_cjs/IO/api/forkIn.cjs +1 -1
- package/_cjs/IO/api/forkIn.cjs.map +1 -1
- package/_cjs/IO/api/forkScoped.cjs +1 -1
- package/_cjs/IO/api/forkScoped.cjs.map +1 -1
- package/_cjs/IO/api/fulfill.cjs +1 -1
- package/_cjs/IO/api/fulfill.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +18 -6
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/raceWith.cjs +4 -4
- package/_cjs/IO/api/raceWith.cjs.map +1 -1
- package/_cjs/IO/api/timeout.cjs +8 -5
- package/_cjs/IO/api/timeout.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/IO/api.cjs +78 -20
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +14 -191
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO.cjs +11 -0
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Layer/MemoMap.cjs +1 -1
- package/_cjs/Layer/MemoMap.cjs.map +1 -1
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +238 -168
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +12 -13
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +37 -29
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/RefSubject/Atomic.cjs +15 -19
- package/_cjs/RefSubject/Atomic.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +9 -10
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
- package/_cjs/RefSubject/api.cjs +5 -6
- package/_cjs/RefSubject/api.cjs.map +1 -1
- package/_cjs/RefSubject/definition.cjs.map +1 -1
- package/_cjs/STM/api/atomically.cjs +1 -1
- package/_cjs/STM/api/atomically.cjs.map +1 -1
- package/_cjs/STM/api.cjs +2 -2
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs +1 -1
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/ScopedRef/api.cjs +2 -2
- package/_cjs/ScopedRef/api.cjs.map +1 -1
- package/_cjs/Semaphore.cjs +1 -1
- package/_cjs/Semaphore.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +13 -13
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +4 -5
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/TReentrantLock/api.cjs +2 -2
- package/_cjs/TReentrantLock/api.cjs.map +1 -1
- package/_cjs/TSemaphore/api.cjs +1 -1
- package/_cjs/TSemaphore/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +12 -17
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +12 -17
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/filterIO.cjs +2 -12
- package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/mapIO.cjs +3 -9
- package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +11 -27
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
- package/_mjs/Channel/api/runScoped.mjs +1 -1
- package/_mjs/Channel/api/runScoped.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +2 -2
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Fiber/FiberRuntime.mjs +111 -100
- package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +7 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/Future/api.mjs +1 -1
- package/_mjs/Future/api.mjs.map +1 -1
- package/_mjs/IO/api/all.mjs +24 -0
- package/_mjs/IO/api/all.mjs.map +1 -0
- package/_mjs/IO/api/asyncIO.mjs +1 -1
- package/_mjs/IO/api/asyncIO.mjs.map +1 -1
- package/_mjs/IO/api/bracketExit.mjs +1 -1
- package/_mjs/IO/api/bracketExit.mjs.map +1 -1
- package/_mjs/IO/api/concurrency.mjs +19 -2
- package/_mjs/IO/api/concurrency.mjs.map +1 -1
- package/_mjs/IO/api/disconnect.mjs +1 -1
- package/_mjs/IO/api/disconnect.mjs.map +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
- package/_mjs/IO/api/foreachExec.mjs +1 -1
- package/_mjs/IO/api/foreachExec.mjs.map +1 -1
- package/_mjs/IO/api/forkIn.mjs +1 -1
- package/_mjs/IO/api/forkIn.mjs.map +1 -1
- package/_mjs/IO/api/forkScoped.mjs +1 -1
- package/_mjs/IO/api/forkScoped.mjs.map +1 -1
- package/_mjs/IO/api/fulfill.mjs +1 -1
- package/_mjs/IO/api/fulfill.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +19 -7
- package/_mjs/IO/api/interrupt.mjs.map +1 -1
- package/_mjs/IO/api/raceWith.mjs +4 -4
- package/_mjs/IO/api/raceWith.mjs.map +1 -1
- package/_mjs/IO/api/timeout.mjs +8 -5
- package/_mjs/IO/api/timeout.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
- package/_mjs/IO/api.mjs +78 -23
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +12 -181
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO.mjs +1 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Layer/MemoMap.mjs +1 -1
- package/_mjs/Layer/MemoMap.mjs.map +1 -1
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Push/api.mjs +223 -166
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +9 -10
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +33 -22
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/RefSubject/Atomic.mjs +15 -19
- package/_mjs/RefSubject/Atomic.mjs.map +1 -1
- package/_mjs/RefSubject/Synchronized/definition.mjs +9 -10
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -1
- package/_mjs/RefSubject/api.mjs +6 -7
- package/_mjs/RefSubject/api.mjs.map +1 -1
- package/_mjs/RefSubject/definition.mjs.map +1 -1
- package/_mjs/STM/api/atomically.mjs +1 -1
- package/_mjs/STM/api/atomically.mjs.map +1 -1
- package/_mjs/STM/api.mjs +2 -2
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +1 -1
- package/_mjs/STM/definition.mjs.map +1 -1
- package/_mjs/ScopedRef/api.mjs +2 -2
- package/_mjs/ScopedRef/api.mjs.map +1 -1
- package/_mjs/Semaphore.mjs +1 -1
- package/_mjs/Semaphore.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +10 -10
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +4 -5
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_mjs/TReentrantLock/api.mjs +2 -2
- package/_mjs/TReentrantLock/api.mjs.map +1 -1
- package/_mjs/TSemaphore/api.mjs +1 -1
- package/_mjs/TSemaphore/api.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +12 -17
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +12 -17
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/filterIO.mjs +2 -12
- package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/mapIO.mjs +3 -9
- package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +11 -27
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -1
- package/_src/Channel/api.ts +3 -3
- package/_src/Fiber/FiberRuntime.ts +76 -75
- package/_src/Fiber/constructors.ts +5 -0
- package/_src/IO/api/all.ts +64 -0
- package/_src/IO/api/concurrency.ts +33 -0
- package/_src/IO/api/foreachExec.ts +2 -2
- package/_src/IO/api/interrupt.ts +20 -7
- package/_src/IO/api/raceWith.ts +4 -2
- package/_src/IO/api/timeout.ts +21 -1
- package/_src/IO/api.ts +79 -27
- package/_src/IO/definition.ts +155 -200
- package/_src/IO.ts +1 -0
- package/_src/Layer/api.ts +0 -1
- package/_src/Push/api.ts +305 -304
- package/_src/Push/definition.ts +19 -17
- package/_src/Push/internal.ts +63 -31
- package/_src/RefSubject/Atomic.ts +16 -22
- package/_src/RefSubject/Synchronized/definition.ts +6 -9
- package/_src/RefSubject/api.ts +9 -12
- package/_src/RefSubject/definition.ts +6 -8
- package/_src/STM/api.ts +0 -5
- package/_src/STM/definition.ts +8 -2
- package/_src/Sink/api.ts +9 -9
- package/_src/Subject/Atomic.ts +6 -8
- package/_src/Subject/definition.ts +2 -2
- package/_src/collection/immutable/Conc/dropUntilIO.ts +18 -15
- package/_src/collection/immutable/Conc/dropWhileIO.ts +18 -17
- package/_src/collection/immutable/Conc/filterIO.ts +1 -11
- package/_src/collection/immutable/Conc/mapIO.ts +2 -9
- package/_src/collection/immutable/Conc/takeWhileIO.ts +19 -28
- package/collection/immutable/Conc/filterIO.d.ts +1 -1
- package/collection/immutable/Conc/mapIO.d.ts +1 -1
- package/collection/immutable/Conc/takeWhileIO.d.ts +1 -1
- package/package.json +2 -2
package/_src/IO/definition.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { FiberRuntime } from "../Fiber/FiberRuntime.js";
|
|
2
2
|
import type { Running } from "../FiberStatus.js";
|
|
3
3
|
import type { RuntimeFlagsPatch } from "../RuntimeFlags.js";
|
|
4
|
+
import type { RuntimeFlags } from "../RuntimeFlags.js";
|
|
4
5
|
import type { Left, Right } from "@fncts/base/data/Either";
|
|
5
6
|
import type { Failure, Success } from "@fncts/base/data/Exit";
|
|
6
|
-
import type { Trace } from "@fncts/base/data/Trace";
|
|
7
|
-
|
|
8
|
-
import { RuntimeFlag } from "../RuntimeFlag.js";
|
|
9
|
-
import { RuntimeFlags } from "../RuntimeFlags.js";
|
|
10
7
|
|
|
11
8
|
export const IOVariance = Symbol.for("fncts.io.IO.Variance");
|
|
12
9
|
export type IOVariance = typeof IOVariance;
|
|
@@ -36,6 +33,10 @@ export abstract class IO<R, E, A> {
|
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
|
|
36
|
+
export type EnvironmentOf<T> = [T] extends [{ [IOVariance]: { _R: () => infer R } }] ? R : never;
|
|
37
|
+
export type ErrorOf<T> = [T] extends [{ [IOVariance]: { _E: () => infer E } }] ? E : never;
|
|
38
|
+
export type ValueOf<T> = [T] extends [{ [IOVariance]: { _A: () => infer A } }] ? A : never;
|
|
39
|
+
|
|
39
40
|
declare module "@fncts/base/data/Either/definition" {
|
|
40
41
|
interface Either<E, A> extends IO<never, E, A> {}
|
|
41
42
|
}
|
|
@@ -76,7 +77,7 @@ export type URIO<R, A> = IO<R, never, A>;
|
|
|
76
77
|
|
|
77
78
|
export type FIO<E, A> = IO<never, E, A>;
|
|
78
79
|
|
|
79
|
-
export const enum
|
|
80
|
+
export const enum IOTag {
|
|
80
81
|
SucceedNow,
|
|
81
82
|
Fail,
|
|
82
83
|
Sync,
|
|
@@ -95,199 +96,161 @@ export const enum IOOpCode {
|
|
|
95
96
|
UpdateTrace,
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export class Sync<A> extends IO<never, never, A> {
|
|
103
|
-
readonly _tag = IOOpCode.Sync;
|
|
104
|
-
constructor(readonly evaluate: () => A, readonly trace?: string) {
|
|
105
|
-
super();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export class Async<R, E, A> extends IO<R, E, A> {
|
|
110
|
-
readonly _tag = IOOpCode.Async;
|
|
111
|
-
constructor(
|
|
112
|
-
readonly registerCallback: (f: (_: IO<R, E, A>) => void) => any,
|
|
113
|
-
readonly blockingOn: () => FiberId,
|
|
114
|
-
readonly trace?: string,
|
|
115
|
-
) {
|
|
116
|
-
super();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @internal
|
|
122
|
-
*/
|
|
123
|
-
export class OnSuccessAndFailure<R, E, A, R1, E1, B, R2, E2, C> extends IO<R | R1 | R2, E1 | E2, B | C> {
|
|
124
|
-
readonly _tag = IOOpCode.OnSuccessAndFailure;
|
|
125
|
-
|
|
126
|
-
constructor(
|
|
127
|
-
readonly first: IO<R, E, A>,
|
|
128
|
-
readonly failureK: (cause: Cause<E>) => IO<R1, E1, B>,
|
|
129
|
-
readonly successK: (a: A) => IO<R2, E2, C>,
|
|
130
|
-
readonly trace?: string,
|
|
131
|
-
) {
|
|
132
|
-
super();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
onFailure(c: Cause<E>): IO<R | R1 | R2, E1 | E2, B | C> {
|
|
136
|
-
return this.failureK(c);
|
|
137
|
-
}
|
|
138
|
-
onSuccess(a: A): IO<R | R1 | R2, E1 | E2, B | C> {
|
|
139
|
-
return this.successK(a);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export class OnFailure<R, E, A, R1, E1, B> extends IO<R | R1, E1, A | B> {
|
|
144
|
-
readonly _tag = IOOpCode.OnFailure;
|
|
145
|
-
constructor(
|
|
146
|
-
readonly first: IO<R, E, A>,
|
|
147
|
-
readonly failureK: (cause: Cause<E>) => IO<R1, E1, B>,
|
|
148
|
-
readonly trace?: string,
|
|
149
|
-
) {
|
|
150
|
-
super();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
onFailure(c: Cause<E>): IO<R | R1, E1, A | B> {
|
|
154
|
-
return this.failureK(c);
|
|
155
|
-
}
|
|
156
|
-
onSuccess(a: A): IO<R | R1, E1, A | B> {
|
|
157
|
-
return new SucceedNow(a);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @internal
|
|
163
|
-
*/
|
|
164
|
-
export class OnSuccess<R, R1, E, E1, A, A1> extends IO<R | R1, E | E1, A1> {
|
|
165
|
-
readonly _tag = IOOpCode.OnSuccess;
|
|
166
|
-
constructor(readonly first: IO<R, E, A>, readonly successK: (a: A) => IO<R1, E1, A1>, readonly trace?: string) {
|
|
167
|
-
super();
|
|
168
|
-
}
|
|
169
|
-
onFailure(c: Cause<E>): IO<R | R1, E | E1, A1> {
|
|
170
|
-
return new Fail(c);
|
|
171
|
-
}
|
|
172
|
-
onSuccess(a: A): IO<R | R1, E | E1, A1> {
|
|
173
|
-
return this.successK(a);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @internal
|
|
179
|
-
*/
|
|
180
|
-
export class SucceedNow<A> extends IO<never, never, A> {
|
|
181
|
-
readonly _tag = IOOpCode.SucceedNow;
|
|
182
|
-
constructor(readonly value: A, readonly trace?: string) {
|
|
183
|
-
super();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export class UpdateRuntimeFlags extends IO<never, never, void> {
|
|
188
|
-
readonly _tag = IOOpCode.UpdateRuntimeFlags;
|
|
189
|
-
constructor(readonly update: RuntimeFlags.Patch, readonly trace?: string) {
|
|
190
|
-
super();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export class Interruptible<R, E, A> extends IO<R, E, A> {
|
|
195
|
-
readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
|
|
196
|
-
constructor(readonly effect: IO<R, E, A>, readonly trace?: string) {
|
|
197
|
-
super();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
readonly update: RuntimeFlags.Patch = RuntimeFlags.enable(RuntimeFlag.Interruption);
|
|
201
|
-
scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A> {
|
|
202
|
-
return this.effect;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export class Uninterruptible<R, E, A> extends IO<R, E, A> {
|
|
207
|
-
readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
|
|
208
|
-
constructor(readonly effect: IO<R, E, A>, readonly trace?: string) {
|
|
209
|
-
super();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
readonly update: RuntimeFlags.Patch = RuntimeFlags.disable(RuntimeFlag.Interruption);
|
|
213
|
-
scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A> {
|
|
214
|
-
return this.effect;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export class Dynamic<R, E, A> extends IO<R, E, A> {
|
|
219
|
-
readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
|
|
220
|
-
constructor(
|
|
221
|
-
readonly update: RuntimeFlagsPatch,
|
|
222
|
-
readonly f: (oldRuntimeFlags: RuntimeFlags) => IO<R, E, A>,
|
|
223
|
-
readonly trace?: string,
|
|
224
|
-
) {
|
|
225
|
-
super();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A> {
|
|
229
|
-
return this.f(oldRuntimeFlags);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export class GenerateStackTrace extends IO<never, never, Trace> {
|
|
234
|
-
readonly _tag = IOOpCode.GenerateStackTrace;
|
|
235
|
-
constructor(readonly trace?: string) {
|
|
236
|
-
super();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export class Stateful<R, E, A> extends IO<R, E, A> {
|
|
241
|
-
readonly _tag = IOOpCode.Stateful;
|
|
242
|
-
constructor(readonly onState: (fiber: FiberRuntime<E, A>, status: Running) => IO<R, E, A>, readonly trace?: string) {
|
|
243
|
-
super();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export class WhileLoop<R, E, A> extends IO<R, E, void> {
|
|
248
|
-
readonly _tag = IOOpCode.WhileLoop;
|
|
249
|
-
constructor(
|
|
250
|
-
readonly check: () => boolean,
|
|
251
|
-
readonly body: () => IO<R, E, A>,
|
|
252
|
-
readonly process: (a: A) => any,
|
|
253
|
-
readonly trace?: string,
|
|
254
|
-
) {
|
|
255
|
-
super();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
99
|
+
export type IOOp<Tag extends string | number, Body = {}> = IO<never, never, never> &
|
|
100
|
+
Body & {
|
|
101
|
+
readonly _tag: Tag;
|
|
102
|
+
};
|
|
258
103
|
|
|
259
|
-
export class
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
104
|
+
export class IOPrimitive {
|
|
105
|
+
public i0: any = undefined;
|
|
106
|
+
public i1: any = undefined;
|
|
107
|
+
public i2: any = undefined;
|
|
108
|
+
public trace: string | undefined = undefined;
|
|
109
|
+
[IOTypeId] = IOTypeId;
|
|
110
|
+
constructor(readonly _tag: Primitive["_tag"]) {}
|
|
264
111
|
}
|
|
265
112
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
*/
|
|
269
|
-
export class Fail<E> extends IO<never, E, never> {
|
|
270
|
-
readonly _tag = IOOpCode.Fail;
|
|
271
|
-
|
|
272
|
-
constructor(readonly cause: Lazy<Cause<E>>, readonly trace?: string) {
|
|
273
|
-
super();
|
|
274
|
-
}
|
|
113
|
+
export function isIO(u: unknown): u is IO<any, any, any> {
|
|
114
|
+
return isObject(u) && IOTypeId in u;
|
|
275
115
|
}
|
|
276
116
|
|
|
277
|
-
export
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
117
|
+
export interface Sync<A = any>
|
|
118
|
+
extends IOOp<
|
|
119
|
+
IOTag.Sync,
|
|
120
|
+
{
|
|
121
|
+
readonly i0: () => A;
|
|
122
|
+
readonly trace: string | undefined;
|
|
123
|
+
}
|
|
124
|
+
> {}
|
|
125
|
+
|
|
126
|
+
export interface Async<R = any, E = any, A = any>
|
|
127
|
+
extends IOOp<
|
|
128
|
+
IOTag.Async,
|
|
129
|
+
{
|
|
130
|
+
readonly i0: (resume: (io: Primitive) => void) => void;
|
|
131
|
+
readonly i1: () => FiberId;
|
|
132
|
+
readonly trace: string | undefined;
|
|
133
|
+
}
|
|
134
|
+
> {}
|
|
135
|
+
|
|
136
|
+
export interface OnSuccessAndFailure
|
|
137
|
+
extends IOOp<
|
|
138
|
+
IOTag.OnSuccessAndFailure,
|
|
139
|
+
{
|
|
140
|
+
readonly i0: Primitive;
|
|
141
|
+
readonly i1: (cause: Cause<unknown>) => Primitive;
|
|
142
|
+
readonly i2: (a: unknown) => Primitive;
|
|
143
|
+
readonly trace: string | undefined;
|
|
144
|
+
}
|
|
145
|
+
> {}
|
|
146
|
+
|
|
147
|
+
export interface OnFailure
|
|
148
|
+
extends IOOp<
|
|
149
|
+
IOTag.OnFailure,
|
|
150
|
+
{
|
|
151
|
+
readonly i0: Primitive;
|
|
152
|
+
readonly i1: (cause: Cause<unknown>) => Primitive;
|
|
153
|
+
readonly trace: string | undefined;
|
|
154
|
+
}
|
|
155
|
+
> {}
|
|
156
|
+
|
|
157
|
+
export interface OnSuccess
|
|
158
|
+
extends IOOp<
|
|
159
|
+
IOTag.OnSuccess,
|
|
160
|
+
{
|
|
161
|
+
readonly i0: Primitive;
|
|
162
|
+
readonly i1: (a: unknown) => Primitive;
|
|
163
|
+
readonly trace: string | undefined;
|
|
164
|
+
}
|
|
165
|
+
> {}
|
|
166
|
+
|
|
167
|
+
export interface SucceedNow
|
|
168
|
+
extends IOOp<
|
|
169
|
+
IOTag.SucceedNow,
|
|
170
|
+
{
|
|
171
|
+
readonly i0: any;
|
|
172
|
+
readonly trace: string | undefined;
|
|
173
|
+
}
|
|
174
|
+
> {}
|
|
175
|
+
|
|
176
|
+
export interface UpdateRuntimeFlags
|
|
177
|
+
extends IOOp<
|
|
178
|
+
IOTag.UpdateRuntimeFlags,
|
|
179
|
+
{
|
|
180
|
+
readonly i0: RuntimeFlags.Patch;
|
|
181
|
+
readonly trace: string | undefined;
|
|
182
|
+
}
|
|
183
|
+
> {}
|
|
184
|
+
|
|
185
|
+
export interface UpdateRuntimeFlagsWithin
|
|
186
|
+
extends IOOp<
|
|
187
|
+
IOTag.UpdateRuntimeFlagsWithin,
|
|
188
|
+
{
|
|
189
|
+
readonly i0: RuntimeFlagsPatch;
|
|
190
|
+
readonly i1: (oldRuntimeFlags: RuntimeFlags) => Primitive;
|
|
191
|
+
readonly trace: string | undefined;
|
|
192
|
+
}
|
|
193
|
+
> {}
|
|
194
|
+
|
|
195
|
+
export interface GenerateStackTrace
|
|
196
|
+
extends IOOp<
|
|
197
|
+
IOTag.GenerateStackTrace,
|
|
198
|
+
{
|
|
199
|
+
readonly trace: string | undefined;
|
|
200
|
+
}
|
|
201
|
+
> {}
|
|
202
|
+
|
|
203
|
+
export interface Stateful
|
|
204
|
+
extends IOOp<
|
|
205
|
+
IOTag.Stateful,
|
|
206
|
+
{
|
|
207
|
+
readonly i0: (fiber: FiberRuntime<any, any>, status: Running) => Primitive;
|
|
208
|
+
readonly trace: string | undefined;
|
|
209
|
+
}
|
|
210
|
+
> {}
|
|
211
|
+
|
|
212
|
+
export interface WhileLoop
|
|
213
|
+
extends IOOp<
|
|
214
|
+
IOTag.WhileLoop,
|
|
215
|
+
{
|
|
216
|
+
readonly i0: () => boolean;
|
|
217
|
+
readonly i1: () => Primitive;
|
|
218
|
+
readonly i2: (a: any) => any;
|
|
219
|
+
readonly trace: string | undefined;
|
|
220
|
+
}
|
|
221
|
+
> {}
|
|
222
|
+
|
|
223
|
+
export interface YieldNow
|
|
224
|
+
extends IOOp<
|
|
225
|
+
IOTag.YieldNow,
|
|
226
|
+
{
|
|
227
|
+
readonly trace: string | undefined;
|
|
228
|
+
}
|
|
229
|
+
> {}
|
|
230
|
+
|
|
231
|
+
export interface Fail
|
|
232
|
+
extends IOOp<
|
|
233
|
+
IOTag.Fail,
|
|
234
|
+
{
|
|
235
|
+
readonly i0: () => Cause<unknown>;
|
|
236
|
+
readonly trace: string | undefined;
|
|
237
|
+
}
|
|
238
|
+
> {}
|
|
239
|
+
|
|
240
|
+
export type Primitive =
|
|
241
|
+
| OnSuccessAndFailure
|
|
242
|
+
| OnFailure
|
|
243
|
+
| OnSuccess
|
|
281
244
|
| UpdateRuntimeFlagsWithin
|
|
282
|
-
| Sync
|
|
283
|
-
| Async
|
|
284
|
-
| SucceedNow
|
|
245
|
+
| Sync
|
|
246
|
+
| Async
|
|
247
|
+
| SucceedNow
|
|
285
248
|
| UpdateRuntimeFlags
|
|
286
249
|
| GenerateStackTrace
|
|
287
|
-
| Stateful
|
|
288
|
-
| WhileLoop
|
|
250
|
+
| Stateful
|
|
251
|
+
| WhileLoop
|
|
289
252
|
| YieldNow
|
|
290
|
-
| Fail
|
|
253
|
+
| Fail
|
|
291
254
|
| STM<any, any, any>
|
|
292
255
|
| Left<any>
|
|
293
256
|
| Right<any>
|
|
@@ -300,18 +263,10 @@ export type Concrete =
|
|
|
300
263
|
* @tsplus static fncts.io.IOOps concrete
|
|
301
264
|
* @tsplus macro identity
|
|
302
265
|
*/
|
|
303
|
-
export function concrete(io: IO<any, any, any>):
|
|
304
|
-
return io as
|
|
266
|
+
export function concrete(io: IO<any, any, any>): Primitive {
|
|
267
|
+
return io as Primitive;
|
|
305
268
|
}
|
|
306
269
|
|
|
307
|
-
export type EvaluationStep =
|
|
308
|
-
| OnSuccessAndFailure<any, any, any, any, any, any, any, any, any>
|
|
309
|
-
| OnFailure<any, any, any, any, any, any>
|
|
310
|
-
| OnSuccess<any, any, any, any, any, any>;
|
|
311
|
-
|
|
312
|
-
export type UpdateRuntimeFlagsWithin =
|
|
313
|
-
| Interruptible<any, any, any>
|
|
314
|
-
| Uninterruptible<any, any, any>
|
|
315
|
-
| Dynamic<any, any, any>;
|
|
270
|
+
export type EvaluationStep = OnSuccessAndFailure | OnFailure | OnSuccess;
|
|
316
271
|
|
|
317
272
|
export type Canceler<R> = URIO<R, void>;
|
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/all.js";
|
|
14
15
|
export * from "./IO/api/asyncInterrupt.js";
|
|
15
16
|
export * from "./IO/api/asyncIO.js";
|
|
16
17
|
export * from "./IO/api/blocking.js";
|
package/_src/Layer/api.ts
CHANGED