@typed/fx 1.22.2 → 1.24.0

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 (157) hide show
  1. package/dist/cjs/AsyncData.js.map +1 -1
  2. package/dist/cjs/Form.js.map +1 -1
  3. package/dist/cjs/FormEntry.js.map +1 -1
  4. package/dist/cjs/Fx.js +1 -1
  5. package/dist/cjs/Fx.js.map +1 -1
  6. package/dist/cjs/Idle.js.map +1 -1
  7. package/dist/cjs/Match.js.map +1 -1
  8. package/dist/cjs/Pull.js +5 -3
  9. package/dist/cjs/Pull.js.map +1 -1
  10. package/dist/cjs/RefArray.js.map +1 -1
  11. package/dist/cjs/RefChunk.js.map +1 -1
  12. package/dist/cjs/RefHashSet.js.map +1 -1
  13. package/dist/cjs/RefSubject.js +3 -2
  14. package/dist/cjs/RefSubject.js.map +1 -1
  15. package/dist/cjs/Sink.js.map +1 -1
  16. package/dist/cjs/Subject.js.map +1 -1
  17. package/dist/cjs/Versioned.js.map +1 -1
  18. package/dist/cjs/internal/core.js.map +1 -1
  19. package/dist/cjs/internal/helpers.js.map +1 -1
  20. package/dist/cjs/internal/keyed.js +1 -1
  21. package/dist/cjs/internal/keyed.js.map +1 -1
  22. package/dist/cjs/internal/provide.js.map +1 -1
  23. package/dist/cjs/internal/share.js.map +1 -1
  24. package/dist/cjs/internal/sync-producer.js.map +1 -1
  25. package/dist/dts/AsyncData.d.ts +53 -53
  26. package/dist/dts/AsyncData.d.ts.map +1 -1
  27. package/dist/dts/Emitter.d.ts +7 -7
  28. package/dist/dts/Emitter.d.ts.map +1 -1
  29. package/dist/dts/Form.d.ts +14 -14
  30. package/dist/dts/Form.d.ts.map +1 -1
  31. package/dist/dts/FormEntry.d.ts +11 -11
  32. package/dist/dts/FormEntry.d.ts.map +1 -1
  33. package/dist/dts/Fx.d.ts +417 -417
  34. package/dist/dts/Fx.d.ts.map +1 -1
  35. package/dist/dts/Guard.d.ts +21 -21
  36. package/dist/dts/Guard.d.ts.map +1 -1
  37. package/dist/dts/Idle.d.ts +12 -12
  38. package/dist/dts/Idle.d.ts.map +1 -1
  39. package/dist/dts/Match.d.ts +16 -16
  40. package/dist/dts/Match.d.ts.map +1 -1
  41. package/dist/dts/Pull.d.ts +5 -5
  42. package/dist/dts/Pull.d.ts.map +1 -1
  43. package/dist/dts/Push.d.ts +40 -40
  44. package/dist/dts/Push.d.ts.map +1 -1
  45. package/dist/dts/RefArray.d.ts +59 -59
  46. package/dist/dts/RefArray.d.ts.map +1 -1
  47. package/dist/dts/RefChunk.d.ts +45 -45
  48. package/dist/dts/RefChunk.d.ts.map +1 -1
  49. package/dist/dts/RefHashMap.d.ts +35 -35
  50. package/dist/dts/RefHashMap.d.ts.map +1 -1
  51. package/dist/dts/RefHashSet.d.ts +17 -17
  52. package/dist/dts/RefHashSet.d.ts.map +1 -1
  53. package/dist/dts/RefSubject.d.ts +136 -136
  54. package/dist/dts/RefSubject.d.ts.map +1 -1
  55. package/dist/dts/Sink.d.ts +63 -63
  56. package/dist/dts/Sink.d.ts.map +1 -1
  57. package/dist/dts/Stream.d.ts +11 -11
  58. package/dist/dts/Stream.d.ts.map +1 -1
  59. package/dist/dts/Subject.d.ts +13 -13
  60. package/dist/dts/Subject.d.ts.map +1 -1
  61. package/dist/dts/Typeclass.d.ts +1 -1
  62. package/dist/dts/Typeclass.d.ts.map +1 -1
  63. package/dist/dts/Versioned.d.ts +33 -33
  64. package/dist/dts/Versioned.d.ts.map +1 -1
  65. package/dist/dts/index.d.ts +1 -1
  66. package/dist/dts/internal/DeferredRef.d.ts +8 -8
  67. package/dist/dts/internal/DeferredRef.d.ts.map +1 -1
  68. package/dist/dts/internal/core.d.ts +191 -191
  69. package/dist/dts/internal/core.d.ts.map +1 -1
  70. package/dist/dts/internal/effect-loop-operator.d.ts +6 -6
  71. package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -1
  72. package/dist/dts/internal/effect-operator.d.ts +16 -16
  73. package/dist/dts/internal/effect-operator.d.ts.map +1 -1
  74. package/dist/dts/internal/effect-producer.d.ts +13 -13
  75. package/dist/dts/internal/effect-producer.d.ts.map +1 -1
  76. package/dist/dts/internal/helpers.d.ts +26 -26
  77. package/dist/dts/internal/helpers.d.ts.map +1 -1
  78. package/dist/dts/internal/keyed.d.ts +1 -1
  79. package/dist/dts/internal/keyed.d.ts.map +1 -1
  80. package/dist/dts/internal/loop-operator.d.ts +2 -2
  81. package/dist/dts/internal/loop-operator.d.ts.map +1 -1
  82. package/dist/dts/internal/operator.d.ts +2 -2
  83. package/dist/dts/internal/operator.d.ts.map +1 -1
  84. package/dist/dts/internal/protos.d.ts +12 -12
  85. package/dist/dts/internal/protos.d.ts.map +1 -1
  86. package/dist/dts/internal/provide.d.ts +15 -15
  87. package/dist/dts/internal/provide.d.ts.map +1 -1
  88. package/dist/dts/internal/share.d.ts +11 -11
  89. package/dist/dts/internal/share.d.ts.map +1 -1
  90. package/dist/dts/internal/sync-operator.d.ts +2 -2
  91. package/dist/dts/internal/sync-operator.d.ts.map +1 -1
  92. package/dist/dts/internal/sync-producer.d.ts +6 -6
  93. package/dist/dts/internal/sync-producer.d.ts.map +1 -1
  94. package/dist/dts/internal/withKey.d.ts +1 -1
  95. package/dist/dts/internal/withKey.d.ts.map +1 -1
  96. package/dist/esm/AsyncData.js.map +1 -1
  97. package/dist/esm/Form.js.map +1 -1
  98. package/dist/esm/FormEntry.js.map +1 -1
  99. package/dist/esm/Fx.js +1 -1
  100. package/dist/esm/Fx.js.map +1 -1
  101. package/dist/esm/Idle.js.map +1 -1
  102. package/dist/esm/Match.js.map +1 -1
  103. package/dist/esm/Pull.js +3 -3
  104. package/dist/esm/Pull.js.map +1 -1
  105. package/dist/esm/RefArray.js.map +1 -1
  106. package/dist/esm/RefChunk.js.map +1 -1
  107. package/dist/esm/RefHashSet.js.map +1 -1
  108. package/dist/esm/RefSubject.js +3 -1
  109. package/dist/esm/RefSubject.js.map +1 -1
  110. package/dist/esm/Sink.js.map +1 -1
  111. package/dist/esm/Subject.js.map +1 -1
  112. package/dist/esm/Versioned.js.map +1 -1
  113. package/dist/esm/index.js +1 -1
  114. package/dist/esm/internal/core.js.map +1 -1
  115. package/dist/esm/internal/helpers.js.map +1 -1
  116. package/dist/esm/internal/keyed.js +1 -1
  117. package/dist/esm/internal/keyed.js.map +1 -1
  118. package/dist/esm/internal/provide.js.map +1 -1
  119. package/dist/esm/internal/share.js.map +1 -1
  120. package/dist/esm/internal/sync-producer.js.map +1 -1
  121. package/package.json +6 -6
  122. package/src/AsyncData.ts +142 -144
  123. package/src/Emitter.ts +13 -13
  124. package/src/Form.ts +55 -55
  125. package/src/FormEntry.ts +39 -39
  126. package/src/Fx.ts +788 -789
  127. package/src/Guard.ts +43 -43
  128. package/src/Idle.ts +26 -26
  129. package/src/Match.ts +60 -61
  130. package/src/Pull.ts +42 -43
  131. package/src/Push.ts +195 -195
  132. package/src/RefArray.ts +121 -119
  133. package/src/RefChunk.ts +98 -97
  134. package/src/RefHashMap.ts +79 -79
  135. package/src/RefHashSet.ts +40 -39
  136. package/src/RefSubject.ts +574 -565
  137. package/src/Sink.ts +303 -303
  138. package/src/Stream.ts +27 -27
  139. package/src/Subject.ts +48 -46
  140. package/src/Typeclass.ts +2 -2
  141. package/src/Versioned.ts +97 -97
  142. package/src/index.ts +1 -1
  143. package/src/internal/DeferredRef.ts +7 -7
  144. package/src/internal/core.ts +768 -781
  145. package/src/internal/effect-loop-operator.ts +7 -7
  146. package/src/internal/effect-operator.ts +23 -23
  147. package/src/internal/effect-producer.ts +38 -38
  148. package/src/internal/helpers.ts +51 -51
  149. package/src/internal/keyed.ts +21 -21
  150. package/src/internal/loop-operator.ts +2 -2
  151. package/src/internal/operator.ts +2 -2
  152. package/src/internal/protos.ts +15 -15
  153. package/src/internal/provide.ts +27 -27
  154. package/src/internal/share.ts +25 -25
  155. package/src/internal/sync-operator.ts +4 -4
  156. package/src/internal/sync-producer.ts +15 -15
  157. package/src/internal/withKey.ts +13 -13
@@ -12,12 +12,12 @@ export type EffectLoopOperator<B = any, A = any, R = any, E = any, C = any> =
12
12
  export interface LoopEffectOperator<B, A, R, E, C> {
13
13
  readonly _tag: "LoopEffect"
14
14
  readonly seed: B
15
- readonly f: (acc: B, a: A) => Effect.Effect<R, E, readonly [C, B]>
15
+ readonly f: (acc: B, a: A) => Effect.Effect<readonly [C, B], E, R>
16
16
  }
17
17
 
18
18
  export function LoopEffectOperator<const B, A, R, E, C>(
19
19
  seed: B,
20
- f: (acc: B, a: A) => Effect.Effect<R, E, readonly [C, B]>
20
+ f: (acc: B, a: A) => Effect.Effect<readonly [C, B], E, R>
21
21
  ): LoopEffectOperator<B, A, R, E, C> {
22
22
  return { _tag: "LoopEffect", seed, f }
23
23
  }
@@ -25,17 +25,17 @@ export function LoopEffectOperator<const B, A, R, E, C>(
25
25
  export interface FilterMapLoopEffectOperator<B, A, R, E, C> {
26
26
  readonly _tag: "FilterMapLoopEffect"
27
27
  readonly seed: B
28
- readonly f: (acc: B, a: A) => Effect.Effect<R, E, readonly [Option.Option<C>, B]>
28
+ readonly f: (acc: B, a: A) => Effect.Effect<readonly [Option.Option<C>, B], E, R>
29
29
  }
30
30
 
31
31
  export function FilterMapLoopEffectOperator<const B, A, R, E, C>(
32
32
  seed: B,
33
- f: (acc: B, a: A) => Effect.Effect<R, E, readonly [Option.Option<C>, B]>
33
+ f: (acc: B, a: A) => Effect.Effect<readonly [Option.Option<C>, B], E, R>
34
34
  ): FilterMapLoopEffectOperator<B, A, R, E, C> {
35
35
  return { _tag: "FilterMapLoopEffect", seed, f }
36
36
  }
37
37
 
38
- export function compileLoopEffectOperatorSink<R>(operator: EffectLoopOperator, sink: Sink.Sink<R, any, any>) {
38
+ export function compileLoopEffectOperatorSink<R>(operator: EffectLoopOperator, sink: Sink.Sink<any, any, R>) {
39
39
  return matchEffectLoopOperator(operator, {
40
40
  LoopEffect: (op) => Sink.loopEffect(sink, op.seed, op.f),
41
41
  FilterMapLoopEffect: (op) => Sink.filterMapLoopEffect(sink, op.seed, op.f)
@@ -457,8 +457,8 @@ export function matchEffectLoopOperator<A, B, R, E, C, D>(
457
457
 
458
458
  export function compileCauseLoopEffectOperatorSinkCause<R>(
459
459
  operator: EffectLoopOperator,
460
- sink: Sink.Sink<R, any, any>
461
- ): Sink.Sink<R, any, any> {
460
+ sink: Sink.Sink<any, any, R>
461
+ ): Sink.Sink<any, any, R> {
462
462
  return matchEffectLoopOperator(operator, {
463
463
  LoopEffect: (op) => Sink.loopCauseEffect(sink, op.seed, op.f),
464
464
  FilterMapLoopEffect: (op) => Sink.filterMapLoopCauseEffect(sink, op.seed, op.f)
@@ -13,44 +13,44 @@ export type EffectOperator =
13
13
  | FilterEffect<any, any, any>
14
14
  | FilterMapEffect<any, any, any, any>
15
15
 
16
- export interface MapEffect<A, R2, E2, B> {
16
+ export interface MapEffect<A, B, E2, R2> {
17
17
  readonly _tag: "MapEffect"
18
- readonly f: (a: A) => Effect.Effect<R2, E2, B>
18
+ readonly f: (a: A) => Effect.Effect<B, E2, R2>
19
19
  }
20
20
 
21
- export const MapEffect = <A, R2, E2, B>(f: (a: A) => Effect.Effect<R2, E2, B>): MapEffect<A, R2, E2, B> => ({
21
+ export const MapEffect = <A, B, E2, R2>(f: (a: A) => Effect.Effect<B, E2, R2>): MapEffect<A, B, E2, R2> => ({
22
22
  _tag: "MapEffect",
23
23
  f
24
24
  })
25
25
 
26
- export interface TapEffect<A, R2, E2, B> {
26
+ export interface TapEffect<A, B, E2, R2> {
27
27
  readonly _tag: "TapEffect"
28
- readonly f: (a: A) => Effect.Effect<R2, E2, B>
28
+ readonly f: (a: A) => Effect.Effect<B, E2, R2>
29
29
  }
30
30
 
31
- export const TapEffect = <A, R2, E2, B>(f: (a: A) => Effect.Effect<R2, E2, B>): TapEffect<A, R2, E2, B> => ({
31
+ export const TapEffect = <A, B, E2, R2>(f: (a: A) => Effect.Effect<B, E2, R2>): TapEffect<A, B, E2, R2> => ({
32
32
  _tag: "TapEffect",
33
33
  f
34
34
  })
35
35
 
36
36
  export interface FilterEffect<A, R2, E2> {
37
37
  readonly _tag: "FilterEffect"
38
- readonly f: (a: A) => Effect.Effect<R2, E2, boolean>
38
+ readonly f: (a: A) => Effect.Effect<boolean, E2, R2>
39
39
  }
40
40
 
41
- export const FilterEffect = <A, R2, E2>(f: (a: A) => Effect.Effect<R2, E2, boolean>): FilterEffect<A, R2, E2> => ({
41
+ export const FilterEffect = <A, R2, E2>(f: (a: A) => Effect.Effect<boolean, E2, R2>): FilterEffect<A, R2, E2> => ({
42
42
  _tag: "FilterEffect",
43
43
  f
44
44
  })
45
45
 
46
- export interface FilterMapEffect<A, R2, E2, B> {
46
+ export interface FilterMapEffect<A, B, E2, R2> {
47
47
  readonly _tag: "FilterMapEffect"
48
- readonly f: (a: A) => Effect.Effect<R2, E2, Option.Option<B>>
48
+ readonly f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>
49
49
  }
50
50
 
51
- export const FilterMapEffect = <A, R2, E2, B>(
52
- f: (a: A) => Effect.Effect<R2, E2, Option.Option<B>>
53
- ): FilterMapEffect<A, R2, E2, B> => ({ _tag: "FilterMapEffect", f })
51
+ export const FilterMapEffect = <A, B, E2, R2>(
52
+ f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>
53
+ ): FilterMapEffect<A, B, E2, R2> => ({ _tag: "FilterMapEffect", f })
54
54
 
55
55
  type EffectOperatorFusionMap = {
56
56
  readonly [K in EffectOperator["_tag"]]: {
@@ -190,8 +190,8 @@ export function matchEffectOperator<A, B, C, D>(
190
190
 
191
191
  export function compileEffectOperatorSink<R>(
192
192
  operator: EffectOperator,
193
- sink: Sink.Sink<R, any, any>
194
- ): Sink.Sink<R, any, any> {
193
+ sink: Sink.Sink<any, any, R>
194
+ ): Sink.Sink<any, any, R> {
195
195
  return matchEffectOperator(operator, {
196
196
  MapEffect: (op) => Sink.mapEffect(sink, op.f),
197
197
  FilterEffect: (op) => Sink.filterEffect(sink, op.f),
@@ -202,8 +202,8 @@ export function compileEffectOperatorSink<R>(
202
202
 
203
203
  export function compileCauseEffectOperatorSink<R>(
204
204
  operator: EffectOperator,
205
- sink: Sink.Sink<R, any, any>
206
- ): Sink.Sink<R, any, any> {
205
+ sink: Sink.Sink<any, any, R>
206
+ ): Sink.Sink<any, any, R> {
207
207
  return matchEffectOperator(operator, {
208
208
  MapEffect: (op) =>
209
209
  Sink.make(
@@ -253,10 +253,10 @@ export function compileCauseEffectOperatorSink<R>(
253
253
  })
254
254
  }
255
255
 
256
- export function compileEffectLoop<B, A, R2, E2, C>(
256
+ export function compileEffectLoop<B, A, C, E2, R2>(
257
257
  operator: EffectOperator,
258
- loop: (b: B, a: A) => Effect.Effect<R2, E2, readonly [C, B]>
259
- ): (b: B, i: any) => Effect.Effect<R2, E2, Option.Option<readonly [C, B]>> {
258
+ loop: (b: B, a: A) => Effect.Effect<readonly [C, B], E2, R2>
259
+ ): (b: B, i: any) => Effect.Effect<Option.Option<readonly [C, B]>, E2, R2> {
260
260
  return matchEffectOperator(operator, {
261
261
  MapEffect: (op) => (b, i) => Effect.map(Effect.flatMap(op.f(i), (a) => loop(b, a)), Option.some),
262
262
  TapEffect: (op) => (b, i) => Effect.map(Effect.flatMap(op.f(i), () => loop(b, i)), Option.some),
@@ -275,8 +275,8 @@ export function compileEffectLoop<B, A, R2, E2, C>(
275
275
 
276
276
  export function compileEffectReducer<B, A, R2, E2>(
277
277
  operator: EffectOperator,
278
- loop: (b: B, a: A) => Effect.Effect<R2, E2, B>
279
- ): (b: B, i: any) => Effect.Effect<R2, E2, Option.Option<B>> {
278
+ loop: (b: B, a: A) => Effect.Effect<B, E2, R2>
279
+ ): (b: B, i: any) => Effect.Effect<Option.Option<B>, E2, R2> {
280
280
  return matchEffectOperator(operator, {
281
281
  MapEffect: (op) => (b, i) => Effect.map(Effect.flatMap(op.f(i), (a) => loop(b, a)), Option.some),
282
282
  TapEffect: (op) => (b, i) => Effect.map(Effect.flatMap(op.f(i), () => loop(b, i)), Option.some),
@@ -298,7 +298,7 @@ export function runSyncReduce<A, B, R2, E2>(
298
298
  op: EffectOperator,
299
299
  seed: B,
300
300
  f: (acc: B, a: any) => B
301
- ): Effect.Effect<R2, E2, B> {
301
+ ): Effect.Effect<B, E2, R2> {
302
302
  return matchEffectOperator(op, {
303
303
  MapEffect: (op) => SyncProducer.runReduceEffect(producer, seed, (acc, a) => Effect.map(op.f(a), (b) => f(acc, b))),
304
304
  TapEffect: (op) => SyncProducer.runReduceEffect(producer, seed, (acc, a) => Effect.map(op.f(a), () => f(acc, a))),
@@ -3,50 +3,50 @@ import * as Effect from "effect/Effect"
3
3
  import * as Schedule from "effect/Schedule"
4
4
  import type * as Sink from "../Sink.js"
5
5
 
6
- export type EffectProducer<R = any, E = any, A = any> =
7
- | FromEffect<R, E, A>
8
- | FromScheduled<R, E, any, A>
9
- | Scheduled<R, E, A, any>
6
+ export type EffectProducer<A = any, E = any, R = any> =
7
+ | FromEffect<A, E, R>
8
+ | FromScheduled<any, E, R, A>
9
+ | Scheduled<A, E, R, any>
10
10
 
11
- export interface FromEffect<R, E, A> {
11
+ export interface FromEffect<A, E, R> {
12
12
  readonly _tag: "FromEffect"
13
- readonly source: Effect.Effect<R, E, A>
13
+ readonly source: Effect.Effect<A, E, R>
14
14
  }
15
15
 
16
- export function FromEffect<R, E, A>(source: Effect.Effect<R, E, A>): FromEffect<R, E, A> {
16
+ export function FromEffect<A, E, R>(source: Effect.Effect<A, E, R>): FromEffect<A, E, R> {
17
17
  return { _tag: "FromEffect", source }
18
18
  }
19
19
 
20
- export interface FromScheduled<R, E, I, O> {
20
+ export interface FromScheduled<I, E, R, O> {
21
21
  readonly _tag: "FromScheduled"
22
- readonly input: Effect.Effect<R, E, I>
22
+ readonly input: Effect.Effect<I, E, R>
23
23
  readonly schedule: Schedule.Schedule<R, I, O>
24
24
  }
25
25
 
26
- export function FromScheduled<R, E, R2, I, O>(
27
- input: Effect.Effect<R, E, I>,
26
+ export function FromScheduled<I, E, R, R2, O>(
27
+ input: Effect.Effect<I, E, R>,
28
28
  schedule: Schedule.Schedule<R2, I, O>
29
- ): FromScheduled<R | R2, E, I, O> {
29
+ ): FromScheduled<I, E, R | R2, O> {
30
30
  return { _tag: "FromScheduled", schedule, input }
31
31
  }
32
32
 
33
- export interface Scheduled<R, E, A, O> {
33
+ export interface Scheduled<A, E, R, O> {
34
34
  readonly _tag: "Scheduled"
35
- readonly input: Effect.Effect<R, E, A>
35
+ readonly input: Effect.Effect<A, E, R>
36
36
  readonly schedule: Schedule.Schedule<R, unknown, O>
37
37
  }
38
38
 
39
- export function Scheduled<R, E, A, R2, O>(
40
- input: Effect.Effect<R, E, A>,
39
+ export function Scheduled<A, E, R, R2, O>(
40
+ input: Effect.Effect<A, E, R>,
41
41
  schedule: Schedule.Schedule<R2, unknown, O>
42
- ): Scheduled<R | R2, E, A, O> {
42
+ ): Scheduled<A, E, R | R2, O> {
43
43
  return { _tag: "Scheduled", schedule, input }
44
44
  }
45
45
 
46
- export function runSink<R, E, A, R2>(
47
- producer: EffectProducer<R, E, A>,
48
- sink: Sink.Sink<R2, E, A>
49
- ): Effect.Effect<R | R2, never, unknown> {
46
+ export function runSink<A, E, R, R2>(
47
+ producer: EffectProducer<A, E, R>,
48
+ sink: Sink.Sink<A, E, R2>
49
+ ): Effect.Effect<unknown, never, R | R2> {
50
50
  switch (producer._tag) {
51
51
  case "FromEffect":
52
52
  return Effect.matchCauseEffect(producer.source, sink)
@@ -57,10 +57,10 @@ export function runSink<R, E, A, R2>(
57
57
  }
58
58
  }
59
59
 
60
- function runFromScheduled<R, E, I, O, R2>(
61
- scheduled: FromScheduled<R, E, I, O>,
62
- sink: Sink.Sink<R2, E, O>
63
- ): Effect.Effect<R | R2, never, unknown> {
60
+ function runFromScheduled<I, E, R, O, R2>(
61
+ scheduled: FromScheduled<I, E, R, O>,
62
+ sink: Sink.Sink<O, E, R2>
63
+ ): Effect.Effect<unknown, never, R | R2> {
64
64
  return Effect.catchAllCause(
65
65
  Effect.flatMap(
66
66
  scheduled.input,
@@ -70,20 +70,20 @@ function runFromScheduled<R, E, I, O, R2>(
70
70
  )
71
71
  }
72
72
 
73
- function runSchedule<R, E, A, O, R2>(
74
- scheduled: Scheduled<R, E, A, O>,
75
- sink: Sink.Sink<R2, E, A>
76
- ): Effect.Effect<R | R2, never, unknown> {
73
+ function runSchedule<A, E, R, O, R2>(
74
+ scheduled: Scheduled<A, E, R, O>,
75
+ sink: Sink.Sink<A, E, R2>
76
+ ): Effect.Effect<unknown, never, R | R2> {
77
77
  return Effect.catchAllCause(
78
78
  Effect.schedule(Effect.matchCauseEffect(scheduled.input, sink), scheduled.schedule),
79
79
  sink.onFailure
80
80
  )
81
81
  }
82
82
 
83
- export function runEffect<R, E, A, R2, E2, B>(
84
- producer: EffectProducer<R, E, A>,
85
- f: (a: A) => Effect.Effect<R2, E2, B>
86
- ): Effect.Effect<R | R2, E | E2, unknown> {
83
+ export function runEffect<A, E, R, B, E2, R2>(
84
+ producer: EffectProducer<A, E, R>,
85
+ f: (a: A) => Effect.Effect<B, E2, R2>
86
+ ): Effect.Effect<unknown, E | E2, R | R2> {
87
87
  switch (producer._tag) {
88
88
  case "FromEffect":
89
89
  return Effect.flatMap(producer.source, f)
@@ -91,7 +91,7 @@ export function runEffect<R, E, A, R2, E2, B>(
91
91
  return Effect.flatMap(
92
92
  producer.input,
93
93
  (i) =>
94
- Effect.asyncEffect<never, E | E2, unknown, R | R2, never, unknown>((resume) => {
94
+ Effect.asyncEffect<unknown, E | E2, never, unknown, never, R | R2>((resume) => {
95
95
  const onFailure = (cause: Cause.Cause<E | E2>) => Effect.succeed(resume(Effect.failCause(cause)))
96
96
 
97
97
  return Effect.matchCauseEffect(
@@ -112,11 +112,11 @@ export function runEffect<R, E, A, R2, E2, B>(
112
112
  }
113
113
  }
114
114
 
115
- export function runReduceEffect<R, E, A, R2, E2, B>(
116
- producer: EffectProducer<R, E, A>,
115
+ export function runReduceEffect<A, E, R, B, E2, R2>(
116
+ producer: EffectProducer<A, E, R>,
117
117
  initial: B,
118
- f: (b: B, a: A) => Effect.Effect<R2, E2, B>
119
- ): Effect.Effect<R | R2, E | E2, B> {
118
+ f: (b: B, a: A) => Effect.Effect<B, E2, R2>
119
+ ): Effect.Effect<B, E | E2, R | R2> {
120
120
  return Effect.suspend(() => {
121
121
  let acc = initial
122
122
 
@@ -16,12 +16,12 @@ import * as TestClock from "effect/TestClock"
16
16
  import type { FlattenStrategy, FxFork, ScopedFork } from "../Fx.js"
17
17
  import type * as Sink from "../Sink.js"
18
18
 
19
- export function withBuffers<R, E, A>(size: number, sink: Sink.Sink<R, E, A>) {
19
+ export function withBuffers<A, E, R>(size: number, sink: Sink.Sink<A, E, R>) {
20
20
  const buffers: Array<Array<A>> = Array.from({ length: size }, () => [])
21
21
  const finished = new Set<number>()
22
22
  let currentIndex = 0
23
23
 
24
- const drainBuffer = (index: number): Effect.Effect<R, never, void> => {
24
+ const drainBuffer = (index: number): Effect.Effect<void, never, R> => {
25
25
  const effect = Effect.forEach(buffers[index], sink.onSuccess)
26
26
  buffers[index] = []
27
27
 
@@ -62,14 +62,14 @@ export function withBuffers<R, E, A>(size: number, sink: Sink.Sink<R, E, A>) {
62
62
  } as const
63
63
  }
64
64
 
65
- export const withScope = <R, E, A>(
66
- f: (scope: Scope.CloseableScope) => Effect.Effect<R, E, A>,
65
+ export const withScope = <A, E, R>(
66
+ f: (scope: Scope.CloseableScope) => Effect.Effect<A, E, R>,
67
67
  executionStrategy: ExecutionStrategy.ExecutionStrategy
68
- ): Effect.Effect<R | Scope.Scope, E, A> =>
68
+ ): Effect.Effect<A, E, R | Scope.Scope> =>
69
69
  Effect.acquireUseRelease(Effect.scopeWith((scope) => Scope.fork(scope, executionStrategy)), f, Scope.close)
70
70
 
71
71
  export const getExitEquivalence = <E, A>(A: Equivalence.Equivalence<A>) =>
72
- Equivalence.make<Exit.Exit<E, A>>((a, b) => {
72
+ Equivalence.make<Exit.Exit<A, E>>((a, b) => {
73
73
  if (a._tag === "Failure") {
74
74
  return b._tag === "Failure" && Equal.equals(a.cause, b.cause)
75
75
  } else {
@@ -77,16 +77,16 @@ export const getExitEquivalence = <E, A>(A: Equivalence.Equivalence<A>) =>
77
77
  }
78
78
  })
79
79
 
80
- export function withScopedFork<R, E, A>(
81
- f: (fork: ScopedFork, scope: Scope.CloseableScope) => Effect.Effect<R, E, A>,
80
+ export function withScopedFork<A, E, R>(
81
+ f: (fork: ScopedFork, scope: Scope.CloseableScope) => Effect.Effect<A, E, R>,
82
82
  executionStrategy: ExecutionStrategy.ExecutionStrategy
83
- ): Effect.Effect<R | Scope.Scope, E, A> {
83
+ ): Effect.Effect<A, E, R | Scope.Scope> {
84
84
  return withScope((scope) => f(makeForkInScope(scope), scope), executionStrategy)
85
85
  }
86
86
 
87
87
  export function makeForkInScope(scope: Scope.Scope) {
88
- return <R, E, A>(effect: Effect.Effect<R, E, A>) =>
89
- matchEffectPrimitive<R, E, A, Effect.Effect<R, never, Fiber.Fiber<E, A>>>(effect, {
88
+ return <A, E, R>(effect: Effect.Effect<A, E, R>) =>
89
+ matchEffectPrimitive<A, E, R, Effect.Effect<Fiber.Fiber<A, E>, never, R>>(effect, {
90
90
  Success: (a) => Effect.succeed(Fiber.succeed(a)),
91
91
  Failure: (cause) => Effect.succeed(Fiber.failCause(cause)),
92
92
  Sync: (f) =>
@@ -105,25 +105,25 @@ export function makeForkInScope(scope: Scope.Scope) {
105
105
  })
106
106
  }
107
107
 
108
- export function withSwitchFork<R, E, A>(
109
- f: (fork: FxFork, scope: Scope.CloseableScope) => Effect.Effect<R, E, A>,
108
+ export function withSwitchFork<A, E, R>(
109
+ f: (fork: FxFork, scope: Scope.CloseableScope) => Effect.Effect<A, E, R>,
110
110
  executionStrategy: ExecutionStrategy.ExecutionStrategy
111
111
  ) {
112
112
  return withScopedFork(
113
113
  (fork, scope) =>
114
114
  Effect.flatMap(
115
- SynchronizedRef.make<Fiber.Fiber<never, unknown>>(Fiber.unit),
115
+ SynchronizedRef.make<Fiber.Fiber<unknown>>(Fiber.unit),
116
116
  (ref) => runSwitchFork(ref, fork, scope, f)
117
117
  ),
118
118
  executionStrategy
119
119
  )
120
120
  }
121
121
 
122
- export function runSwitchFork<R, E, A>(
123
- ref: SynchronizedRef.SynchronizedRef<Fiber.Fiber<never, unknown>>,
122
+ export function runSwitchFork<A, E, R>(
123
+ ref: SynchronizedRef.SynchronizedRef<Fiber.Fiber<unknown>>,
124
124
  fork: ScopedFork,
125
125
  scope: Scope.CloseableScope,
126
- f: (fork: FxFork, scope: Scope.CloseableScope) => Effect.Effect<R, E, A>
126
+ f: (fork: FxFork, scope: Scope.CloseableScope) => Effect.Effect<A, E, R>
127
127
  ) {
128
128
  return Effect.zipRight(
129
129
  f(
@@ -142,13 +142,13 @@ export function runSwitchFork<R, E, A>(
142
142
  )
143
143
  }
144
144
 
145
- export function withExhaustFork<R, E, A>(
146
- f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>,
145
+ export function withExhaustFork<A, E, R>(
146
+ f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>,
147
147
  executionStrategy: ExecutionStrategy.ExecutionStrategy
148
148
  ) {
149
149
  return withScopedFork((fork, scope) => {
150
150
  return Effect.flatMap(
151
- SynchronizedRef.make<Fiber.Fiber<never, void> | null>(null),
151
+ SynchronizedRef.make<Fiber.Fiber<void> | null>(null),
152
152
  (ref) =>
153
153
  Effect.flatMap(
154
154
  f((effect) =>
@@ -170,15 +170,15 @@ export function withExhaustFork<R, E, A>(
170
170
  }, executionStrategy)
171
171
  }
172
172
 
173
- export function withExhaustLatestFork<R, E, A>(
174
- f: (exhaustLatestFork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>,
173
+ export function withExhaustLatestFork<A, E, R>(
174
+ f: (exhaustLatestFork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>,
175
175
  executionStrategy: ExecutionStrategy.ExecutionStrategy
176
176
  ) {
177
177
  return withScopedFork((fork, scope) =>
178
178
  Effect.flatMap(
179
179
  Effect.zip(
180
- Ref.make<Fiber.Fiber<never, void> | void>(undefined),
181
- Ref.make<Option.Option<Effect.Effect<any, never, void>>>(Option.none())
180
+ Ref.make<Fiber.Fiber<void> | void>(undefined),
181
+ Ref.make<Option.Option<Effect.Effect<void, never, any>>>(Option.none())
182
182
  ),
183
183
  ([ref, nextEffect]) => {
184
184
  const reset = Ref.set(ref, undefined)
@@ -188,7 +188,7 @@ export function withExhaustLatestFork<R, E, A>(
188
188
 
189
189
  // Run the next value that's be saved for replay if it exists
190
190
 
191
- const runNext: Effect.Effect<any, never, void> = Effect.flatMap(
191
+ const runNext: Effect.Effect<void, never, any> = Effect.flatMap(
192
192
  Ref.get(nextEffect),
193
193
  (next) => {
194
194
  if (Option.isNone(next)) {
@@ -206,7 +206,7 @@ export function withExhaustLatestFork<R, E, A>(
206
206
  }
207
207
  )
208
208
 
209
- const exhaustLatestFork = <R2>(eff: Effect.Effect<R2, never, void>) =>
209
+ const exhaustLatestFork = <R2>(eff: Effect.Effect<void, never, R2>) =>
210
210
  Effect.flatMap(Ref.get(ref), (currentFiber) =>
211
211
  currentFiber
212
212
  ? Ref.set(nextEffect, Option.some(eff))
@@ -225,12 +225,12 @@ export function withExhaustLatestFork<R, E, A>(
225
225
  ), executionStrategy)
226
226
  }
227
227
 
228
- export function withUnboundedFork<R, E, A>(
229
- f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>
228
+ export function withUnboundedFork<A, E, R>(
229
+ f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>
230
230
  ) {
231
231
  return Effect.scopeWith((scope) =>
232
232
  Effect.flatMap(
233
- FiberSet.make<never, void>(),
233
+ FiberSet.make<void, never>(),
234
234
  (set) =>
235
235
  Effect.flatMap(
236
236
  f((effect) => FiberSet.run(set, effect), scope),
@@ -241,13 +241,13 @@ export function withUnboundedFork<R, E, A>(
241
241
  }
242
242
 
243
243
  export function withBoundedFork(capacity: number) {
244
- return <R, E, A>(
245
- f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>,
244
+ return <A, E, R>(
245
+ f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>,
246
246
  executionStrategy: ExecutionStrategy.ExecutionStrategy
247
247
  ) => {
248
248
  return withScopedFork((fork, scope) =>
249
249
  Effect.flatMap(
250
- Ref.make<Set<Fiber.Fiber<never, void>>>(new Set()).pipe(Effect.zip(Effect.makeSemaphore(capacity))),
250
+ Ref.make<Set<Fiber.Fiber<void>>>(new Set()).pipe(Effect.zip(Effect.makeSemaphore(capacity))),
251
251
  ([ref, semaphore]) =>
252
252
  Effect.flatMap(
253
253
  f((effect) =>
@@ -271,10 +271,10 @@ export function withBoundedFork(capacity: number) {
271
271
 
272
272
  export function withFlattenStrategy(
273
273
  strategy: FlattenStrategy
274
- ): <R, E, A>(
275
- f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>,
274
+ ): <A, E, R>(
275
+ f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>,
276
276
  executionStrategy: ExecutionStrategy.ExecutionStrategy
277
- ) => Effect.Effect<R | Scope.Scope, E, void> {
277
+ ) => Effect.Effect<void, E, R | Scope.Scope> {
278
278
  switch (strategy._tag) {
279
279
  case "Bounded":
280
280
  return withBoundedFork(strategy.capacity)
@@ -289,8 +289,8 @@ export function withFlattenStrategy(
289
289
  }
290
290
  }
291
291
 
292
- export function matchEffectPrimitive<R, E, A, Z>(
293
- effect: Effect.Effect<R, E, A>,
292
+ export function matchEffectPrimitive<A, E, R, Z>(
293
+ effect: Effect.Effect<A, E, R>,
294
294
  matchers: {
295
295
  Success: (a: A) => Z
296
296
  Failure: (e: Cause.Cause<E>) => Z
@@ -299,7 +299,7 @@ export function matchEffectPrimitive<R, E, A, Z>(
299
299
  Right: (a: A) => Z
300
300
  Some: (a: A) => Z
301
301
  None: (e: E) => Z
302
- Otherwise: (effect: Effect.Effect<R, E, A>) => Z
302
+ Otherwise: (effect: Effect.Effect<A, E, R>) => Z
303
303
  }
304
304
  ): Z {
305
305
  const eff = effect as any
@@ -339,9 +339,9 @@ export function adjustTime(input: Duration.DurationInput = 1) {
339
339
  )
340
340
  }
341
341
 
342
- export function tupleSink<R, E, A extends ReadonlyArray<any>, R2, E2, B>(
343
- sink: Sink.Sink<R, E, A>,
344
- f: (sink: (index: number, value: A[number]) => Effect.Effect<R, never, unknown>) => Effect.Effect<R2, E2, B>,
342
+ export function tupleSink<A extends ReadonlyArray<any>, E, R, B, E2, R2>(
343
+ sink: Sink.Sink<A, E, R>,
344
+ f: (sink: (index: number, value: A[number]) => Effect.Effect<unknown, never, R>) => Effect.Effect<B, E2, R2>,
345
345
  expected: number
346
346
  ) {
347
347
  return Effect.suspend(() => {
@@ -361,14 +361,14 @@ export function tupleSink<R, E, A extends ReadonlyArray<any>, R2, E2, B>(
361
361
  })
362
362
  }
363
363
 
364
- export function withDebounceFork<R, E, A>(
365
- f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<R, E, A>,
364
+ export function withDebounceFork<A, E, R>(
365
+ f: (fork: FxFork, scope: Scope.Scope) => Effect.Effect<A, E, R>,
366
366
  duration: Duration.DurationInput
367
- ): Effect.Effect<R | Scope.Scope, E, unknown> {
367
+ ): Effect.Effect<unknown, E, R | Scope.Scope> {
368
368
  return withScopedFork(
369
369
  (fork, scope) =>
370
370
  Effect.flatMap(
371
- SynchronizedRef.make(Option.none<Fiber.Fiber<never, void>>()),
371
+ SynchronizedRef.make(Option.none<Fiber.Fiber<void>>()),
372
372
  (ref) =>
373
373
  Effect.flatMap(
374
374
  f(
@@ -417,8 +417,8 @@ export class RingBuffer<A> {
417
417
  }
418
418
  }
419
419
 
420
- forEach<R2, E2, B>(
421
- f: (a: A, i: number) => Effect.Effect<R2, E2, B>
420
+ forEach<B, E2, R2>(
421
+ f: (a: A, i: number) => Effect.Effect<B, E2, R2>
422
422
  ) {
423
423
  switch (this._size) {
424
424
  case 0:
@@ -450,16 +450,16 @@ export class RingBuffer<A> {
450
450
  }
451
451
 
452
452
  export function awaitScopeClose(scope: Scope.Scope) {
453
- return Effect.asyncEffect<never, never, unknown, never, never, void>((cb) =>
453
+ return Effect.asyncEffect<unknown, never, never, void, never, never>((cb) =>
454
454
  Scope.addFinalizerExit(scope, () => Effect.sync(() => cb(Effect.unit)))
455
455
  )
456
456
  }
457
457
 
458
- export class MulticastEffect<R, E, A> extends Effectable.Class<R, E, A> {
459
- private _fiber: Fiber.Fiber<E, A> | null = null
458
+ export class MulticastEffect<A, E, R> extends Effectable.Class<A, E, R> {
459
+ private _fiber: Fiber.Fiber<A, E> | null = null
460
460
 
461
461
  constructor(
462
- readonly effect: Effect.Effect<R, E, A>
462
+ readonly effect: Effect.Effect<A, E, R>
463
463
  ) {
464
464
  super()
465
465
  }
@@ -8,10 +8,10 @@ import { diffIterator } from "./diff.js"
8
8
  import { withDebounceFork } from "./helpers.js"
9
9
  import { FxBase } from "./protos.js"
10
10
 
11
- export function keyed<R, E, A, B extends PropertyKey, R2, E2, C>(
12
- fx: Fx<R, E, ReadonlyArray<A>>,
13
- options: KeyedOptions<A, B, R2, E2, C>
14
- ): Fx<R | R2 | Scope.Scope, E | E2, ReadonlyArray<C>> {
11
+ export function keyed<A, E, R, B extends PropertyKey, C, E2, R2>(
12
+ fx: Fx<ReadonlyArray<A>, E, R>,
13
+ options: KeyedOptions<A, B, C, E2, R2>
14
+ ): Fx<ReadonlyArray<C>, E | E2, R | R2 | Scope.Scope> {
15
15
  return new Keyed(fx, options)
16
16
  }
17
17
 
@@ -20,19 +20,19 @@ type StateContext<A, C> = {
20
20
  output: C
21
21
  }
22
22
 
23
- const StateContext = Context.Tag<StateContext<any, any>>()
23
+ const StateContext = Context.GenericTag<StateContext<any, any>>("@services/StateContext")
24
24
 
25
- class Keyed<R, E, A, B extends PropertyKey, R2, E2, C> extends FxBase<R | R2 | Scope.Scope, E | E2, ReadonlyArray<C>>
26
- implements Fx<R | R2 | Scope.Scope, E | E2, ReadonlyArray<C>>
25
+ class Keyed<A, E, R, B extends PropertyKey, C, E2, R2> extends FxBase<ReadonlyArray<C>, E | E2, R | R2 | Scope.Scope>
26
+ implements Fx<ReadonlyArray<C>, E | E2, R | R2 | Scope.Scope>
27
27
  {
28
28
  constructor(
29
- readonly fx: Fx<R, E, ReadonlyArray<A>>,
30
- readonly options: KeyedOptions<A, B, R2, E2, C>
29
+ readonly fx: Fx<ReadonlyArray<A>, E, R>,
30
+ readonly options: KeyedOptions<A, B, C, E2, R2>
31
31
  ) {
32
32
  super()
33
33
  }
34
34
 
35
- run<R3>(sink: Sink.Sink<R3, E | E2, ReadonlyArray<C>>) {
35
+ run<R3>(sink: Sink.Sink<ReadonlyArray<C>, E | E2, R3>) {
36
36
  return Effect.fiberIdWith((id) => runKeyed(this.fx, this.options, sink, id))
37
37
  }
38
38
  }
@@ -51,12 +51,12 @@ function emptyKeyedState<A, B extends PropertyKey, C>(): KeyedState<A, B, C> {
51
51
  }
52
52
  }
53
53
 
54
- function runKeyed<R, E, A, B extends PropertyKey, R2, E2, C, R3>(
55
- fx: Fx<R, E, ReadonlyArray<A>>,
56
- options: KeyedOptions<A, B, R2, E2, C>,
57
- sink: Sink.Sink<R3, E | E2, ReadonlyArray<C>>,
54
+ function runKeyed<A, E, R, B extends PropertyKey, C, E2, R2, R3>(
55
+ fx: Fx<ReadonlyArray<A>, E, R>,
56
+ options: KeyedOptions<A, B, C, E2, R2>,
57
+ sink: Sink.Sink<ReadonlyArray<C>, E | E2, R3>,
58
58
  id: FiberId.FiberId
59
- ) {
59
+ ): Effect.Effect<unknown, never, Scope.Scope | R | R2 | R3> {
60
60
  return withDebounceFork(
61
61
  (forkDebounce, parentScope) => {
62
62
  const state = emptyKeyedState<A, B, C>()
@@ -126,8 +126,8 @@ class KeyedEntry<A, C> {
126
126
  public value: A,
127
127
  public index: number,
128
128
  public output: Option.Option<C>,
129
- public readonly ref: RefSubject.RefSubject<never, never, A>,
130
- public readonly interrupt: Effect.Effect<never, never, void>
129
+ public readonly ref: RefSubject.RefSubject<A>,
130
+ public readonly interrupt: Effect.Effect<void>
131
131
  ) {}
132
132
  }
133
133
 
@@ -158,14 +158,14 @@ function addValue<A, B extends PropertyKey, C, R2, E2, E, R3, D>(
158
158
  patch: Add<A, B>,
159
159
  id: FiberId.FiberId,
160
160
  parentScope: Scope.Scope,
161
- options: KeyedOptions<A, B, R2, E2, C>,
162
- sink: Sink.Sink<R2 | R3, E | E2, ReadonlyArray<C>>,
163
- scheduleNextEmit: Effect.Effect<R3, never, D>
161
+ options: KeyedOptions<A, B, C, E2, R2>,
162
+ sink: Sink.Sink<ReadonlyArray<C>, E | E2, R2 | R3>,
163
+ scheduleNextEmit: Effect.Effect<D, never, R3>
164
164
  ) {
165
165
  return Effect.gen(function*(_) {
166
166
  const value = values[patch.index]
167
167
  const childScope = yield* _(Scope.fork(parentScope, ExecutionStrategy.sequential))
168
- const ref: RefSubject.RefSubject<never, never, A> = yield* _(RefSubject.unsafeMake<never, A>({
168
+ const ref: RefSubject.RefSubject<A> = yield* _(RefSubject.unsafeMake<never, A>({
169
169
  initial: Effect.sync(() => entry.value),
170
170
  initialValue: value,
171
171
  scope: childScope,