@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.
Files changed (230) hide show
  1. package/Fiber/FiberRuntime.d.ts +7 -7
  2. package/Fiber/constructors.d.ts +5 -0
  3. package/IO/api/all.d.ts +41 -0
  4. package/IO/api/concurrency.d.ts +11 -0
  5. package/IO/api/interrupt.d.ts +1 -1
  6. package/IO/api/raceWith.d.ts +2 -1
  7. package/IO/api.d.ts +7 -2
  8. package/IO/definition.d.ts +103 -127
  9. package/IO.d.ts +1 -0
  10. package/Push/api.d.ts +86 -36
  11. package/Push/definition.d.ts +28 -13
  12. package/Push/internal.d.ts +7 -11
  13. package/RefSubject/Atomic.d.ts +8 -11
  14. package/RefSubject/Synchronized/definition.d.ts +4 -6
  15. package/RefSubject/api.d.ts +0 -1
  16. package/RefSubject/definition.d.ts +6 -8
  17. package/STM/definition.d.ts +19 -2
  18. package/Sink/api.d.ts +24 -24
  19. package/Subject/Atomic.d.ts +4 -6
  20. package/Subject/definition.d.ts +2 -2
  21. package/_cjs/Channel/api/runScoped.cjs +1 -1
  22. package/_cjs/Channel/api/runScoped.cjs.map +1 -1
  23. package/_cjs/Channel/api.cjs +2 -2
  24. package/_cjs/Channel/api.cjs.map +1 -1
  25. package/_cjs/Fiber/FiberRuntime.cjs +110 -98
  26. package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
  27. package/_cjs/Fiber/constructors.cjs +10 -2
  28. package/_cjs/Fiber/constructors.cjs.map +1 -1
  29. package/_cjs/Future/api.cjs +1 -1
  30. package/_cjs/Future/api.cjs.map +1 -1
  31. package/_cjs/IO/api/all.cjs +33 -0
  32. package/_cjs/IO/api/all.cjs.map +1 -0
  33. package/_cjs/IO/api/asyncIO.cjs +1 -1
  34. package/_cjs/IO/api/asyncIO.cjs.map +1 -1
  35. package/_cjs/IO/api/bracketExit.cjs +1 -1
  36. package/_cjs/IO/api/bracketExit.cjs.map +1 -1
  37. package/_cjs/IO/api/concurrency.cjs +25 -4
  38. package/_cjs/IO/api/concurrency.cjs.map +1 -1
  39. package/_cjs/IO/api/disconnect.cjs +1 -1
  40. package/_cjs/IO/api/disconnect.cjs.map +1 -1
  41. package/_cjs/IO/api/foreachConcurrent.cjs +1 -1
  42. package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
  43. package/_cjs/IO/api/foreachExec.cjs +1 -1
  44. package/_cjs/IO/api/foreachExec.cjs.map +1 -1
  45. package/_cjs/IO/api/forkIn.cjs +1 -1
  46. package/_cjs/IO/api/forkIn.cjs.map +1 -1
  47. package/_cjs/IO/api/forkScoped.cjs +1 -1
  48. package/_cjs/IO/api/forkScoped.cjs.map +1 -1
  49. package/_cjs/IO/api/fulfill.cjs +1 -1
  50. package/_cjs/IO/api/fulfill.cjs.map +1 -1
  51. package/_cjs/IO/api/interrupt.cjs +18 -6
  52. package/_cjs/IO/api/interrupt.cjs.map +1 -1
  53. package/_cjs/IO/api/raceWith.cjs +4 -4
  54. package/_cjs/IO/api/raceWith.cjs.map +1 -1
  55. package/_cjs/IO/api/timeout.cjs +8 -5
  56. package/_cjs/IO/api/timeout.cjs.map +1 -1
  57. package/_cjs/IO/api/zipConcurrent.cjs +1 -1
  58. package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
  59. package/_cjs/IO/api.cjs +78 -20
  60. package/_cjs/IO/api.cjs.map +1 -1
  61. package/_cjs/IO/definition.cjs +14 -191
  62. package/_cjs/IO/definition.cjs.map +1 -1
  63. package/_cjs/IO.cjs +11 -0
  64. package/_cjs/IO.cjs.map +1 -1
  65. package/_cjs/Layer/MemoMap.cjs +1 -1
  66. package/_cjs/Layer/MemoMap.cjs.map +1 -1
  67. package/_cjs/Layer/api.cjs.map +1 -1
  68. package/_cjs/Push/api.cjs +238 -168
  69. package/_cjs/Push/api.cjs.map +1 -1
  70. package/_cjs/Push/definition.cjs +12 -13
  71. package/_cjs/Push/definition.cjs.map +1 -1
  72. package/_cjs/Push/internal.cjs +37 -29
  73. package/_cjs/Push/internal.cjs.map +1 -1
  74. package/_cjs/RefSubject/Atomic.cjs +15 -19
  75. package/_cjs/RefSubject/Atomic.cjs.map +1 -1
  76. package/_cjs/RefSubject/Synchronized/definition.cjs +9 -10
  77. package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
  78. package/_cjs/RefSubject/api.cjs +5 -6
  79. package/_cjs/RefSubject/api.cjs.map +1 -1
  80. package/_cjs/RefSubject/definition.cjs.map +1 -1
  81. package/_cjs/STM/api/atomically.cjs +1 -1
  82. package/_cjs/STM/api/atomically.cjs.map +1 -1
  83. package/_cjs/STM/api.cjs +2 -2
  84. package/_cjs/STM/api.cjs.map +1 -1
  85. package/_cjs/STM/definition.cjs +1 -1
  86. package/_cjs/STM/definition.cjs.map +1 -1
  87. package/_cjs/ScopedRef/api.cjs +2 -2
  88. package/_cjs/ScopedRef/api.cjs.map +1 -1
  89. package/_cjs/Semaphore.cjs +1 -1
  90. package/_cjs/Semaphore.cjs.map +1 -1
  91. package/_cjs/Sink/api.cjs +13 -13
  92. package/_cjs/Sink/api.cjs.map +1 -1
  93. package/_cjs/Subject/Atomic.cjs +4 -5
  94. package/_cjs/Subject/Atomic.cjs.map +1 -1
  95. package/_cjs/TReentrantLock/api.cjs +2 -2
  96. package/_cjs/TReentrantLock/api.cjs.map +1 -1
  97. package/_cjs/TSemaphore/api.cjs +1 -1
  98. package/_cjs/TSemaphore/api.cjs.map +1 -1
  99. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +12 -17
  100. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
  101. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +12 -17
  102. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
  103. package/_cjs/collection/immutable/Conc/filterIO.cjs +2 -12
  104. package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
  105. package/_cjs/collection/immutable/Conc/mapIO.cjs +3 -9
  106. package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
  107. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +11 -27
  108. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
  109. package/_mjs/Channel/api/runScoped.mjs +1 -1
  110. package/_mjs/Channel/api/runScoped.mjs.map +1 -1
  111. package/_mjs/Channel/api.mjs +2 -2
  112. package/_mjs/Channel/api.mjs.map +1 -1
  113. package/_mjs/Fiber/FiberRuntime.mjs +111 -100
  114. package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
  115. package/_mjs/Fiber/constructors.mjs +7 -1
  116. package/_mjs/Fiber/constructors.mjs.map +1 -1
  117. package/_mjs/Future/api.mjs +1 -1
  118. package/_mjs/Future/api.mjs.map +1 -1
  119. package/_mjs/IO/api/all.mjs +24 -0
  120. package/_mjs/IO/api/all.mjs.map +1 -0
  121. package/_mjs/IO/api/asyncIO.mjs +1 -1
  122. package/_mjs/IO/api/asyncIO.mjs.map +1 -1
  123. package/_mjs/IO/api/bracketExit.mjs +1 -1
  124. package/_mjs/IO/api/bracketExit.mjs.map +1 -1
  125. package/_mjs/IO/api/concurrency.mjs +19 -2
  126. package/_mjs/IO/api/concurrency.mjs.map +1 -1
  127. package/_mjs/IO/api/disconnect.mjs +1 -1
  128. package/_mjs/IO/api/disconnect.mjs.map +1 -1
  129. package/_mjs/IO/api/foreachConcurrent.mjs +1 -1
  130. package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
  131. package/_mjs/IO/api/foreachExec.mjs +1 -1
  132. package/_mjs/IO/api/foreachExec.mjs.map +1 -1
  133. package/_mjs/IO/api/forkIn.mjs +1 -1
  134. package/_mjs/IO/api/forkIn.mjs.map +1 -1
  135. package/_mjs/IO/api/forkScoped.mjs +1 -1
  136. package/_mjs/IO/api/forkScoped.mjs.map +1 -1
  137. package/_mjs/IO/api/fulfill.mjs +1 -1
  138. package/_mjs/IO/api/fulfill.mjs.map +1 -1
  139. package/_mjs/IO/api/interrupt.mjs +19 -7
  140. package/_mjs/IO/api/interrupt.mjs.map +1 -1
  141. package/_mjs/IO/api/raceWith.mjs +4 -4
  142. package/_mjs/IO/api/raceWith.mjs.map +1 -1
  143. package/_mjs/IO/api/timeout.mjs +8 -5
  144. package/_mjs/IO/api/timeout.mjs.map +1 -1
  145. package/_mjs/IO/api/zipConcurrent.mjs +1 -1
  146. package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
  147. package/_mjs/IO/api.mjs +78 -23
  148. package/_mjs/IO/api.mjs.map +1 -1
  149. package/_mjs/IO/definition.mjs +12 -181
  150. package/_mjs/IO/definition.mjs.map +1 -1
  151. package/_mjs/IO.mjs +1 -0
  152. package/_mjs/IO.mjs.map +1 -1
  153. package/_mjs/Layer/MemoMap.mjs +1 -1
  154. package/_mjs/Layer/MemoMap.mjs.map +1 -1
  155. package/_mjs/Layer/api.mjs.map +1 -1
  156. package/_mjs/Push/api.mjs +223 -166
  157. package/_mjs/Push/api.mjs.map +1 -1
  158. package/_mjs/Push/definition.mjs +9 -10
  159. package/_mjs/Push/definition.mjs.map +1 -1
  160. package/_mjs/Push/internal.mjs +33 -22
  161. package/_mjs/Push/internal.mjs.map +1 -1
  162. package/_mjs/RefSubject/Atomic.mjs +15 -19
  163. package/_mjs/RefSubject/Atomic.mjs.map +1 -1
  164. package/_mjs/RefSubject/Synchronized/definition.mjs +9 -10
  165. package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -1
  166. package/_mjs/RefSubject/api.mjs +6 -7
  167. package/_mjs/RefSubject/api.mjs.map +1 -1
  168. package/_mjs/RefSubject/definition.mjs.map +1 -1
  169. package/_mjs/STM/api/atomically.mjs +1 -1
  170. package/_mjs/STM/api/atomically.mjs.map +1 -1
  171. package/_mjs/STM/api.mjs +2 -2
  172. package/_mjs/STM/api.mjs.map +1 -1
  173. package/_mjs/STM/definition.mjs +1 -1
  174. package/_mjs/STM/definition.mjs.map +1 -1
  175. package/_mjs/ScopedRef/api.mjs +2 -2
  176. package/_mjs/ScopedRef/api.mjs.map +1 -1
  177. package/_mjs/Semaphore.mjs +1 -1
  178. package/_mjs/Semaphore.mjs.map +1 -1
  179. package/_mjs/Sink/api.mjs +10 -10
  180. package/_mjs/Sink/api.mjs.map +1 -1
  181. package/_mjs/Subject/Atomic.mjs +4 -5
  182. package/_mjs/Subject/Atomic.mjs.map +1 -1
  183. package/_mjs/TReentrantLock/api.mjs +2 -2
  184. package/_mjs/TReentrantLock/api.mjs.map +1 -1
  185. package/_mjs/TSemaphore/api.mjs +1 -1
  186. package/_mjs/TSemaphore/api.mjs.map +1 -1
  187. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +12 -17
  188. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -1
  189. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +12 -17
  190. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -1
  191. package/_mjs/collection/immutable/Conc/filterIO.mjs +2 -12
  192. package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -1
  193. package/_mjs/collection/immutable/Conc/mapIO.mjs +3 -9
  194. package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -1
  195. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +11 -27
  196. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -1
  197. package/_src/Channel/api.ts +3 -3
  198. package/_src/Fiber/FiberRuntime.ts +76 -75
  199. package/_src/Fiber/constructors.ts +5 -0
  200. package/_src/IO/api/all.ts +64 -0
  201. package/_src/IO/api/concurrency.ts +33 -0
  202. package/_src/IO/api/foreachExec.ts +2 -2
  203. package/_src/IO/api/interrupt.ts +20 -7
  204. package/_src/IO/api/raceWith.ts +4 -2
  205. package/_src/IO/api/timeout.ts +21 -1
  206. package/_src/IO/api.ts +79 -27
  207. package/_src/IO/definition.ts +155 -200
  208. package/_src/IO.ts +1 -0
  209. package/_src/Layer/api.ts +0 -1
  210. package/_src/Push/api.ts +305 -304
  211. package/_src/Push/definition.ts +19 -17
  212. package/_src/Push/internal.ts +63 -31
  213. package/_src/RefSubject/Atomic.ts +16 -22
  214. package/_src/RefSubject/Synchronized/definition.ts +6 -9
  215. package/_src/RefSubject/api.ts +9 -12
  216. package/_src/RefSubject/definition.ts +6 -8
  217. package/_src/STM/api.ts +0 -5
  218. package/_src/STM/definition.ts +8 -2
  219. package/_src/Sink/api.ts +9 -9
  220. package/_src/Subject/Atomic.ts +6 -8
  221. package/_src/Subject/definition.ts +2 -2
  222. package/_src/collection/immutable/Conc/dropUntilIO.ts +18 -15
  223. package/_src/collection/immutable/Conc/dropWhileIO.ts +18 -17
  224. package/_src/collection/immutable/Conc/filterIO.ts +1 -11
  225. package/_src/collection/immutable/Conc/mapIO.ts +2 -9
  226. package/_src/collection/immutable/Conc/takeWhileIO.ts +19 -28
  227. package/collection/immutable/Conc/filterIO.d.ts +1 -1
  228. package/collection/immutable/Conc/mapIO.d.ts +1 -1
  229. package/collection/immutable/Conc/takeWhileIO.d.ts +1 -1
  230. package/package.json +2 -2
@@ -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 IOOpCode {
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 function isIO(u: unknown): u is IO<any, any, any> {
99
- return isObject(u) && IOTypeId in u;
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 YieldNow extends IO<never, never, void> {
260
- readonly _tag = IOOpCode.YieldNow;
261
- constructor(readonly trace?: string) {
262
- super();
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
- * @internal
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 type Concrete =
278
- | OnSuccessAndFailure<any, any, any, any, any, any, any, any, any>
279
- | OnFailure<any, any, any, any, any, any>
280
- | OnSuccess<any, any, any, any, any, any>
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<any>
283
- | Async<any, any, any>
284
- | SucceedNow<any>
245
+ | Sync
246
+ | Async
247
+ | SucceedNow
285
248
  | UpdateRuntimeFlags
286
249
  | GenerateStackTrace
287
- | Stateful<any, any, any>
288
- | WhileLoop<any, any, any>
250
+ | Stateful
251
+ | WhileLoop
289
252
  | YieldNow
290
- | Fail<any>
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>): Concrete {
304
- return io as Concrete;
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
@@ -1,5 +1,4 @@
1
1
  import type { Spreadable } from "@fncts/base/types";
2
- import type { Erase } from "@fncts/typelevel/Intersection";
3
2
 
4
3
  import { Fold, Fresh, FromScoped, Layer, To, ZipWithConcurrent } from "@fncts/io/Layer/definition";
5
4
  import { DecisionTag } from "@fncts/io/Schedule";