@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
@@ -216,14 +216,14 @@ export function fuseLoopOperators<A, B, C, D, E>(
216
216
  })
217
217
  }
218
218
 
219
- export function compileLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<R, any, any>) {
219
+ export function compileLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<any, any, R>) {
220
220
  return matchSyncLoopOperator(operator, {
221
221
  Loop: (op) => Sink.loop(sink, op.seed, op.f),
222
222
  FilterMapLoop: (op) => Sink.filterMapLoop(sink, op.seed, op.f)
223
223
  })
224
224
  }
225
225
 
226
- export function compileCauseLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<R, any, any>) {
226
+ export function compileCauseLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<any, any, R>) {
227
227
  return matchSyncLoopOperator(operator, {
228
228
  Loop: (op) => Sink.loopCause(sink, op.seed, op.f),
229
229
  FilterMapLoop: (op) => Sink.filterMapLoopCause(sink, op.seed, op.f)
@@ -68,7 +68,7 @@ export function fuseOperators(first: Operator, second: Operator): Operator {
68
68
  })
69
69
  }
70
70
 
71
- export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<R, any, any>): Sink<R | R2, any, any> {
71
+ export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<any, any, R>): Sink<any, any, R | R2> {
72
72
  return matchOperator(operator, {
73
73
  SyncOperator: (op) => SyncOp.compileSyncOperatorSink(op, sink),
74
74
  EffectOperator: (op) => EffectOp.compileEffectOperatorSink(op, sink),
@@ -77,7 +77,7 @@ export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<R, any
77
77
  })
78
78
  }
79
79
 
80
- export function compileOperatorSinkCause<R, R2>(operator: Operator, sink: Sink<R, any, any>): Sink<R | R2, any, any> {
80
+ export function compileOperatorSinkCause<R, R2>(operator: Operator, sink: Sink<any, any, R>): Sink<any, any, R | R2> {
81
81
  return matchOperator(operator, {
82
82
  SyncOperator: (op) => SyncOp.compileCauseSyncOperatorSink(op, sink),
83
83
  EffectOperator: (op) => EffectOp.compileCauseEffectOperatorSink(op, sink),
@@ -12,27 +12,27 @@ const Variance: Fx.Variance<never, never, never> = {
12
12
  _A: identity
13
13
  }
14
14
 
15
- export abstract class FxBase<R, E, A> implements Fx<R, E, A> {
16
- readonly [TypeId]: Fx.Variance<R, E, A> = Variance
15
+ export abstract class FxBase<A, E, R> implements Fx<A, E, R> {
16
+ readonly [TypeId]: Fx.Variance<A, E, R> = Variance
17
17
 
18
- abstract run<R2>(sink: Sink<R2, E, A>): Effect.Effect<R | R2, never, unknown>
18
+ abstract run<R2>(sink: Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2>
19
19
 
20
20
  pipe() {
21
21
  return pipeArguments(this, arguments)
22
22
  }
23
23
  }
24
24
 
25
- export abstract class FxEffectBase<R, E, A, R2, E2, B> extends Effectable.StructuralClass<R2, E2, B>
26
- implements Fx<R, E, A>, Effect.Effect<R2, E2, B>
25
+ export abstract class FxEffectBase<A, E, R, B, E2, R2> extends Effectable.StructuralClass<B, E2, R2>
26
+ implements Fx<A, E, R>, Effect.Effect<B, E2, R2>
27
27
  {
28
- readonly [TypeId]: Fx.Variance<R, E, A> = Variance
28
+ readonly [TypeId]: Fx.Variance<A, E, R> = Variance
29
29
 
30
- abstract run<R3>(sink: Sink<R3, E, A>): Effect.Effect<R | R3, never, unknown>
30
+ abstract run<R3>(sink: Sink<A, E, R3>): Effect.Effect<unknown, never, R | R3>
31
31
 
32
- abstract toEffect(): Effect.Effect<R2, E2, B>
32
+ abstract toEffect(): Effect.Effect<B, E2, R2>
33
33
 
34
- protected _effect: Effect.Effect<R2, E2, B> | undefined
35
- commit(): Effect.Effect<R2, E2, B> {
34
+ protected _effect: Effect.Effect<B, E2, R2> | undefined
35
+ commit(): Effect.Effect<B, E2, R2> {
36
36
  if (this._effect === undefined) {
37
37
  return (this._effect = this.toEffect())
38
38
  } else {
@@ -41,13 +41,13 @@ export abstract class FxEffectBase<R, E, A, R2, E2, B> extends Effectable.Struct
41
41
  }
42
42
  }
43
43
 
44
- export abstract class EffectBase<R, E, A> extends Effectable.StructuralClass<R, E, A>
45
- implements Effect.Effect<R, E, A>
44
+ export abstract class EffectBase<A, E, R> extends Effectable.StructuralClass<A, E, R>
45
+ implements Effect.Effect<A, E, R>
46
46
  {
47
- abstract toEffect(): Effect.Effect<R, E, A>
47
+ abstract toEffect(): Effect.Effect<A, E, R>
48
48
 
49
- private _effect: Effect.Effect<R, E, A> | undefined
50
- commit(): Effect.Effect<R, E, A> {
49
+ private _effect: Effect.Effect<A, E, R> | undefined
50
+ commit(): Effect.Effect<A, E, R> {
51
51
  if (this._effect === undefined) {
52
52
  return (this._effect = this.toEffect())
53
53
  } else {
@@ -6,12 +6,12 @@ import * as Runtime from "effect/Runtime"
6
6
  import * as RuntimeFlags from "effect/RuntimeFlags"
7
7
  import type * as Scope from "effect/Scope"
8
8
 
9
- export type Provide<R, E, A> =
9
+ export type Provide<A, E, R> =
10
10
  | ProvideContext<A>
11
- | ProvideLayer<R, E, A>
11
+ | ProvideLayer<A, E, R>
12
12
  | ProvideRuntime<A>
13
13
  | ProvideService<A, any>
14
- | ProvideServiceEffect<R, E, A, any>
14
+ | ProvideServiceEffect<A, any, E, R>
15
15
 
16
16
  export interface ProvideContext<A> {
17
17
  readonly _tag: "ProvideContext"
@@ -23,12 +23,12 @@ export const ProvideContext = <A>(i0: Context.Context<A>): ProvideContext<A> =>
23
23
  i0
24
24
  })
25
25
 
26
- export interface ProvideLayer<R, E, A> {
26
+ export interface ProvideLayer<A, E, R> {
27
27
  readonly _tag: "ProvideLayer"
28
- readonly i0: Layer.Layer<R, E, A>
28
+ readonly i0: Layer.Layer<A, E, R>
29
29
  }
30
30
 
31
- export const ProvideLayer = <R, E, A>(i0: Layer.Layer<R, E, A>): ProvideLayer<R, E, A> => ({
31
+ export const ProvideLayer = <A, E, R>(i0: Layer.Layer<A, E, R>): ProvideLayer<A, E, R> => ({
32
32
  _tag: "ProvideLayer",
33
33
  i0
34
34
  })
@@ -45,16 +45,16 @@ export const ProvideService = <I, S>(i0: Context.Tag<I, S>, i1: S): ProvideServi
45
45
  i1
46
46
  })
47
47
 
48
- export interface ProvideServiceEffect<R, E, I, S> {
48
+ export interface ProvideServiceEffect<I, S, E, R> {
49
49
  readonly _tag: "ProvideServiceEffect"
50
50
  readonly i0: Context.Tag<I, S>
51
- readonly i1: Effect.Effect<R, E, S>
51
+ readonly i1: Effect.Effect<S, E, R>
52
52
  }
53
53
 
54
- export const ProvideServiceEffect = <R, E, I, S>(
54
+ export const ProvideServiceEffect = <I, S, E, R>(
55
55
  i0: Context.Tag<I, S>,
56
- i1: Effect.Effect<R, E, S>
57
- ): ProvideServiceEffect<R, E, I, S> => ({
56
+ i1: Effect.Effect<S, E, R>
57
+ ): ProvideServiceEffect<I, S, E, R> => ({
58
58
  _tag: "ProvideServiceEffect",
59
59
  i0,
60
60
  i1
@@ -70,34 +70,34 @@ export const ProvideRuntime = <A>(i0: Runtime.Runtime<A>): ProvideRuntime<A> =>
70
70
  i0
71
71
  })
72
72
 
73
- export function matchProvide<R = never, E = never, A = never, B = never>(
74
- self: Provide<R, E, A>,
73
+ export function matchProvide<A, E, R, B>(
74
+ self: Provide<A, E, R>,
75
75
  matchers: {
76
76
  readonly ProvideContext: (i0: Context.Context<A>) => B
77
77
  readonly ProvideRuntime: (i0: Runtime.Runtime<A>) => B
78
- readonly ProvideLayer: (i0: Layer.Layer<R, E, A>) => B
78
+ readonly ProvideLayer: (i0: Layer.Layer<A, E, R>) => B
79
79
  readonly ProvideService: (tag: Context.Tag<A, any>, service: any) => B
80
- readonly ProvideServiceEffect: (tag: Context.Tag<A, any>, service: Effect.Effect<R, E, any>) => B
80
+ readonly ProvideServiceEffect: (tag: Context.Tag<A, any>, service: Effect.Effect<any, E, R>) => B
81
81
  }
82
82
  ): B {
83
83
  return matchers[self._tag](self.i0 as any, (self as any).i1)
84
84
  }
85
85
 
86
- export function merge<R = never, E = never, A = never, R2 = never, E2 = never, B = never>(
87
- self: Provide<R, E, A>,
88
- that: Provide<R2, E2, B>
89
- ): Provide<Exclude<R, B> | R2, E | E2, A | B> {
86
+ export function merge<A, E, R, B, E2, R2>(
87
+ self: Provide<A, E, R>,
88
+ that: Provide<B, E2, R2>
89
+ ): Provide<A | B, E | E2, Exclude<R, B> | R2> {
90
90
  return ProvideLayer(Layer.provideMerge(toLayer(self), toLayer(that)))
91
91
  }
92
92
 
93
- export function buildWithScope<R, E, A>(
94
- provide: Provide<R, E, A>,
93
+ export function buildWithScope<A, E, R>(
94
+ provide: Provide<A, E, R>,
95
95
  scope: Scope.Scope
96
96
  ) {
97
97
  return Layer.buildWithScope(toLayer(provide), scope)
98
98
  }
99
99
 
100
- export function toLayer<R, E, A>(provide: Provide<R, E, A>): Layer.Layer<R, E, A> {
100
+ export function toLayer<A, E, R>(provide: Provide<A, E, R>): Layer.Layer<A, E, R> {
101
101
  switch (provide._tag) {
102
102
  case "ProvideContext":
103
103
  return Layer.succeedContext(provide.i0)
@@ -112,14 +112,14 @@ export function toLayer<R, E, A>(provide: Provide<R, E, A>): Layer.Layer<R, E, A
112
112
  }
113
113
  }
114
114
 
115
- export function provideToEffect<R, E, A, R2 = never, E2 = never, S = never>(
116
- effect: Effect.Effect<R, E, A>,
117
- provide: Provide<R2, E2, S>
118
- ): Effect.Effect<Exclude<R, S> | R2, E | E2, A> {
115
+ export function provideToEffect<A, E, R, R2 = never, E2 = never, S = never>(
116
+ effect: Effect.Effect<A, E, R>,
117
+ provide: Provide<S, E, R2>
118
+ ): Effect.Effect<A, E | E2, Exclude<R, S> | R2> {
119
119
  return Effect.provide(effect, toLayer(provide))
120
120
  }
121
121
 
122
- export function runtimeToLayer<R>(runtime: Runtime.Runtime<R>): Layer.Layer<never, never, R> {
122
+ export function runtimeToLayer<R>(runtime: Runtime.Runtime<R>): Layer.Layer<R> {
123
123
  // Calculate patch
124
124
  const patchRefs = FiberRefsPatch.diff(Runtime.defaultRuntime.fiberRefs, runtime.fiberRefs)
125
125
  const patchFlags = RuntimeFlags.diff(Runtime.defaultRuntime.runtimeFlags, runtime.runtimeFlags)
@@ -10,10 +10,10 @@ import * as Subject from "../Subject.js"
10
10
  import { withScopedFork } from "./helpers.js"
11
11
  import { FxBase } from "./protos.js"
12
12
 
13
- export function share<R, E, A, R2>(
14
- fx: Fx<R, E, A>,
15
- subject: Subject.Subject<R2, E, A>
16
- ): Fx<R | R2 | Scope.Scope, E, A> {
13
+ export function share<A, E, R, R2>(
14
+ fx: Fx<A, E, R>,
15
+ subject: Subject.Subject<A, E, R2>
16
+ ): Fx<A, E, R | R2 | Scope.Scope> {
17
17
  return new Share(fx, subject)
18
18
  }
19
19
 
@@ -29,18 +29,18 @@ class RefCounter {
29
29
  }
30
30
  }
31
31
 
32
- export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
33
- _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<never, unknown>>> = MutableRef.make(Option.none())
32
+ export class Share<A, E, R, R2> extends FxBase<A, E, R | R2 | Scope.Scope> {
33
+ _FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>> = MutableRef.make(Option.none())
34
34
  _RefCount = new RefCounter()
35
35
 
36
36
  constructor(
37
- readonly i0: Fx<R, E, A>,
38
- readonly i1: Subject.Subject<R2, E, A>
37
+ readonly i0: Fx<A, E, R>,
38
+ readonly i1: Subject.Subject<A, E, R2>
39
39
  ) {
40
40
  super()
41
41
  }
42
42
 
43
- run<R3>(sink: Sink<R3, E, A>): Effect.Effect<R | R2 | R3 | Scope.Scope, never, unknown> {
43
+ run<R3>(sink: Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
44
44
  return withScopedFork(
45
45
  (fork) =>
46
46
  Effect.flatMap(
@@ -53,7 +53,7 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
53
53
  )
54
54
  }
55
55
 
56
- private initialize(): Effect.Effect<R | R2, never, unknown> {
56
+ private initialize(): Effect.Effect<unknown, never, R | R2> {
57
57
  return Effect.suspend(() => {
58
58
  if (this._RefCount.increment() === 1) {
59
59
  return this.i0.run(this.i1).pipe(
@@ -80,7 +80,7 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
80
80
  })
81
81
  }
82
82
 
83
- private interrupt(): Effect.Effect<R | R2, never, void> {
83
+ private interrupt(): Effect.Effect<void, never, R | R2> {
84
84
  return Effect.suspend(() => {
85
85
  const fiber = Option.getOrNull(MutableRef.getAndSet(this._FxFiber, Option.none()))
86
86
 
@@ -89,24 +89,24 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
89
89
  }
90
90
  }
91
91
 
92
- export function multicast<R, E, A>(
93
- fx: Fx<R, E, A>
94
- ): Fx<R | Scope.Scope, E, A> {
95
- return new Share(fx, Subject.unsafeMake<E, A>(0))
92
+ export function multicast<A, E, R>(
93
+ fx: Fx<A, E, R>
94
+ ): Fx<A, E, R | Scope.Scope> {
95
+ return new Share(fx, Subject.unsafeMake<A, E>(0))
96
96
  }
97
97
 
98
- export function hold<R, E, A>(
99
- fx: Fx<R, E, A>
100
- ): Fx<R | Scope.Scope, E, A> {
101
- return new Share(fx, Subject.unsafeMake<E, A>(1))
98
+ export function hold<A, E, R>(
99
+ fx: Fx<A, E, R>
100
+ ): Fx<A, E, R | Scope.Scope> {
101
+ return new Share(fx, Subject.unsafeMake<A, E>(1))
102
102
  }
103
103
 
104
104
  export const replay: {
105
- (capacity: number): <R, E, A>(fx: Fx<R, E, A>) => Fx<R, E, A>
106
- <R, E, A>(fx: Fx<R, E, A>, capacity: number): Fx<R, E, A>
107
- } = dual(2, function replay<R, E, A>(
108
- fx: Fx<R, E, A>,
105
+ (capacity: number): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>
106
+ <A, E, R>(fx: Fx<A, E, R>, capacity: number): Fx<A, E, R>
107
+ } = dual(2, function replay<A, E, R>(
108
+ fx: Fx<A, E, R>,
109
109
  capacity: number
110
- ): Fx<R | Scope.Scope, E, A> {
111
- return new Share(fx, Subject.unsafeMake<E, A>(capacity))
110
+ ): Fx<A, E, R | Scope.Scope> {
111
+ return new Share(fx, Subject.unsafeMake<A, E>(capacity))
112
112
  })
@@ -80,8 +80,8 @@ export function matchSyncOperator<A>(operator: SyncOperator, matchers: {
80
80
 
81
81
  export function compileSyncOperatorSink<R>(
82
82
  operator: SyncOperator,
83
- sink: Sink.Sink<R, any, any>
84
- ): Sink.Sink<R, any, any> {
83
+ sink: Sink.Sink<any, any, R>
84
+ ): Sink.Sink<any, any, R> {
85
85
  return matchSyncOperator(operator, {
86
86
  Map: (op) => Sink.map(sink, op.f),
87
87
  Filter: (op) => Sink.filter(sink, op.f),
@@ -91,8 +91,8 @@ export function compileSyncOperatorSink<R>(
91
91
 
92
92
  export function compileCauseSyncOperatorSink<R>(
93
93
  operator: SyncOperator,
94
- sink: Sink.Sink<R, any, any>
95
- ): Sink.Sink<R, any, any> {
94
+ sink: Sink.Sink<any, any, R>
95
+ ): Sink.Sink<any, any, R> {
96
96
  return matchSyncOperator(operator, {
97
97
  Map: (op) => Sink.make((a) => sink.onFailure(op.f(a)), sink.onSuccess),
98
98
  Filter: (op) => Sink.make((a) => op.f(a) ? sink.onFailure(a) : Effect.unit, sink.onSuccess),
@@ -47,8 +47,8 @@ export const matchSyncProducer = <A, R>(
47
47
 
48
48
  export function runSink<A, R, E>(
49
49
  producer: SyncProducer<A>,
50
- sink: Sink<R, E, A>
51
- ): Effect.Effect<R, never, unknown> {
50
+ sink: Sink<A, E, R>
51
+ ): Effect.Effect<unknown, never, R> {
52
52
  return matchSyncProducer(producer, {
53
53
  Success: (a) => sink.onSuccess(a),
54
54
  FromSync: (a) => Effect.suspend(() => sink.onSuccess(a())),
@@ -61,7 +61,7 @@ export function runReduce<A, B>(
61
61
  producer: SyncProducer<A>,
62
62
  initial: B,
63
63
  f: (b: B, a: any) => B
64
- ): Effect.Effect<never, never, B> {
64
+ ): Effect.Effect<B> {
65
65
  return matchSyncProducer(producer, {
66
66
  Success: (a) => syncOnce(() => f(initial, a)),
67
67
  FromSync: (a) => syncOnce(() => f(initial, a())),
@@ -70,11 +70,11 @@ export function runReduce<A, B>(
70
70
  })
71
71
  }
72
72
 
73
- export function runReduceEffect<A, R2, E2, B>(
73
+ export function runReduceEffect<A, B, E2, R2>(
74
74
  producer: SyncProducer<A>,
75
75
  initial: B,
76
- f: (b: B, a: any) => Effect.Effect<R2, E2, B>
77
- ): Effect.Effect<R2, E2, B> {
76
+ f: (b: B, a: any) => Effect.Effect<B, E2, R2>
77
+ ): Effect.Effect<B, E2, R2> {
78
78
  return matchSyncProducer(producer, {
79
79
  Success: (a) => effectOnce(() => f(initial, a)),
80
80
  FromSync: (a) => Effect.suspend(() => f(initial, a())),
@@ -83,7 +83,7 @@ export function runReduceEffect<A, R2, E2, B>(
83
83
  })
84
84
  }
85
85
 
86
- function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<R2, never, A>): Effect.Effect<R2, never, unknown> {
86
+ function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
87
87
  if (array.length === 0) return Effect.unit
88
88
  else if (array.length === 1) return sink.onSuccess(array[0])
89
89
  else {
@@ -96,8 +96,8 @@ function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<R2, never, A>):
96
96
  }
97
97
  }
98
98
 
99
- function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<R2, never, A>): Effect.Effect<R2, never, unknown> {
100
- let effect: Effect.Effect<R2, never, any> = Effect.unit
99
+ function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
100
+ let effect: Effect.Effect<any, never, R2> = Effect.unit
101
101
 
102
102
  for (const item of array) {
103
103
  effect = Effect.zipRight(effect, sink.onSuccess(item))
@@ -106,7 +106,7 @@ function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<R2, never, A>): Ef
106
106
  return effect
107
107
  }
108
108
 
109
- export const syncOnce = <A>(f: () => A): Effect.Effect<never, never, A> => {
109
+ export const syncOnce = <A>(f: () => A): Effect.Effect<A> => {
110
110
  let memoized: Option.Option<A> = Option.none()
111
111
  const get = () => {
112
112
  if (Option.isSome(memoized)) {
@@ -121,7 +121,7 @@ export const syncOnce = <A>(f: () => A): Effect.Effect<never, never, A> => {
121
121
  return Effect.sync(get)
122
122
  }
123
123
 
124
- export const effectOnce = <R, E, A>(f: () => Effect.Effect<R, E, A>): Effect.Effect<R, E, A> => {
124
+ export const effectOnce = <A, E, R>(f: () => Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
125
125
  let memoized: Option.Option<A> = Option.none()
126
126
 
127
127
  return Effect.suspend(() => {
@@ -133,12 +133,12 @@ export const effectOnce = <R, E, A>(f: () => Effect.Effect<R, E, A>): Effect.Eff
133
133
  })
134
134
  }
135
135
 
136
- export function runEffect<A, R2, E2, B>(
136
+ export function runEffect<A, B, E2, R2>(
137
137
  producer: SyncProducer<A>,
138
- f: (a: A) => Effect.Effect<R2, E2, B>
139
- ): Effect.Effect<R2, E2, void> {
138
+ f: (a: A) => Effect.Effect<B, E2, R2>
139
+ ): Effect.Effect<void, E2, R2> {
140
140
  return matchSyncProducer(producer, {
141
- Success: (a): Effect.Effect<R2, E2, void> => f(a),
141
+ Success: (a): Effect.Effect<void, E2, R2> => f(a),
142
142
  FromSync: (a) => Effect.suspend(() => f(a())),
143
143
  FromArray: (a) => Effect.forEach(a, f, DISCARD),
144
144
  FromIterable: (a) => Effect.forEach(a, f, DISCARD)
@@ -9,28 +9,28 @@ import * as Sink from "../Sink.js"
9
9
  import { withSwitchFork } from "./helpers.js"
10
10
  import { FxBase } from "./protos.js"
11
11
 
12
- export function withKey<R, E, A, B extends PropertyKey, R2, E2, C>(
13
- fx: Fx<R, E, A>,
14
- options: WithKeyOptions<A, B, R2, E2, C>
15
- ): Fx<R | R2 | Scope.Scope, E | E2, C> {
12
+ export function withKey<A, E, R, B extends PropertyKey, C, E2, R2>(
13
+ fx: Fx<A, E, R>,
14
+ options: WithKeyOptions<A, B, C, E2, R2>
15
+ ): Fx<C, E | E2, R | R2 | Scope.Scope> {
16
16
  return new WithKey(fx, options)
17
17
  }
18
18
 
19
- class WithKey<R, E, A, B extends PropertyKey, R2, E2, C> extends FxBase<R | R2 | Scope.Scope, E | E2, C> {
20
- constructor(readonly fx: Fx<R, E, A>, readonly options: WithKeyOptions<A, B, R2, E2, C>) {
19
+ class WithKey<A, E, R, B extends PropertyKey, C, E2, R2> extends FxBase<C, E | E2, R | R2 | Scope.Scope> {
20
+ constructor(readonly fx: Fx<A, E, R>, readonly options: WithKeyOptions<A, B, C, E2, R2>) {
21
21
  super()
22
22
  }
23
23
 
24
- run<R3>(sink: Sink.Sink<R3, E | E2, C>) {
24
+ run<R3>(sink: Sink.Sink<C, E | E2, R3>) {
25
25
  return runWithKey(this.fx, this.options, sink)
26
26
  }
27
27
  }
28
28
 
29
- function runWithKey<R, E, A, B extends PropertyKey, R2, E2, C, R3>(
30
- fx: Fx<R, E, A>,
31
- options: WithKeyOptions<A, B, R2, E2, C>,
32
- sink: Sink.Sink<R3, E | E2, C>
33
- ) {
29
+ function runWithKey<A, E, R, B extends PropertyKey, C, E2, R2, R3>(
30
+ fx: Fx<A, E, R>,
31
+ options: WithKeyOptions<A, B, C, E2, R2>,
32
+ sink: Sink.Sink<C, E | E2, R3>
33
+ ): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
34
34
  return withSwitchFork((fork) => {
35
35
  let previous: Option.Option<WithKeyState<A, B>> = Option.none()
36
36
 
@@ -78,5 +78,5 @@ function runWithKey<R, E, A, B extends PropertyKey, R2, E2, C, R3>(
78
78
  type WithKeyState<A, B> = {
79
79
  value: A
80
80
  key: B
81
- ref: RefSubject.RefSubject<never, never, A>
81
+ ref: RefSubject.RefSubject<A>
82
82
  }