@fncts/io 0.0.34 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. package/Fiber/FiberRuntime.d.ts +7 -7
  2. package/IO/api/all.d.ts +41 -0
  3. package/IO/api/concurrency.d.ts +11 -0
  4. package/IO/api/interrupt.d.ts +1 -1
  5. package/IO/api/raceWith.d.ts +2 -1
  6. package/IO/api.d.ts +7 -2
  7. package/IO/definition.d.ts +103 -127
  8. package/IO.d.ts +1 -0
  9. package/Push/api.d.ts +25 -4
  10. package/Push/definition.d.ts +17 -0
  11. package/STM/definition.d.ts +2 -2
  12. package/Sink/api.d.ts +19 -19
  13. package/_cjs/Channel/api/runScoped.cjs +1 -1
  14. package/_cjs/Channel/api/runScoped.cjs.map +1 -1
  15. package/_cjs/Channel/api.cjs +2 -2
  16. package/_cjs/Channel/api.cjs.map +1 -1
  17. package/_cjs/Fiber/FiberRuntime.cjs +110 -98
  18. package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
  19. package/_cjs/Future/api.cjs +1 -1
  20. package/_cjs/Future/api.cjs.map +1 -1
  21. package/_cjs/IO/api/all.cjs +33 -0
  22. package/_cjs/IO/api/all.cjs.map +1 -0
  23. package/_cjs/IO/api/asyncIO.cjs +1 -1
  24. package/_cjs/IO/api/asyncIO.cjs.map +1 -1
  25. package/_cjs/IO/api/bracketExit.cjs +1 -1
  26. package/_cjs/IO/api/bracketExit.cjs.map +1 -1
  27. package/_cjs/IO/api/concurrency.cjs +25 -4
  28. package/_cjs/IO/api/concurrency.cjs.map +1 -1
  29. package/_cjs/IO/api/disconnect.cjs +1 -1
  30. package/_cjs/IO/api/disconnect.cjs.map +1 -1
  31. package/_cjs/IO/api/foreachConcurrent.cjs +1 -1
  32. package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
  33. package/_cjs/IO/api/foreachExec.cjs +1 -1
  34. package/_cjs/IO/api/foreachExec.cjs.map +1 -1
  35. package/_cjs/IO/api/forkIn.cjs +1 -1
  36. package/_cjs/IO/api/forkIn.cjs.map +1 -1
  37. package/_cjs/IO/api/forkScoped.cjs +1 -1
  38. package/_cjs/IO/api/forkScoped.cjs.map +1 -1
  39. package/_cjs/IO/api/fulfill.cjs +1 -1
  40. package/_cjs/IO/api/fulfill.cjs.map +1 -1
  41. package/_cjs/IO/api/interrupt.cjs +18 -6
  42. package/_cjs/IO/api/interrupt.cjs.map +1 -1
  43. package/_cjs/IO/api/raceWith.cjs +4 -4
  44. package/_cjs/IO/api/raceWith.cjs.map +1 -1
  45. package/_cjs/IO/api/timeout.cjs +8 -5
  46. package/_cjs/IO/api/timeout.cjs.map +1 -1
  47. package/_cjs/IO/api/zipConcurrent.cjs +1 -1
  48. package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
  49. package/_cjs/IO/api.cjs +78 -20
  50. package/_cjs/IO/api.cjs.map +1 -1
  51. package/_cjs/IO/definition.cjs +14 -191
  52. package/_cjs/IO/definition.cjs.map +1 -1
  53. package/_cjs/IO.cjs +11 -0
  54. package/_cjs/IO.cjs.map +1 -1
  55. package/_cjs/Layer/MemoMap.cjs +1 -1
  56. package/_cjs/Layer/MemoMap.cjs.map +1 -1
  57. package/_cjs/Push/api.cjs +149 -110
  58. package/_cjs/Push/api.cjs.map +1 -1
  59. package/_cjs/Push/definition.cjs.map +1 -1
  60. package/_cjs/STM/api/atomically.cjs +1 -1
  61. package/_cjs/STM/api/atomically.cjs.map +1 -1
  62. package/_cjs/STM/definition.cjs +1 -1
  63. package/_cjs/STM/definition.cjs.map +1 -1
  64. package/_cjs/ScopedRef/api.cjs +2 -2
  65. package/_cjs/ScopedRef/api.cjs.map +1 -1
  66. package/_cjs/Semaphore.cjs +1 -1
  67. package/_cjs/Semaphore.cjs.map +1 -1
  68. package/_cjs/TReentrantLock/api.cjs +2 -2
  69. package/_cjs/TReentrantLock/api.cjs.map +1 -1
  70. package/_cjs/TSemaphore/api.cjs +1 -1
  71. package/_cjs/TSemaphore/api.cjs.map +1 -1
  72. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +12 -17
  73. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
  74. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +12 -17
  75. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
  76. package/_cjs/collection/immutable/Conc/filterIO.cjs +2 -12
  77. package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
  78. package/_cjs/collection/immutable/Conc/mapIO.cjs +3 -9
  79. package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
  80. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +11 -27
  81. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
  82. package/_mjs/Channel/api/runScoped.mjs +1 -1
  83. package/_mjs/Channel/api/runScoped.mjs.map +1 -1
  84. package/_mjs/Channel/api.mjs +2 -2
  85. package/_mjs/Channel/api.mjs.map +1 -1
  86. package/_mjs/Fiber/FiberRuntime.mjs +111 -100
  87. package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
  88. package/_mjs/Future/api.mjs +1 -1
  89. package/_mjs/Future/api.mjs.map +1 -1
  90. package/_mjs/IO/api/all.mjs +24 -0
  91. package/_mjs/IO/api/all.mjs.map +1 -0
  92. package/_mjs/IO/api/asyncIO.mjs +1 -1
  93. package/_mjs/IO/api/asyncIO.mjs.map +1 -1
  94. package/_mjs/IO/api/bracketExit.mjs +1 -1
  95. package/_mjs/IO/api/bracketExit.mjs.map +1 -1
  96. package/_mjs/IO/api/concurrency.mjs +19 -2
  97. package/_mjs/IO/api/concurrency.mjs.map +1 -1
  98. package/_mjs/IO/api/disconnect.mjs +1 -1
  99. package/_mjs/IO/api/disconnect.mjs.map +1 -1
  100. package/_mjs/IO/api/foreachConcurrent.mjs +1 -1
  101. package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
  102. package/_mjs/IO/api/foreachExec.mjs +1 -1
  103. package/_mjs/IO/api/foreachExec.mjs.map +1 -1
  104. package/_mjs/IO/api/forkIn.mjs +1 -1
  105. package/_mjs/IO/api/forkIn.mjs.map +1 -1
  106. package/_mjs/IO/api/forkScoped.mjs +1 -1
  107. package/_mjs/IO/api/forkScoped.mjs.map +1 -1
  108. package/_mjs/IO/api/fulfill.mjs +1 -1
  109. package/_mjs/IO/api/fulfill.mjs.map +1 -1
  110. package/_mjs/IO/api/interrupt.mjs +19 -7
  111. package/_mjs/IO/api/interrupt.mjs.map +1 -1
  112. package/_mjs/IO/api/raceWith.mjs +4 -4
  113. package/_mjs/IO/api/raceWith.mjs.map +1 -1
  114. package/_mjs/IO/api/timeout.mjs +8 -5
  115. package/_mjs/IO/api/timeout.mjs.map +1 -1
  116. package/_mjs/IO/api/zipConcurrent.mjs +1 -1
  117. package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
  118. package/_mjs/IO/api.mjs +78 -23
  119. package/_mjs/IO/api.mjs.map +1 -1
  120. package/_mjs/IO/definition.mjs +12 -181
  121. package/_mjs/IO/definition.mjs.map +1 -1
  122. package/_mjs/IO.mjs +1 -0
  123. package/_mjs/IO.mjs.map +1 -1
  124. package/_mjs/Layer/MemoMap.mjs +1 -1
  125. package/_mjs/Layer/MemoMap.mjs.map +1 -1
  126. package/_mjs/Push/api.mjs +145 -109
  127. package/_mjs/Push/api.mjs.map +1 -1
  128. package/_mjs/Push/definition.mjs.map +1 -1
  129. package/_mjs/STM/api/atomically.mjs +1 -1
  130. package/_mjs/STM/api/atomically.mjs.map +1 -1
  131. package/_mjs/STM/definition.mjs +1 -1
  132. package/_mjs/STM/definition.mjs.map +1 -1
  133. package/_mjs/ScopedRef/api.mjs +2 -2
  134. package/_mjs/ScopedRef/api.mjs.map +1 -1
  135. package/_mjs/Semaphore.mjs +1 -1
  136. package/_mjs/Semaphore.mjs.map +1 -1
  137. package/_mjs/TReentrantLock/api.mjs +2 -2
  138. package/_mjs/TReentrantLock/api.mjs.map +1 -1
  139. package/_mjs/TSemaphore/api.mjs +1 -1
  140. package/_mjs/TSemaphore/api.mjs.map +1 -1
  141. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +12 -17
  142. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -1
  143. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +12 -17
  144. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -1
  145. package/_mjs/collection/immutable/Conc/filterIO.mjs +2 -12
  146. package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -1
  147. package/_mjs/collection/immutable/Conc/mapIO.mjs +3 -9
  148. package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -1
  149. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +11 -27
  150. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -1
  151. package/_src/Channel/api.ts +3 -3
  152. package/_src/Fiber/FiberRuntime.ts +76 -75
  153. package/_src/IO/api/all.ts +64 -0
  154. package/_src/IO/api/concurrency.ts +33 -0
  155. package/_src/IO/api/foreachExec.ts +2 -2
  156. package/_src/IO/api/interrupt.ts +20 -7
  157. package/_src/IO/api/raceWith.ts +4 -2
  158. package/_src/IO/api/timeout.ts +21 -1
  159. package/_src/IO/api.ts +79 -27
  160. package/_src/IO/definition.ts +155 -199
  161. package/_src/IO.ts +1 -0
  162. package/_src/Push/api.ts +70 -4
  163. package/_src/Push/definition.ts +6 -0
  164. package/_src/STM/definition.ts +2 -2
  165. package/_src/collection/immutable/Conc/dropUntilIO.ts +18 -15
  166. package/_src/collection/immutable/Conc/dropWhileIO.ts +18 -17
  167. package/_src/collection/immutable/Conc/filterIO.ts +1 -11
  168. package/_src/collection/immutable/Conc/mapIO.ts +2 -9
  169. package/_src/collection/immutable/Conc/takeWhileIO.ts +19 -28
  170. package/collection/immutable/Conc/filterIO.d.ts +1 -1
  171. package/collection/immutable/Conc/mapIO.d.ts +1 -1
  172. package/collection/immutable/Conc/takeWhileIO.d.ts +1 -1
  173. package/package.json +2 -2
@@ -18,24 +18,24 @@ import { LogLevel } from "@fncts/io/LogLevel";
18
18
  import { Logger } from "@fncts/io/Logger/definition";
19
19
  import type { FiberStatus } from "../FiberStatus.js";
20
20
  import type { OnFailure, OnSuccess, OnSuccessAndFailure, UIO } from "../IO/definition.js";
21
+ import type { WhileLoop } from "../IO/definition.js";
21
22
  import type { RuntimeFlags } from "../RuntimeFlags.js";
22
23
  import { Trace } from "@fncts/base/data/Trace";
23
24
  import { FiberTypeId, FiberVariance } from "@fncts/io/Fiber/definition";
24
- import { WhileLoop } from "../IO/definition.js";
25
- import { IOOpCode } from "../IO/definition.js";
25
+ import { IOTag } from "../IO/definition.js";
26
26
  import { FiberMessage } from "./FiberMessage.js";
27
27
  export declare class RevertFlags {
28
28
  readonly patch: RuntimeFlags.Patch;
29
29
  readonly trace?: string | undefined;
30
- readonly _tag = IOOpCode.RevertFlags;
30
+ readonly _tag = IOTag.RevertFlags;
31
31
  constructor(patch: RuntimeFlags.Patch, trace?: string | undefined);
32
32
  }
33
33
  export declare class UpdateTrace {
34
34
  readonly trace?: string | undefined;
35
- readonly _tag = IOOpCode.UpdateTrace;
35
+ readonly _tag = IOTag.UpdateTrace;
36
36
  constructor(trace?: string | undefined);
37
37
  }
38
- export type Continuation = OnSuccess<any, any, any, any, any, any> | OnSuccessAndFailure<any, any, any, any, any, any, any, any, any> | OnFailure<any, any, any, any, any, any> | WhileLoop<any, any, any> | UpdateTrace | RevertFlags;
38
+ export type Continuation = OnSuccess | OnSuccessAndFailure | OnFailure | WhileLoop | UpdateTrace | RevertFlags;
39
39
  /**
40
40
  * @tsplus type fncts.io.Fiber
41
41
  */
@@ -108,7 +108,7 @@ export declare class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
108
108
  location: string | undefined;
109
109
  get status(): UIO<FiberStatus>;
110
110
  get trace(): UIO<Trace>;
111
- getNextSuccessCont(): OnSuccessAndFailure<any, any, any, any, any, any, any, any, any> | OnSuccess<any, any, any, any, any, any> | WhileLoop<any, any, any> | RevertFlags | UpdateTrace | undefined;
112
- getNextFailCont(): OnSuccessAndFailure<any, any, any, any, any, any, any, any, any> | OnFailure<any, any, any, any, any, any> | RevertFlags | UpdateTrace | undefined;
111
+ getNextSuccessCont(): OnSuccessAndFailure | OnSuccess | WhileLoop | RevertFlags | UpdateTrace | undefined;
112
+ getNextFailCont(): OnSuccessAndFailure | OnFailure | RevertFlags | UpdateTrace | undefined;
113
113
  isFatal(t: unknown): boolean;
114
114
  }
@@ -0,0 +1,41 @@
1
+ import { IO } from "@fncts/io/IO/definition";
2
+ import { Conc } from "@fncts/base/collection/immutable/Conc";
3
+ import type { EnvironmentOf, ErrorOf, ValueOf } from "@fncts/io/IO";
4
+ /**
5
+ * @tsplus static fncts.io.IOOps all
6
+ * @tsplus location "@fncts/io/IO/api/all"
7
+ */
8
+ export declare function all<T extends ReadonlyArray<IO<any, any, any>>>(ios: [...T]): IO<{
9
+ [K in number]: EnvironmentOf<T[K]>;
10
+ }[number], {
11
+ [K in number]: ErrorOf<T[K]>;
12
+ }[number], {
13
+ [K in keyof T]: ValueOf<T[K]>;
14
+ }>;
15
+ export declare function all<T extends Iterable<IO<any, any, any>>>(ios: T): [T] extends [Iterable<infer A>] ? IO<EnvironmentOf<A>, ErrorOf<A>, Conc<ValueOf<A>>> : never;
16
+ export declare function all<T extends Record<string, IO<any, any, any>>>(ios: T): IO<{
17
+ [K in keyof T]: EnvironmentOf<T[K]>;
18
+ }[keyof T], {
19
+ [K in keyof T]: ErrorOf<T[K]>;
20
+ }[keyof T], {
21
+ [K in keyof T]: ValueOf<T[K]>;
22
+ }>;
23
+ /**
24
+ * @tsplus static fncts.io.IOOps allConcurrent
25
+ * @tsplus location "@fncts/io/IO/api/all"
26
+ */
27
+ export declare function allConcurrent<T extends ReadonlyArray<IO<any, any, any>>>(ios: [...T]): IO<{
28
+ [K in number]: EnvironmentOf<T[K]>;
29
+ }[number], {
30
+ [K in number]: ErrorOf<T[K]>;
31
+ }[number], {
32
+ [K in keyof T]: ValueOf<T[K]>;
33
+ }>;
34
+ export declare function allConcurrent<T extends Iterable<IO<any, any, any>>>(ios: T): [T] extends [Iterable<infer A>] ? IO<EnvironmentOf<A>, ErrorOf<A>, Conc<ValueOf<A>>> : never;
35
+ export declare function allConcurrent<T extends Record<string, IO<any, any, any>>>(ios: T): IO<{
36
+ [K in keyof T]: EnvironmentOf<T[K]>;
37
+ }[keyof T], {
38
+ [K in keyof T]: ErrorOf<T[K]>;
39
+ }[keyof T], {
40
+ [K in keyof T]: ValueOf<T[K]>;
41
+ }>;
@@ -33,3 +33,14 @@ export declare function withConcurrency(n: number, __tsplusTrace?: string): <R,
33
33
  * @tsplus location "@fncts/io/IO/api/concurrency"
34
34
  */
35
35
  export declare function withConcurrencyUnbounded<R, E, A>(ma: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A>;
36
+ export type ConcurrencyRestorer = <R, E, A>(io: IO<R, E, A>) => IO<R, E, A>;
37
+ /**
38
+ * @tsplus static fncts.io.IOOps withConcurrencyMask
39
+ * @tsplus location "@fncts/io/IO/api/concurrency"
40
+ */
41
+ export declare function withConcurrencyMask<R, E, A>(n: number, f: (restore: ConcurrencyRestorer) => IO<R, E, A>): IO<R, E, A>;
42
+ /**
43
+ * @tsplus static fncts.io.IOOps withConcurrencyUnboundedMask
44
+ * @tsplus location "@fncts/io/IO/api/concurrency"
45
+ */
46
+ export declare function withConcurrencyUnboundedMask<R, E, A>(f: (restore: ConcurrencyRestorer) => IO<R, E, A>): IO<R, E, A>;
@@ -51,7 +51,7 @@ export declare function uninterruptible<R, E, A>(self: IO<R, E, A>, __tsplusTrac
51
51
  * @tsplus static fncts.io.IOOps uninterruptibleMask
52
52
  * @tsplus location "@fncts/io/IO/api/interrupt"
53
53
  */
54
- export declare function uninterruptibleMask<R, E, A>(f: (restore: InterruptibilityRestorer) => IO<R, E, A>): IO<R, E, A>;
54
+ export declare function uninterruptibleMask<R, E, A>(f: (restore: InterruptibilityRestorer) => IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A>;
55
55
  /**
56
56
  * @tsplus pipeable fncts.io.IO ensuring
57
57
  * @tsplus location "@fncts/io/IO/api/interrupt"
@@ -1,5 +1,6 @@
1
1
  import { Lazy } from "@fncts/base/data/function/definition";
2
2
  import { IO } from "@fncts/io/IO/definition";
3
+ import { FiberScope } from "@fncts/io/FiberScope";
3
4
  import { Exit } from "@fncts/base/data/Exit/definition";
4
5
  import { Fiber } from "@fncts/io/Fiber/definition";
5
6
  import type { FiberRuntime } from "@fncts/io/Fiber/FiberRuntime";
@@ -7,7 +8,7 @@ import type { FiberRuntime } from "@fncts/io/Fiber/FiberRuntime";
7
8
  * @tsplus pipeable fncts.io.IO raceFibersWith
8
9
  * @tsplus location "@fncts/io/IO/api/raceWith"
9
10
  */
10
- export declare function raceFibersWith<R, E, A, R1, E1, B, R2, E2, C, R3, E3, D>(right: Lazy<IO<R1, E1, B>>, leftWins: (winner: FiberRuntime<E, A>, loser: FiberRuntime<E1, B>) => IO<R2, E2, C>, rightWins: (winner: FiberRuntime<E1, B>, loser: FiberRuntime<E, A>) => IO<R3, E3, D>, __tsplusTrace?: string): (left: IO<R, E, A>) => IO<R | R1 | R2 | R3, E2 | E3, C | D>;
11
+ export declare function raceFibersWith<R, E, A, R1, E1, B, R2, E2, C, R3, E3, D>(right: Lazy<IO<R1, E1, B>>, leftWins: (winner: FiberRuntime<E, A>, loser: FiberRuntime<E1, B>) => IO<R2, E2, C>, rightWins: (winner: FiberRuntime<E1, B>, loser: FiberRuntime<E, A>) => IO<R3, E3, D>, leftScope?: FiberScope | null, rightScope?: FiberScope | null, __tsplusTrace?: string): (left: IO<R, E, A>) => IO<R | R1 | R2 | R3, E2 | E3, C | D>;
11
12
  /**
12
13
  * Returns an effect that races this effect with the specified effect, calling
13
14
  * the specified finisher as soon as one result or the other has been computed.
package/IO/api.d.ts CHANGED
@@ -194,14 +194,14 @@ export declare function condIO<R, R1, E, A>(b: boolean, onTrue: URIO<R, A>, onFa
194
194
  * @tsplus static fncts.io.IOOps defer
195
195
  * @tsplus location "@fncts/io/IO/api"
196
196
  */
197
- export declare function defer<R, E, A>(io: Lazy<IO<R, E, A>>, __tsplusTrace?: string): IO<R, E, A>;
197
+ export declare function defer<R = never, E = never, A = never>(io: Lazy<IO<R, E, A>>, __tsplusTrace?: string): IO<R, E, A>;
198
198
  /**
199
199
  * Returns a lazily constructed effect, whose construction may itself require effects.
200
200
  * When no environment is required (i.e., when R == unknown) it is conceptually equivalent to `flatten(try(io))`.
201
201
  * @tsplus static fncts.io.IOOps deferTry
202
202
  * @tsplus location "@fncts/io/IO/api"
203
203
  */
204
- export declare function deferTry<R, E, A>(io: () => IO<R, E, A>, __tsplusTrace?: string): IO<R, unknown, A>;
204
+ export declare function deferTry<R = never, E = never, A = never>(io: () => IO<R, E, A>, __tsplusTrace?: string): IO<R, unknown, A>;
205
205
  /**
206
206
  * Returns a lazily constructed effect, whose construction may itself require effects,
207
207
  * translating any thrown exceptions into typed failed effects and mapping the error.
@@ -903,6 +903,11 @@ export declare function swapWith<R, E, A, R1, E1, A1>(f: (ma: IO<R, A, E>) => IO
903
903
  * @tsplus location "@fncts/io/IO/api"
904
904
  */
905
905
  export declare function timedWith<R1, E1>(msTime: IO<R1, E1, number>, __tsplusTrace?: string): <R, E, A>(ma: IO<R, E, A>) => IO<R1 | R, E1 | E, readonly [number, A]>;
906
+ /**
907
+ * @tsplus static fncts.io.IOOps attempt
908
+ * @tsplus location "@fncts/io/IO/api"
909
+ */
910
+ export declare function attempt<A>(effect: Lazy<A>, __tsplusTrace?: string): FIO<unknown, A>;
906
911
  /**
907
912
  * Creates a `IO` that has succeeded with a pure value
908
913
  * @tsplus static fncts.io.IOOps tryCatch
@@ -2,16 +2,14 @@ import { HKT } from "@fncts/typelevel/HKT";
2
2
  import { NoSuchElementError } from "@fncts/base/data/exceptions";
3
3
  import { FiberId } from "@fncts/base/data/FiberId/definition";
4
4
  import { Cause } from "@fncts/base/data/Cause/definition";
5
- import { Lazy } from "@fncts/base/data/function/definition";
6
5
  import { STM } from "@fncts/io/STM/definition";
7
6
  import { Nothing, Just } from "@fncts/base/data/Maybe/definition";
8
7
  import type { FiberRuntime } from "../Fiber/FiberRuntime.js";
9
8
  import type { Running } from "../FiberStatus.js";
10
9
  import type { RuntimeFlagsPatch } from "../RuntimeFlags.js";
10
+ import type { RuntimeFlags } from "../RuntimeFlags.js";
11
11
  import type { Left, Right } from "@fncts/base/data/Either";
12
12
  import type { Failure, Success } from "@fncts/base/data/Exit";
13
- import type { Trace } from "@fncts/base/data/Trace";
14
- import { RuntimeFlags } from "../RuntimeFlags.js";
15
13
  export declare const IOVariance: unique symbol;
16
14
  export type IOVariance = typeof IOVariance;
17
15
  export declare const IOTypeId: unique symbol;
@@ -36,6 +34,21 @@ export declare abstract class IO<R, E, A> {
36
34
  _A: () => A;
37
35
  };
38
36
  }
37
+ export type EnvironmentOf<T> = [T] extends [{
38
+ [IOVariance]: {
39
+ _R: () => infer R;
40
+ };
41
+ }] ? R : never;
42
+ export type ErrorOf<T> = [T] extends [{
43
+ [IOVariance]: {
44
+ _E: () => infer E;
45
+ };
46
+ }] ? E : never;
47
+ export type ValueOf<T> = [T] extends [{
48
+ [IOVariance]: {
49
+ _A: () => infer A;
50
+ };
51
+ }] ? A : never;
39
52
  declare module "@fncts/base/data/Either/definition" {
40
53
  interface Either<E, A> extends IO<never, E, A> {
41
54
  }
@@ -85,7 +98,7 @@ export declare function unifyIO<X extends IO<any, any, any>>(self: X): IO<[
85
98
  export type UIO<A> = IO<never, never, A>;
86
99
  export type URIO<R, A> = IO<R, never, A>;
87
100
  export type FIO<E, A> = IO<never, E, A>;
88
- export declare const enum IOOpCode {
101
+ export declare const enum IOTag {
89
102
  SucceedNow = 0,
90
103
  Fail = 1,
91
104
  Sync = 2,
@@ -103,133 +116,96 @@ export declare const enum IOOpCode {
103
116
  RevertFlags = 14,
104
117
  UpdateTrace = 15
105
118
  }
106
- export declare function isIO(u: unknown): u is IO<any, any, any>;
107
- export declare class Sync<A> extends IO<never, never, A> {
108
- readonly evaluate: () => A;
109
- readonly trace?: string | undefined;
110
- readonly _tag = IOOpCode.Sync;
111
- constructor(evaluate: () => A, trace?: string | undefined);
112
- }
113
- export declare class Async<R, E, A> extends IO<R, E, A> {
114
- readonly registerCallback: (f: (_: IO<R, E, A>) => void) => any;
115
- readonly blockingOn: () => FiberId;
116
- readonly trace?: string | undefined;
117
- readonly _tag = IOOpCode.Async;
118
- constructor(registerCallback: (f: (_: IO<R, E, A>) => void) => any, blockingOn: () => FiberId, trace?: string | undefined);
119
+ export type IOOp<Tag extends string | number, Body = {}> = IO<never, never, never> & Body & {
120
+ readonly _tag: Tag;
121
+ };
122
+ export declare class IOPrimitive {
123
+ readonly _tag: Primitive["_tag"];
124
+ i0: any;
125
+ i1: any;
126
+ i2: any;
127
+ trace: string | undefined;
128
+ [IOTypeId]: symbol;
129
+ constructor(_tag: Primitive["_tag"]);
119
130
  }
120
- /**
121
- * @internal
122
- */
123
- export declare class OnSuccessAndFailure<R, E, A, R1, E1, B, R2, E2, C> extends IO<R | R1 | R2, E1 | E2, B | C> {
124
- readonly first: IO<R, E, A>;
125
- readonly failureK: (cause: Cause<E>) => IO<R1, E1, B>;
126
- readonly successK: (a: A) => IO<R2, E2, C>;
127
- readonly trace?: string | undefined;
128
- readonly _tag = IOOpCode.OnSuccessAndFailure;
129
- constructor(first: IO<R, E, A>, failureK: (cause: Cause<E>) => IO<R1, E1, B>, successK: (a: A) => IO<R2, E2, C>, trace?: string | undefined);
130
- onFailure(c: Cause<E>): IO<R | R1 | R2, E1 | E2, B | C>;
131
- onSuccess(a: A): IO<R | R1 | R2, E1 | E2, B | C>;
132
- }
133
- export declare class OnFailure<R, E, A, R1, E1, B> extends IO<R | R1, E1, A | B> {
134
- readonly first: IO<R, E, A>;
135
- readonly failureK: (cause: Cause<E>) => IO<R1, E1, B>;
136
- readonly trace?: string | undefined;
137
- readonly _tag = IOOpCode.OnFailure;
138
- constructor(first: IO<R, E, A>, failureK: (cause: Cause<E>) => IO<R1, E1, B>, trace?: string | undefined);
139
- onFailure(c: Cause<E>): IO<R | R1, E1, A | B>;
140
- onSuccess(a: A): IO<R | R1, E1, A | B>;
141
- }
142
- /**
143
- * @internal
144
- */
145
- export declare class OnSuccess<R, R1, E, E1, A, A1> extends IO<R | R1, E | E1, A1> {
146
- readonly first: IO<R, E, A>;
147
- readonly successK: (a: A) => IO<R1, E1, A1>;
148
- readonly trace?: string | undefined;
149
- readonly _tag = IOOpCode.OnSuccess;
150
- constructor(first: IO<R, E, A>, successK: (a: A) => IO<R1, E1, A1>, trace?: string | undefined);
151
- onFailure(c: Cause<E>): IO<R | R1, E | E1, A1>;
152
- onSuccess(a: A): IO<R | R1, E | E1, A1>;
153
- }
154
- /**
155
- * @internal
156
- */
157
- export declare class SucceedNow<A> extends IO<never, never, A> {
158
- readonly value: A;
159
- readonly trace?: string | undefined;
160
- readonly _tag = IOOpCode.SucceedNow;
161
- constructor(value: A, trace?: string | undefined);
162
- }
163
- export declare class UpdateRuntimeFlags extends IO<never, never, void> {
164
- readonly update: RuntimeFlags.Patch;
165
- readonly trace?: string | undefined;
166
- readonly _tag = IOOpCode.UpdateRuntimeFlags;
167
- constructor(update: RuntimeFlags.Patch, trace?: string | undefined);
168
- }
169
- export declare class Interruptible<R, E, A> extends IO<R, E, A> {
170
- readonly effect: IO<R, E, A>;
171
- readonly trace?: string | undefined;
172
- readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
173
- constructor(effect: IO<R, E, A>, trace?: string | undefined);
174
- readonly update: RuntimeFlags.Patch;
175
- scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A>;
176
- }
177
- export declare class Uninterruptible<R, E, A> extends IO<R, E, A> {
178
- readonly effect: IO<R, E, A>;
179
- readonly trace?: string | undefined;
180
- readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
181
- constructor(effect: IO<R, E, A>, trace?: string | undefined);
182
- readonly update: RuntimeFlags.Patch;
183
- scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A>;
184
- }
185
- export declare class Dynamic<R, E, A> extends IO<R, E, A> {
186
- readonly update: RuntimeFlagsPatch;
187
- readonly f: (oldRuntimeFlags: RuntimeFlags) => IO<R, E, A>;
188
- readonly trace?: string | undefined;
189
- readonly _tag = IOOpCode.UpdateRuntimeFlagsWithin;
190
- constructor(update: RuntimeFlagsPatch, f: (oldRuntimeFlags: RuntimeFlags) => IO<R, E, A>, trace?: string | undefined);
191
- scope(oldRuntimeFlags: RuntimeFlags): IO<R, E, A>;
192
- }
193
- export declare class GenerateStackTrace extends IO<never, never, Trace> {
194
- readonly trace?: string | undefined;
195
- readonly _tag = IOOpCode.GenerateStackTrace;
196
- constructor(trace?: string | undefined);
197
- }
198
- export declare class Stateful<R, E, A> extends IO<R, E, A> {
199
- readonly onState: (fiber: FiberRuntime<E, A>, status: Running) => IO<R, E, A>;
200
- readonly trace?: string | undefined;
201
- readonly _tag = IOOpCode.Stateful;
202
- constructor(onState: (fiber: FiberRuntime<E, A>, status: Running) => IO<R, E, A>, trace?: string | undefined);
203
- }
204
- export declare class WhileLoop<R, E, A> extends IO<R, E, void> {
205
- readonly check: () => boolean;
206
- readonly body: () => IO<R, E, A>;
207
- readonly process: (a: A) => any;
208
- readonly trace?: string | undefined;
209
- readonly _tag = IOOpCode.WhileLoop;
210
- constructor(check: () => boolean, body: () => IO<R, E, A>, process: (a: A) => any, trace?: string | undefined);
211
- }
212
- export declare class YieldNow extends IO<never, never, void> {
213
- readonly trace?: string | undefined;
214
- readonly _tag = IOOpCode.YieldNow;
215
- constructor(trace?: string | undefined);
216
- }
217
- /**
218
- * @internal
219
- */
220
- export declare class Fail<E> extends IO<never, E, never> {
221
- readonly cause: Lazy<Cause<E>>;
222
- readonly trace?: string | undefined;
223
- readonly _tag = IOOpCode.Fail;
224
- constructor(cause: Lazy<Cause<E>>, trace?: string | undefined);
225
- }
226
- export type Concrete = OnSuccessAndFailure<any, any, any, any, any, any, any, any, any> | OnFailure<any, any, any, any, any, any> | OnSuccess<any, any, any, any, any, any> | UpdateRuntimeFlagsWithin | Sync<any> | Async<any, any, any> | SucceedNow<any> | UpdateRuntimeFlags | GenerateStackTrace | Stateful<any, any, any> | WhileLoop<any, any, any> | YieldNow | Fail<any> | STM<any, any, any> | Left<any> | Right<any> | Nothing | Just<any> | Failure<any> | Success<any>;
131
+ export declare function isIO(u: unknown): u is IO<any, any, any>;
132
+ export interface Sync<A = any> extends IOOp<IOTag.Sync, {
133
+ readonly i0: () => A;
134
+ readonly trace: string | undefined;
135
+ }> {
136
+ }
137
+ export interface Async<R = any, E = any, A = any> extends IOOp<IOTag.Async, {
138
+ readonly i0: (resume: (io: Primitive) => void) => void;
139
+ readonly i1: () => FiberId;
140
+ readonly trace: string | undefined;
141
+ }> {
142
+ }
143
+ export interface OnSuccessAndFailure extends IOOp<IOTag.OnSuccessAndFailure, {
144
+ readonly i0: Primitive;
145
+ readonly i1: (cause: Cause<unknown>) => Primitive;
146
+ readonly i2: (a: unknown) => Primitive;
147
+ readonly trace: string | undefined;
148
+ }> {
149
+ }
150
+ export interface OnFailure extends IOOp<IOTag.OnFailure, {
151
+ readonly i0: Primitive;
152
+ readonly i1: (cause: Cause<unknown>) => Primitive;
153
+ readonly trace: string | undefined;
154
+ }> {
155
+ }
156
+ export interface OnSuccess extends IOOp<IOTag.OnSuccess, {
157
+ readonly i0: Primitive;
158
+ readonly i1: (a: unknown) => Primitive;
159
+ readonly trace: string | undefined;
160
+ }> {
161
+ }
162
+ export interface SucceedNow extends IOOp<IOTag.SucceedNow, {
163
+ readonly i0: any;
164
+ readonly trace: string | undefined;
165
+ }> {
166
+ }
167
+ export interface UpdateRuntimeFlags extends IOOp<IOTag.UpdateRuntimeFlags, {
168
+ readonly i0: RuntimeFlags.Patch;
169
+ readonly trace: string | undefined;
170
+ }> {
171
+ }
172
+ export interface UpdateRuntimeFlagsWithin extends IOOp<IOTag.UpdateRuntimeFlagsWithin, {
173
+ readonly i0: RuntimeFlagsPatch;
174
+ readonly i1: (oldRuntimeFlags: RuntimeFlags) => Primitive;
175
+ readonly trace: string | undefined;
176
+ }> {
177
+ }
178
+ export interface GenerateStackTrace extends IOOp<IOTag.GenerateStackTrace, {
179
+ readonly trace: string | undefined;
180
+ }> {
181
+ }
182
+ export interface Stateful extends IOOp<IOTag.Stateful, {
183
+ readonly i0: (fiber: FiberRuntime<any, any>, status: Running) => Primitive;
184
+ readonly trace: string | undefined;
185
+ }> {
186
+ }
187
+ export interface WhileLoop extends IOOp<IOTag.WhileLoop, {
188
+ readonly i0: () => boolean;
189
+ readonly i1: () => Primitive;
190
+ readonly i2: (a: any) => any;
191
+ readonly trace: string | undefined;
192
+ }> {
193
+ }
194
+ export interface YieldNow extends IOOp<IOTag.YieldNow, {
195
+ readonly trace: string | undefined;
196
+ }> {
197
+ }
198
+ export interface Fail extends IOOp<IOTag.Fail, {
199
+ readonly i0: () => Cause<unknown>;
200
+ readonly trace: string | undefined;
201
+ }> {
202
+ }
203
+ export type Primitive = OnSuccessAndFailure | OnFailure | OnSuccess | UpdateRuntimeFlagsWithin | Sync | Async | SucceedNow | UpdateRuntimeFlags | GenerateStackTrace | Stateful | WhileLoop | YieldNow | Fail | STM<any, any, any> | Left<any> | Right<any> | Nothing | Just<any> | Failure<any> | Success<any>;
227
204
  /**
228
205
  * @tsplus static fncts.io.IOOps concrete
229
206
  * @tsplus macro identity
230
207
  * @tsplus location "@fncts/io/IO/definition"
231
208
  */
232
- export declare function concrete(io: IO<any, any, any>): Concrete;
233
- export type EvaluationStep = OnSuccessAndFailure<any, any, any, any, any, any, any, any, any> | OnFailure<any, any, any, any, any, any> | OnSuccess<any, any, any, any, any, any>;
234
- export type UpdateRuntimeFlagsWithin = Interruptible<any, any, any> | Uninterruptible<any, any, any> | Dynamic<any, any, any>;
209
+ export declare function concrete(io: IO<any, any, any>): Primitive;
210
+ export type EvaluationStep = OnSuccessAndFailure | OnFailure | OnSuccess;
235
211
  export type Canceler<R> = URIO<R, void>;
package/IO.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./IO/api/acquireReleaseInterruptible.js";
7
7
  export * from "./IO/api/acquireReleaseInterruptibleExit.js";
8
8
  export * from "./IO/api/addFinalizer.js";
9
9
  export * from "./IO/api/addFinalizerExit.js";
10
+ export * from "./IO/api/all.js";
10
11
  export * from "./IO/api/asyncInterrupt.js";
11
12
  export * from "./IO/api/asyncIO.js";
12
13
  export * from "./IO/api/blocking.js";
package/Push/api.d.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import { Lazy } from "@fncts/base/data/function/definition";
2
+ import { Cause } from "@fncts/base/data/Cause/definition";
3
+ import { Either } from "@fncts/base/data/Either/definition";
4
+ import { IO } from "@fncts/io/IO/definition";
2
5
  import { Duration } from "@fncts/base/data/Duration/definition";
3
6
  import { Fiber } from "@fncts/io/Fiber/definition";
4
- import { IO } from "@fncts/io/IO/definition";
5
7
  import { Environment } from "@fncts/base/data/Environment/definition";
6
8
  import { Future } from "@fncts/io/Future";
7
9
  import { Scope } from "@fncts/io/Scope/definition";
8
10
  import { Schedule } from "@fncts/io/Schedule/definition";
9
- import { Cause } from "@fncts/base/data/Cause/definition";
10
11
  import { Nothing, Just, Maybe } from "@fncts/base/data/Maybe/definition";
11
12
  import { FiberId } from "@fncts/base/data/FiberId/definition";
12
13
  import { Conc } from "@fncts/base/collection/immutable/Conc";
13
- import type { _A, _E, _R } from "@fncts/base/types";
14
+ import type { _E, _R } from "@fncts/base/types";
14
15
  import { AtomicReference } from "@fncts/base/internal/AtomicReference";
15
16
  import { Emitter, Push, PushTypeId, PushVariance } from "./definition.js";
16
17
  /**
@@ -18,6 +19,21 @@ import { Emitter, Push, PushTypeId, PushVariance } from "./definition.js";
18
19
  * @tsplus location "@fncts/io/Push/api"
19
20
  */
20
21
  export declare function as<B>(b: Lazy<B>): <R, E, A>(self: Push<R, E, A>) => Push<R, E, B>;
22
+ interface UnsafeEmitter<E, A> {
23
+ emit: (value: A) => void;
24
+ failCause: (cause: Cause<E>) => void;
25
+ end: () => void;
26
+ }
27
+ /**
28
+ * @tsplus static fncts.io.PushOps asyncInterrupt
29
+ * @tsplus location "@fncts/io/Push/api"
30
+ */
31
+ export declare function asyncInterrupt<R, E, A>(make: (emitter: UnsafeEmitter<E, A>) => Either<IO<R, never, void>, Push<R, E, A>>): Push<R, E, A>;
32
+ /**
33
+ * @tsplus static fncts.io.PushOps async
34
+ * @tsplus location "@fncts/io/Push/api"
35
+ */
36
+ export declare function async<E, A>(make: (emitter: UnsafeEmitter<E, A>) => void): Push<never, E, A>;
21
37
  /**
22
38
  * @tsplus static fncts.io.PushOps combineLatest
23
39
  * @tsplus location "@fncts/io/Push/api"
@@ -160,8 +176,13 @@ export declare function merge<R1, E1, B>(that: Push<R1, E1, B>): <R, E, A>(self:
160
176
  * @tsplus static fncts.io.PushOps mergeAll
161
177
  * @tsplus location "@fncts/io/Push/api"
162
178
  */
163
- export declare function mergeAll<A extends ReadonlyArray<Push<any, any, any>>>(streams: [...A]): Push<_R<A[number]>, _E<A[number]>, _A<A[number]>>;
179
+ export declare function mergeAll<A extends ReadonlyArray<Push<any, any, any>>>(streams: [...A]): Push<Push.EnvironmentOf<A[number]>, Push.ErrorOf<A[number]>, Push.ValueOf<A[number]>>;
164
180
  export declare function mergeAll<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R, E, A>;
181
+ /**
182
+ * @tsplus pipeable fncts.io.Push observe
183
+ * @tsplus location "@fncts/io/Push/api"
184
+ */
185
+ export declare function observe<A, R1, E1>(f: (a: A) => IO<R1, E1, void>, __tsplusTrace?: string): <R, E>(self: Push<R, E, A>) => import("../IO.js").IO<import("../Scope.js").Scope | R1 | R, E1 | E, void>;
165
186
  /**
166
187
  * @tsplus static fncts.io.PushOps repeatIOMaybe
167
188
  * @tsplus location "@fncts/io/Push/api"
@@ -19,6 +19,23 @@ export declare class Push<R, E, A> {
19
19
  };
20
20
  constructor(run: <R1>(emitter: Emitter<R1, E, A>) => IO<R | R1 | Scope, never, unknown>);
21
21
  }
22
+ export declare namespace Push {
23
+ type EnvironmentOf<X> = [X] extends [{
24
+ [PushVariance]: {
25
+ readonly _R: (_: never) => infer R;
26
+ };
27
+ }] ? R : never;
28
+ type ErrorOf<X> = [X] extends [{
29
+ [PushVariance]: {
30
+ readonly _E: (_: never) => infer E;
31
+ };
32
+ }] ? E : never;
33
+ type ValueOf<X> = [X] extends [{
34
+ [PushVariance]: {
35
+ readonly _A: (_: never) => infer A;
36
+ };
37
+ }] ? A : never;
38
+ }
22
39
  /**
23
40
  * @tsplus type fncts.io.Push.Emitter
24
41
  * @tsplus companion fncts.io.Push.EmitterOps
@@ -2,7 +2,7 @@ import { FiberId } from "@fncts/base/data/FiberId/definition";
2
2
  import { Environment } from "@fncts/base/data/Environment/definition";
3
3
  import type { Journal } from "./internal/Journal.js";
4
4
  import type { _A, _E, _R } from "@fncts/base/types";
5
- import { IOOpCode, IOTypeId, IOVariance } from "@fncts/io/IO/definition";
5
+ import { IOTag, IOTypeId, IOVariance } from "@fncts/io/IO/definition";
6
6
  export declare const enum STMTag {
7
7
  Effect = "Effect",
8
8
  OnFailure = "OnFailure",
@@ -22,7 +22,7 @@ export type STMTypeId = typeof STMTypeId;
22
22
  */
23
23
  export declare abstract class STM<R, E, A> {
24
24
  readonly [IOTypeId]: IOTypeId;
25
- readonly _tag = IOOpCode.Commit;
25
+ readonly _tag = IOTag.Commit;
26
26
  readonly trace?: string;
27
27
  readonly [STMTypeId]: STMTypeId;
28
28
  [IOVariance]: {