@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.
- package/dist/cjs/AsyncData.js.map +1 -1
- package/dist/cjs/Form.js.map +1 -1
- package/dist/cjs/FormEntry.js.map +1 -1
- package/dist/cjs/Fx.js +1 -1
- package/dist/cjs/Fx.js.map +1 -1
- package/dist/cjs/Idle.js.map +1 -1
- package/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/Pull.js +5 -3
- package/dist/cjs/Pull.js.map +1 -1
- package/dist/cjs/RefArray.js.map +1 -1
- package/dist/cjs/RefChunk.js.map +1 -1
- package/dist/cjs/RefHashSet.js.map +1 -1
- package/dist/cjs/RefSubject.js +3 -2
- package/dist/cjs/RefSubject.js.map +1 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Subject.js.map +1 -1
- package/dist/cjs/Versioned.js.map +1 -1
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/helpers.js.map +1 -1
- package/dist/cjs/internal/keyed.js +1 -1
- package/dist/cjs/internal/keyed.js.map +1 -1
- package/dist/cjs/internal/provide.js.map +1 -1
- package/dist/cjs/internal/share.js.map +1 -1
- package/dist/cjs/internal/sync-producer.js.map +1 -1
- package/dist/dts/AsyncData.d.ts +53 -53
- package/dist/dts/AsyncData.d.ts.map +1 -1
- package/dist/dts/Emitter.d.ts +7 -7
- package/dist/dts/Emitter.d.ts.map +1 -1
- package/dist/dts/Form.d.ts +14 -14
- package/dist/dts/Form.d.ts.map +1 -1
- package/dist/dts/FormEntry.d.ts +11 -11
- package/dist/dts/FormEntry.d.ts.map +1 -1
- package/dist/dts/Fx.d.ts +417 -417
- package/dist/dts/Fx.d.ts.map +1 -1
- package/dist/dts/Guard.d.ts +21 -21
- package/dist/dts/Guard.d.ts.map +1 -1
- package/dist/dts/Idle.d.ts +12 -12
- package/dist/dts/Idle.d.ts.map +1 -1
- package/dist/dts/Match.d.ts +16 -16
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Pull.d.ts +5 -5
- package/dist/dts/Pull.d.ts.map +1 -1
- package/dist/dts/Push.d.ts +40 -40
- package/dist/dts/Push.d.ts.map +1 -1
- package/dist/dts/RefArray.d.ts +59 -59
- package/dist/dts/RefArray.d.ts.map +1 -1
- package/dist/dts/RefChunk.d.ts +45 -45
- package/dist/dts/RefChunk.d.ts.map +1 -1
- package/dist/dts/RefHashMap.d.ts +35 -35
- package/dist/dts/RefHashMap.d.ts.map +1 -1
- package/dist/dts/RefHashSet.d.ts +17 -17
- package/dist/dts/RefHashSet.d.ts.map +1 -1
- package/dist/dts/RefSubject.d.ts +136 -136
- package/dist/dts/RefSubject.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +63 -63
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +11 -11
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Subject.d.ts +13 -13
- package/dist/dts/Subject.d.ts.map +1 -1
- package/dist/dts/Typeclass.d.ts +1 -1
- package/dist/dts/Typeclass.d.ts.map +1 -1
- package/dist/dts/Versioned.d.ts +33 -33
- package/dist/dts/Versioned.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/internal/DeferredRef.d.ts +8 -8
- package/dist/dts/internal/DeferredRef.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts +191 -191
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/effect-loop-operator.d.ts +6 -6
- package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-operator.d.ts +16 -16
- package/dist/dts/internal/effect-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-producer.d.ts +13 -13
- package/dist/dts/internal/effect-producer.d.ts.map +1 -1
- package/dist/dts/internal/helpers.d.ts +26 -26
- package/dist/dts/internal/helpers.d.ts.map +1 -1
- package/dist/dts/internal/keyed.d.ts +1 -1
- package/dist/dts/internal/keyed.d.ts.map +1 -1
- package/dist/dts/internal/loop-operator.d.ts +2 -2
- package/dist/dts/internal/loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/operator.d.ts +2 -2
- package/dist/dts/internal/operator.d.ts.map +1 -1
- package/dist/dts/internal/protos.d.ts +12 -12
- package/dist/dts/internal/protos.d.ts.map +1 -1
- package/dist/dts/internal/provide.d.ts +15 -15
- package/dist/dts/internal/provide.d.ts.map +1 -1
- package/dist/dts/internal/share.d.ts +11 -11
- package/dist/dts/internal/share.d.ts.map +1 -1
- package/dist/dts/internal/sync-operator.d.ts +2 -2
- package/dist/dts/internal/sync-operator.d.ts.map +1 -1
- package/dist/dts/internal/sync-producer.d.ts +6 -6
- package/dist/dts/internal/sync-producer.d.ts.map +1 -1
- package/dist/dts/internal/withKey.d.ts +1 -1
- package/dist/dts/internal/withKey.d.ts.map +1 -1
- package/dist/esm/AsyncData.js.map +1 -1
- package/dist/esm/Form.js.map +1 -1
- package/dist/esm/FormEntry.js.map +1 -1
- package/dist/esm/Fx.js +1 -1
- package/dist/esm/Fx.js.map +1 -1
- package/dist/esm/Idle.js.map +1 -1
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Pull.js +3 -3
- package/dist/esm/Pull.js.map +1 -1
- package/dist/esm/RefArray.js.map +1 -1
- package/dist/esm/RefChunk.js.map +1 -1
- package/dist/esm/RefHashSet.js.map +1 -1
- package/dist/esm/RefSubject.js +3 -1
- package/dist/esm/RefSubject.js.map +1 -1
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Subject.js.map +1 -1
- package/dist/esm/Versioned.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/helpers.js.map +1 -1
- package/dist/esm/internal/keyed.js +1 -1
- package/dist/esm/internal/keyed.js.map +1 -1
- package/dist/esm/internal/provide.js.map +1 -1
- package/dist/esm/internal/share.js.map +1 -1
- package/dist/esm/internal/sync-producer.js.map +1 -1
- package/package.json +6 -6
- package/src/AsyncData.ts +142 -144
- package/src/Emitter.ts +13 -13
- package/src/Form.ts +55 -55
- package/src/FormEntry.ts +39 -39
- package/src/Fx.ts +788 -789
- package/src/Guard.ts +43 -43
- package/src/Idle.ts +26 -26
- package/src/Match.ts +60 -61
- package/src/Pull.ts +42 -43
- package/src/Push.ts +195 -195
- package/src/RefArray.ts +121 -119
- package/src/RefChunk.ts +98 -97
- package/src/RefHashMap.ts +79 -79
- package/src/RefHashSet.ts +40 -39
- package/src/RefSubject.ts +574 -565
- package/src/Sink.ts +303 -303
- package/src/Stream.ts +27 -27
- package/src/Subject.ts +48 -46
- package/src/Typeclass.ts +2 -2
- package/src/Versioned.ts +97 -97
- package/src/index.ts +1 -1
- package/src/internal/DeferredRef.ts +7 -7
- package/src/internal/core.ts +768 -781
- package/src/internal/effect-loop-operator.ts +7 -7
- package/src/internal/effect-operator.ts +23 -23
- package/src/internal/effect-producer.ts +38 -38
- package/src/internal/helpers.ts +51 -51
- package/src/internal/keyed.ts +21 -21
- package/src/internal/loop-operator.ts +2 -2
- package/src/internal/operator.ts +2 -2
- package/src/internal/protos.ts +15 -15
- package/src/internal/provide.ts +27 -27
- package/src/internal/share.ts +25 -25
- package/src/internal/sync-operator.ts +4 -4
- package/src/internal/sync-producer.ts +15 -15
- package/src/internal/withKey.ts +13 -13
package/src/internal/core.ts
CHANGED
|
@@ -63,56 +63,55 @@ const UNBOUNDED = { concurrency: "unbounded" } as const
|
|
|
63
63
|
// TODO: expose FxBase and FxEffectBase
|
|
64
64
|
|
|
65
65
|
export function make<A>(
|
|
66
|
-
run: (sink: Sink.Sink<
|
|
67
|
-
): Fx<
|
|
68
|
-
export function make<
|
|
69
|
-
export function make<
|
|
70
|
-
export function make<
|
|
66
|
+
run: (sink: Sink.Sink<A>) => Effect.Effect<unknown>
|
|
67
|
+
): Fx<A>
|
|
68
|
+
export function make<A, E>(run: (sink: Sink.Sink<A, E>) => Effect.Effect<unknown>): Fx<A, E>
|
|
69
|
+
export function make<A, E, R>(run: (sink: Sink.Sink<A, E>) => Effect.Effect<unknown, never, R>): Fx<A, E, R>
|
|
70
|
+
export function make<A, E, R>(run: (sink: Sink.Sink<A, E>) => Effect.Effect<unknown, never, R>): Fx<A, E, R> {
|
|
71
71
|
return new Make(run)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
class Make<
|
|
75
|
-
constructor(readonly _run: Fx<
|
|
74
|
+
class Make<A, E, R> extends FxBase<A, E, R> {
|
|
75
|
+
constructor(readonly _run: Fx<A, E, R>["run"]) {
|
|
76
76
|
super()
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
run<R2>(sink: Sink.Sink<
|
|
79
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
80
80
|
return Effect.contextWithEffect((ctx) => this._run(Sink.provide(sink, ctx)))
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
class Producer<A> extends FxBase<
|
|
84
|
+
class Producer<A> extends FxBase<A, never, never> {
|
|
85
85
|
constructor(readonly i0: SyncProducer.SyncProducer<A>) {
|
|
86
86
|
super()
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
run<R2>(sink: Sink.Sink<
|
|
89
|
+
run<R2>(sink: Sink.Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
|
|
90
90
|
return SyncProducer.runSink(this.i0, sink)
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* @internal
|
|
95
95
|
*/
|
|
96
|
-
export function isProducer<
|
|
96
|
+
export function isProducer<A, E, R>(fx: Fx<A, E, R>): fx is Producer<A> {
|
|
97
97
|
return fx.constructor === Producer
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export const succeed = <A>(value: A): Fx<
|
|
100
|
+
export const succeed = <A>(value: A): Fx<A> => new Producer(SyncProducer.Success(value))
|
|
101
101
|
|
|
102
|
-
export const fromSync = <A>(f: () => A): Fx<
|
|
102
|
+
export const fromSync = <A>(f: () => A): Fx<A> => new Producer(SyncProducer.FromSync(f))
|
|
103
103
|
|
|
104
|
-
export const fromArray = <const A extends ReadonlyArray<any>>(array: A): Fx<
|
|
104
|
+
export const fromArray = <const A extends ReadonlyArray<any>>(array: A): Fx<A[number]> =>
|
|
105
105
|
new Producer(SyncProducer.FromArray(array))
|
|
106
106
|
|
|
107
|
-
export const fromIterable = <A>(iterable: Iterable<A>): Fx<
|
|
108
|
-
new Producer(SyncProducer.FromIterable(iterable))
|
|
107
|
+
export const fromIterable = <A>(iterable: Iterable<A>): Fx<A> => new Producer(SyncProducer.FromIterable(iterable))
|
|
109
108
|
|
|
110
|
-
class ProducerEffect<
|
|
111
|
-
constructor(readonly i0: EffectProducer.EffectProducer<
|
|
109
|
+
class ProducerEffect<A, E, R> extends FxBase<A, E, R> {
|
|
110
|
+
constructor(readonly i0: EffectProducer.EffectProducer<A, E, R>) {
|
|
112
111
|
super()
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
run<R2>(sink: Sink.Sink<
|
|
114
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
116
115
|
return EffectProducer.runSink(this.i0, sink)
|
|
117
116
|
}
|
|
118
117
|
}
|
|
@@ -120,12 +119,12 @@ class ProducerEffect<R, E, A> extends FxBase<R, E, A> {
|
|
|
120
119
|
/**
|
|
121
120
|
* @internal
|
|
122
121
|
*/
|
|
123
|
-
export function isProducerEffect<
|
|
122
|
+
export function isProducerEffect<A, E, R>(fx: Fx<A, E, R>): fx is ProducerEffect<A, E, R> {
|
|
124
123
|
return fx.constructor === ProducerEffect
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
export const fromEffect = <
|
|
128
|
-
matchEffectPrimitive<
|
|
126
|
+
export const fromEffect = <A, E, R>(effect: Effect.Effect<A, E, R>): Fx<A, E, R> =>
|
|
127
|
+
matchEffectPrimitive<A, E, R, Fx<A, E, R>>(effect, {
|
|
129
128
|
// Match over Effect primitives and return Fx primitives to allow fusion to take place
|
|
130
129
|
Success: succeed,
|
|
131
130
|
Failure: failCause,
|
|
@@ -138,21 +137,21 @@ export const fromEffect = <R, E, A>(effect: Effect.Effect<R, E, A>): Fx<R, E, A>
|
|
|
138
137
|
})
|
|
139
138
|
|
|
140
139
|
export const fromScheduled = <R, E, I, R2, O>(
|
|
141
|
-
input: Effect.Effect<
|
|
140
|
+
input: Effect.Effect<I, E, R>,
|
|
142
141
|
schedule: Schedule.Schedule<R2, I, O>
|
|
143
|
-
): Fx<R | R2
|
|
142
|
+
): Fx<O, E, R | R2> => new ProducerEffect(EffectProducer.FromScheduled(input, schedule))
|
|
144
143
|
|
|
145
|
-
export const schedule = <
|
|
146
|
-
input: Effect.Effect<
|
|
144
|
+
export const schedule = <A, E, R, R2, O>(
|
|
145
|
+
input: Effect.Effect<A, E, R>,
|
|
147
146
|
schedule: Schedule.Schedule<R2, unknown, O>
|
|
148
|
-
): Fx<R | R2
|
|
147
|
+
): Fx<A, E, R | R2> => new ProducerEffect(EffectProducer.Scheduled(input, schedule))
|
|
149
148
|
|
|
150
149
|
class FailCause<E> extends FxBase<never, E, never> {
|
|
151
150
|
constructor(readonly i0: Cause.Cause<E>) {
|
|
152
151
|
super()
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
run<R2>(sink: Sink.Sink<
|
|
154
|
+
run<R2>(sink: Sink.Sink<never, E, R2>): Effect.Effect<unknown, never, R2> {
|
|
156
155
|
return sink.onFailure(this.i0)
|
|
157
156
|
}
|
|
158
157
|
}
|
|
@@ -160,26 +159,26 @@ class FailCause<E> extends FxBase<never, E, never> {
|
|
|
160
159
|
/**
|
|
161
160
|
* @internal
|
|
162
161
|
*/
|
|
163
|
-
export function isFailCause<
|
|
162
|
+
export function isFailCause<A, E, R>(fx: Fx<A, E, R>): fx is FailCause<E> {
|
|
164
163
|
return fx.constructor === FailCause
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
export const failCause = <E>(cause: Cause.Cause<E>): Fx<never, E
|
|
166
|
+
export const failCause = <E>(cause: Cause.Cause<E>): Fx<never, E> => new FailCause(cause)
|
|
168
167
|
|
|
169
|
-
export const fail = <E>(error: E): Fx<never, E
|
|
168
|
+
export const fail = <E>(error: E): Fx<never, E> => failCause(Cause.fail(error))
|
|
170
169
|
|
|
171
|
-
export const die = (error: unknown): Fx<never
|
|
170
|
+
export const die = (error: unknown): Fx<never> => failCause(Cause.die(error))
|
|
172
171
|
|
|
173
|
-
class Transformer<
|
|
174
|
-
constructor(readonly i0: Fx<
|
|
172
|
+
class Transformer<A, E, R> extends FxBase<A, E, R> {
|
|
173
|
+
constructor(readonly i0: Fx<any, E, R>, readonly i1: Op.Operator) {
|
|
175
174
|
super()
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
run<R2>(sink: Sink.Sink<
|
|
177
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
179
178
|
return this.i0.run(Op.compileOperatorSink(this.i1, sink))
|
|
180
179
|
}
|
|
181
180
|
|
|
182
|
-
static make<
|
|
181
|
+
static make<A, E, R, B, E2, R2>(fx: Fx<A, E, R>, operator: Op.Operator): Fx<B, E | E2, R | R2> {
|
|
183
182
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
184
183
|
else if (isProducer(fx)) {
|
|
185
184
|
return new ProducerSyncTransformer(fx.i0, operator)
|
|
@@ -198,7 +197,7 @@ class Transformer<R, E, A> extends FxBase<R, E, A> {
|
|
|
198
197
|
} else if (isFailCause(fx)) {
|
|
199
198
|
return fx
|
|
200
199
|
} else {
|
|
201
|
-
return new Transformer<
|
|
200
|
+
return new Transformer<B, E, R>(fx, operator)
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
203
|
}
|
|
@@ -206,16 +205,16 @@ class Transformer<R, E, A> extends FxBase<R, E, A> {
|
|
|
206
205
|
/**
|
|
207
206
|
* @internal
|
|
208
207
|
*/
|
|
209
|
-
export function isTransformer<
|
|
208
|
+
export function isTransformer<A, E, R>(fx: Fx<A, E, R>): fx is Transformer<A, E, R> {
|
|
210
209
|
return fx.constructor === Transformer
|
|
211
210
|
}
|
|
212
211
|
|
|
213
|
-
class ProducerSyncTransformer<
|
|
212
|
+
class ProducerSyncTransformer<A, E, R> extends FxBase<A, E, R> implements Fx<A, E, R> {
|
|
214
213
|
constructor(readonly i0: SyncProducer.SyncProducer<any>, readonly i1: Op.Operator) {
|
|
215
214
|
super()
|
|
216
215
|
}
|
|
217
216
|
|
|
218
|
-
run<R2>(sink: Sink.Sink<
|
|
217
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
219
218
|
return SyncProducer.runSink(this.i0, Op.compileOperatorSink(this.i1, sink))
|
|
220
219
|
}
|
|
221
220
|
}
|
|
@@ -223,80 +222,80 @@ class ProducerSyncTransformer<R, E, A> extends FxBase<R, E, A> implements Fx<R,
|
|
|
223
222
|
/**
|
|
224
223
|
* @internal
|
|
225
224
|
*/
|
|
226
|
-
export function isProducerSyncTransformer<
|
|
225
|
+
export function isProducerSyncTransformer<A, E, R>(fx: Fx<A, E, R>): fx is ProducerSyncTransformer<A, E, R> {
|
|
227
226
|
return fx.constructor === ProducerSyncTransformer
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
export const map = <
|
|
229
|
+
export const map = <A, E, R, B>(fx: Fx<A, E, R>, f: (a: A) => B): Fx<B, E, R> => Transformer.make(fx, SyncOp.Map(f))
|
|
231
230
|
|
|
232
|
-
export const filter = <
|
|
231
|
+
export const filter = <A, E, R>(fx: Fx<A, E, R>, f: Predicate.Predicate<A>): Fx<A, E, R> =>
|
|
233
232
|
Transformer.make(fx, SyncOp.Filter(f))
|
|
234
233
|
|
|
235
|
-
export const filterMap = <
|
|
234
|
+
export const filterMap = <A, E, R, B>(fx: Fx<A, E, R>, f: (a: A) => Option.Option<B>): Fx<B, E, R> =>
|
|
236
235
|
Transformer.make(fx, SyncOp.FilterMap(f))
|
|
237
236
|
|
|
238
|
-
export const mapEffect = <
|
|
239
|
-
fx: Fx<
|
|
240
|
-
f: (a: A) => Effect.Effect<
|
|
241
|
-
): Fx<
|
|
237
|
+
export const mapEffect = <A, E, R, B, E2, R2>(
|
|
238
|
+
fx: Fx<A, E, R>,
|
|
239
|
+
f: (a: A) => Effect.Effect<B, E2, R2>
|
|
240
|
+
): Fx<B, E | E2, R | R2> => Transformer.make(fx, EffectOp.MapEffect(f))
|
|
242
241
|
|
|
243
|
-
export const filterMapEffect = <
|
|
244
|
-
fx: Fx<
|
|
245
|
-
f: (a: A) => Effect.Effect<
|
|
246
|
-
): Fx<
|
|
242
|
+
export const filterMapEffect = <A, E, R, B, E2, R2>(
|
|
243
|
+
fx: Fx<A, E, R>,
|
|
244
|
+
f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>
|
|
245
|
+
): Fx<B, E | E2, R | R2> => Transformer.make(fx, EffectOp.FilterMapEffect(f))
|
|
247
246
|
|
|
248
|
-
export const filterEffect = <
|
|
249
|
-
fx: Fx<
|
|
250
|
-
f: (a: A) => Effect.Effect<
|
|
251
|
-
): Fx<
|
|
247
|
+
export const filterEffect = <A, E, R, R2, E2>(
|
|
248
|
+
fx: Fx<A, E, R>,
|
|
249
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
250
|
+
): Fx<A, E | E2, R | R2> => Transformer.make(fx, EffectOp.FilterEffect(f))
|
|
252
251
|
|
|
253
|
-
export const tapEffect = <
|
|
254
|
-
fx: Fx<
|
|
255
|
-
f: (a: A) => Effect.Effect<
|
|
256
|
-
): Fx<
|
|
252
|
+
export const tapEffect = <A, E, R, R2, E2>(
|
|
253
|
+
fx: Fx<A, E, R>,
|
|
254
|
+
f: (a: A) => Effect.Effect<unknown, E2, R2>
|
|
255
|
+
): Fx<A, E | E2, R | R2> => Transformer.make(fx, EffectOp.TapEffect(f))
|
|
257
256
|
|
|
258
|
-
export const loop = <
|
|
257
|
+
export const loop = <A, E, R, B, C>(fx: Fx<A, E, R>, seed: B, f: (acc: B, a: A) => readonly [C, B]): Fx<C, E, R> =>
|
|
259
258
|
Transformer.make(fx, SyncLoopOp.LoopOperator(seed, f))
|
|
260
259
|
|
|
261
|
-
export const withPrevious = <
|
|
260
|
+
export const withPrevious = <A, E, R>(fx: Fx<A, E, R>): Fx<readonly [Option.Option<A>, A], E, R> =>
|
|
262
261
|
loop(fx, Option.none<A>(), (acc, a) => [[acc, a], Option.some(a)] as const)
|
|
263
262
|
|
|
264
|
-
export const filterMapLoop = <
|
|
265
|
-
fx: Fx<
|
|
263
|
+
export const filterMapLoop = <A, E, R, B, C>(
|
|
264
|
+
fx: Fx<A, E, R>,
|
|
266
265
|
seed: B,
|
|
267
266
|
f: (acc: B, a: A) => readonly [Option.Option<C>, B]
|
|
268
|
-
): Fx<
|
|
267
|
+
): Fx<C, E, R> => Transformer.make(fx, SyncLoopOp.FilterMapLoopOperator(seed, f))
|
|
269
268
|
|
|
270
|
-
export const loopEffect = <
|
|
271
|
-
fx: Fx<
|
|
269
|
+
export const loopEffect = <A, E, R, B, E2, R2, C>(
|
|
270
|
+
fx: Fx<A, E, R>,
|
|
272
271
|
seed: B,
|
|
273
|
-
f: (acc: B, a: A) => Effect.Effect<
|
|
274
|
-
): Fx<
|
|
272
|
+
f: (acc: B, a: A) => Effect.Effect<readonly [C, B], E2, R2>
|
|
273
|
+
): Fx<C, E | E2, R | R2> => Transformer.make(fx, EffectLoopOp.LoopEffectOperator(seed, f))
|
|
275
274
|
|
|
276
|
-
export const filterMapLoopEffect = <
|
|
277
|
-
fx: Fx<
|
|
275
|
+
export const filterMapLoopEffect = <A, E, R, B, E2, R2, C>(
|
|
276
|
+
fx: Fx<A, E, R>,
|
|
278
277
|
seed: B,
|
|
279
|
-
f: (acc: B, a: A) => Effect.Effect<
|
|
280
|
-
): Fx<
|
|
278
|
+
f: (acc: B, a: A) => Effect.Effect<readonly [Option.Option<C>, B], E2, R2>
|
|
279
|
+
): Fx<C, E | E2, R | R2> => Transformer.make(fx, EffectLoopOp.FilterMapLoopEffectOperator(seed, f))
|
|
281
280
|
|
|
282
|
-
export const observe = <
|
|
283
|
-
fx: Fx<
|
|
284
|
-
f: (a: A) => Effect.Effect<
|
|
285
|
-
): Effect.Effect<
|
|
281
|
+
export const observe = <A, E, R, B, E2, R2>(
|
|
282
|
+
fx: Fx<A, E, R>,
|
|
283
|
+
f: (a: A) => Effect.Effect<B, E2, R2>
|
|
284
|
+
): Effect.Effect<void, E | E2, R | R2> => Observe.make(fx, f)
|
|
286
285
|
|
|
287
286
|
const constUnit = () => Effect.unit
|
|
288
287
|
|
|
289
|
-
export const drain = <
|
|
288
|
+
export const drain = <A, E, R>(fx: Fx<A, E, R>): Effect.Effect<void, E, R> => Observe.make(fx, constUnit)
|
|
290
289
|
|
|
291
|
-
class Observe<
|
|
290
|
+
class Observe<A, E, R, B, E2, R2> extends EffectBase<void, E | E2, R | R2> {
|
|
292
291
|
constructor(
|
|
293
|
-
readonly i0: Fx<
|
|
294
|
-
readonly i1: (a: A) => Effect.Effect<
|
|
292
|
+
readonly i0: Fx<A, E, R>,
|
|
293
|
+
readonly i1: (a: A) => Effect.Effect<B, E2, R2>
|
|
295
294
|
) {
|
|
296
295
|
super()
|
|
297
296
|
}
|
|
298
297
|
|
|
299
|
-
toEffect(): Effect.Effect<
|
|
298
|
+
toEffect(): Effect.Effect<void, E | E2, R | R2> {
|
|
300
299
|
return Effect.asyncEffect((resume) => {
|
|
301
300
|
const { i0: fx, i1: f } = this
|
|
302
301
|
const onFailure = (cause: Cause.Cause<E | E2>) => Effect.sync(() => resume(Effect.failCause(cause)))
|
|
@@ -308,10 +307,10 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
308
307
|
})
|
|
309
308
|
}
|
|
310
309
|
|
|
311
|
-
static make<
|
|
312
|
-
fx: Fx<
|
|
313
|
-
f: (a: A) => Effect.Effect<
|
|
314
|
-
): Effect.Effect<
|
|
310
|
+
static make<A, E, R, B, E2, R2>(
|
|
311
|
+
fx: Fx<A, E, R>,
|
|
312
|
+
f: (a: A) => Effect.Effect<B, E2, R2>
|
|
313
|
+
): Effect.Effect<void, E | E2, R | R2> {
|
|
315
314
|
if (isEmpty(fx)) {
|
|
316
315
|
return Effect.unit
|
|
317
316
|
} else if (isNever(fx)) {
|
|
@@ -320,9 +319,9 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
320
319
|
return SyncProducer.runEffect(fx.i0, f)
|
|
321
320
|
} else if (isProducerSyncTransformer(fx)) {
|
|
322
321
|
return Op.matchOperator(fx.i1, {
|
|
323
|
-
SyncOperator: (op): Effect.Effect<
|
|
322
|
+
SyncOperator: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
324
323
|
SyncOp.matchSyncOperator(op, {
|
|
325
|
-
Map: (op): Effect.Effect<
|
|
324
|
+
Map: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
326
325
|
SyncProducer.effectOnce(() => SyncProducer.runEffect(fx.i0, (a) => f(op.f(a)))),
|
|
327
326
|
Filter: (op) =>
|
|
328
327
|
SyncProducer.effectOnce(() =>
|
|
@@ -338,7 +337,7 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
338
337
|
}),
|
|
339
338
|
EffectOperator: (op) =>
|
|
340
339
|
EffectOp.matchEffectOperator(op, {
|
|
341
|
-
MapEffect: (op): Effect.Effect<
|
|
340
|
+
MapEffect: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
342
341
|
SyncProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), f)),
|
|
343
342
|
FilterMapEffect: (op) =>
|
|
344
343
|
SyncProducer.runEffect(fx.i0, (a) =>
|
|
@@ -394,9 +393,9 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
394
393
|
return EffectProducer.runEffect(fx.i0, f)
|
|
395
394
|
} else if (isProducerEffectTransformer(fx)) {
|
|
396
395
|
return Op.matchOperator(fx.i1, {
|
|
397
|
-
SyncOperator: (op): Effect.Effect<
|
|
396
|
+
SyncOperator: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
398
397
|
SyncOp.matchSyncOperator(op, {
|
|
399
|
-
Map: (op): Effect.Effect<
|
|
398
|
+
Map: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
400
399
|
SyncProducer.effectOnce(() => EffectProducer.runEffect(fx.i0, (a) => f(op.f(a)))),
|
|
401
400
|
Filter: (op) =>
|
|
402
401
|
SyncProducer.effectOnce(() =>
|
|
@@ -412,7 +411,7 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
412
411
|
}),
|
|
413
412
|
EffectOperator: (op) =>
|
|
414
413
|
EffectOp.matchEffectOperator(op, {
|
|
415
|
-
MapEffect: (op): Effect.Effect<
|
|
414
|
+
MapEffect: (op): Effect.Effect<void, E | E2, R | R2> =>
|
|
416
415
|
EffectProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), f)),
|
|
417
416
|
FilterMapEffect: (op) =>
|
|
418
417
|
EffectProducer.runEffect(fx.i0, (a) =>
|
|
@@ -472,15 +471,15 @@ class Observe<R, E, A, R2, E2, B> extends EffectBase<R | R2, E | E2, void> {
|
|
|
472
471
|
}
|
|
473
472
|
}
|
|
474
473
|
|
|
475
|
-
export const reduce = <
|
|
474
|
+
export const reduce = <A, E, R, B>(fx: Fx<A, E, R>, seed: B, f: (acc: B, a: A) => B): Effect.Effect<B, E, R> =>
|
|
476
475
|
Reduce.make(fx, seed, f)
|
|
477
476
|
|
|
478
|
-
class Reduce<
|
|
479
|
-
constructor(readonly i0: Fx<
|
|
477
|
+
class Reduce<A, E, R, B> extends EffectBase<B, E, R> {
|
|
478
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: B, readonly i2: (acc: B, a: A) => B) {
|
|
480
479
|
super()
|
|
481
480
|
}
|
|
482
481
|
|
|
483
|
-
toEffect(): Effect.Effect<
|
|
482
|
+
toEffect(): Effect.Effect<B, E, R> {
|
|
484
483
|
return Effect.suspend(() => {
|
|
485
484
|
let acc = this.i1
|
|
486
485
|
|
|
@@ -491,7 +490,7 @@ class Reduce<R, E, A, B> extends EffectBase<R, E, B> {
|
|
|
491
490
|
})
|
|
492
491
|
}
|
|
493
492
|
|
|
494
|
-
static make<
|
|
493
|
+
static make<A, E, R, B>(fx: Fx<A, E, R>, seed: B, f: (acc: B, a: A) => B) {
|
|
495
494
|
// TODO: optimize Effect trasformers
|
|
496
495
|
|
|
497
496
|
if (isEmpty(fx)) return Effect.succeed(seed)
|
|
@@ -557,7 +556,7 @@ class Reduce<R, E, A, B> extends EffectBase<R, E, B> {
|
|
|
557
556
|
}
|
|
558
557
|
}
|
|
559
558
|
|
|
560
|
-
export const toReadonlyArray = <
|
|
559
|
+
export const toReadonlyArray = <A, E, R>(fx: Fx<A, E, R>): Effect.Effect<ReadonlyArray<A>, E, R> =>
|
|
561
560
|
Effect.suspend(() => {
|
|
562
561
|
const init = [] as Array<A>
|
|
563
562
|
return Reduce.make(fx, init, (acc, a) => {
|
|
@@ -566,23 +565,23 @@ export const toReadonlyArray = <R, E, A>(fx: Fx<R, E, A>): Effect.Effect<R, E, R
|
|
|
566
565
|
})
|
|
567
566
|
})
|
|
568
567
|
|
|
569
|
-
export const slice = <
|
|
568
|
+
export const slice = <A, E, R>(fx: Fx<A, E, R>, drop: number, take: number): Fx<A, E, R> =>
|
|
570
569
|
Slice.make(fx, boundsFrom(drop, take))
|
|
571
570
|
|
|
572
|
-
export const take = <
|
|
571
|
+
export const take = <A, E, R>(fx: Fx<A, E, R>, n: number): Fx<A, E, R> => slice(fx, 0, n)
|
|
573
572
|
|
|
574
|
-
export const drop = <
|
|
573
|
+
export const drop = <A, E, R>(fx: Fx<A, E, R>, n: number): Fx<A, E, R> => slice(fx, n, Infinity)
|
|
575
574
|
|
|
576
|
-
class Slice<
|
|
577
|
-
constructor(readonly i0: Fx<
|
|
575
|
+
class Slice<A, E, R> extends FxBase<A, E, R> {
|
|
576
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Bounds) {
|
|
578
577
|
super()
|
|
579
578
|
}
|
|
580
579
|
|
|
581
|
-
run<R2>(sink: Sink.Sink<
|
|
580
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
582
581
|
return Sink.slice(sink, this.i1, (s) => this.i0.run(s))
|
|
583
582
|
}
|
|
584
583
|
|
|
585
|
-
static make<
|
|
584
|
+
static make<A, E, R>(fx: Fx<A, E, R>, bounds: Bounds): Fx<A, E, R> {
|
|
586
585
|
if (isNilBounds(bounds)) return empty
|
|
587
586
|
if (isInfiniteBounds(bounds)) return fx
|
|
588
587
|
|
|
@@ -600,14 +599,14 @@ class Slice<R, E, A> extends FxBase<R, E, A> {
|
|
|
600
599
|
/**
|
|
601
600
|
* @internal
|
|
602
601
|
*/
|
|
603
|
-
export function isSlice<
|
|
602
|
+
export function isSlice<A, E, R>(fx: Fx<A, E, R>): fx is Slice<A, E, R> {
|
|
604
603
|
return fx.constructor === Slice
|
|
605
604
|
}
|
|
606
605
|
|
|
607
|
-
export function skipRepeatsWith<
|
|
608
|
-
fx: Fx<
|
|
606
|
+
export function skipRepeatsWith<A, E, R>(
|
|
607
|
+
fx: Fx<A, E, R>,
|
|
609
608
|
eq: Equivalence.Equivalence<A>
|
|
610
|
-
): Fx<
|
|
609
|
+
): Fx<A, E, R> {
|
|
611
610
|
return filterMapLoop(fx, Option.none<A>(), (previous, a) => {
|
|
612
611
|
if (Option.isSome(previous) && eq(a, previous.value)) {
|
|
613
612
|
return [Option.none<A>(), Option.some<A>(a)] as const
|
|
@@ -617,18 +616,18 @@ export function skipRepeatsWith<R, E, A>(
|
|
|
617
616
|
})
|
|
618
617
|
}
|
|
619
618
|
|
|
620
|
-
export function skipRepeats<
|
|
621
|
-
fx: Fx<
|
|
622
|
-
): Fx<
|
|
619
|
+
export function skipRepeats<A, E, R>(
|
|
620
|
+
fx: Fx<A, E, R>
|
|
621
|
+
): Fx<A, E, R> {
|
|
623
622
|
return skipRepeatsWith(fx, Equal.equals)
|
|
624
623
|
}
|
|
625
624
|
|
|
626
|
-
class ProducerEffectTransformer<
|
|
627
|
-
constructor(readonly i0: EffectProducer.EffectProducer<
|
|
625
|
+
class ProducerEffectTransformer<A, E, R, B, E2, R2> extends FxBase<B, E | E2, R | R2> {
|
|
626
|
+
constructor(readonly i0: EffectProducer.EffectProducer<A, E, R>, readonly i1: Op.Operator) {
|
|
628
627
|
super()
|
|
629
628
|
}
|
|
630
629
|
|
|
631
|
-
run<R3>(sink: Sink.Sink<
|
|
630
|
+
run<R3>(sink: Sink.Sink<B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
632
631
|
return EffectProducer.runSink(this.i0, Op.compileOperatorSink(this.i1, sink))
|
|
633
632
|
}
|
|
634
633
|
}
|
|
@@ -636,14 +635,14 @@ class ProducerEffectTransformer<R, E, A, R2, E2, B> extends FxBase<R | R2, E | E
|
|
|
636
635
|
/**
|
|
637
636
|
* @internal
|
|
638
637
|
*/
|
|
639
|
-
export function isProducerEffectTransformer<
|
|
640
|
-
fx: Fx<
|
|
641
|
-
): fx is ProducerEffectTransformer<
|
|
638
|
+
export function isProducerEffectTransformer<A, E, R>(
|
|
639
|
+
fx: Fx<A, E, R>
|
|
640
|
+
): fx is ProducerEffectTransformer<A, E, R, A, E, R> {
|
|
642
641
|
return fx.constructor === ProducerEffectTransformer
|
|
643
642
|
}
|
|
644
643
|
|
|
645
644
|
class Empty extends FxBase<never, never, never> {
|
|
646
|
-
run<R2>(): Effect.Effect<
|
|
645
|
+
run<R2>(): Effect.Effect<unknown, never, R2> {
|
|
647
646
|
return Effect.unit
|
|
648
647
|
}
|
|
649
648
|
}
|
|
@@ -651,14 +650,14 @@ class Empty extends FxBase<never, never, never> {
|
|
|
651
650
|
/**
|
|
652
651
|
* @internal
|
|
653
652
|
*/
|
|
654
|
-
export function isEmpty<
|
|
653
|
+
export function isEmpty<A, E, R>(fx: Fx<A, E, R>): fx is Empty {
|
|
655
654
|
return fx.constructor === Empty
|
|
656
655
|
}
|
|
657
656
|
|
|
658
|
-
export const empty: Fx<never
|
|
657
|
+
export const empty: Fx<never> = new Empty()
|
|
659
658
|
|
|
660
659
|
class Never extends FxBase<never, never, never> {
|
|
661
|
-
run<R2>(): Effect.Effect<
|
|
660
|
+
run<R2>(): Effect.Effect<unknown, never, R2> {
|
|
662
661
|
return Effect.never
|
|
663
662
|
}
|
|
664
663
|
}
|
|
@@ -666,43 +665,43 @@ class Never extends FxBase<never, never, never> {
|
|
|
666
665
|
/**
|
|
667
666
|
* @internal
|
|
668
667
|
*/
|
|
669
|
-
export function isNever<
|
|
668
|
+
export function isNever<A, E, R>(fx: Fx<A, E, R>): fx is Never {
|
|
670
669
|
return fx.constructor === Never
|
|
671
670
|
}
|
|
672
671
|
|
|
673
|
-
export const never: Fx<never
|
|
672
|
+
export const never: Fx<never> = new Never()
|
|
674
673
|
|
|
675
|
-
export function padWith<
|
|
676
|
-
fx: Fx<
|
|
674
|
+
export function padWith<A, E, R, B, C>(
|
|
675
|
+
fx: Fx<A, E, R>,
|
|
677
676
|
start: Iterable<B>,
|
|
678
677
|
end: Iterable<C>
|
|
679
|
-
): Fx<
|
|
678
|
+
): Fx<A | B | C, E, R> {
|
|
680
679
|
return new PadWith(fx, start, end)
|
|
681
680
|
}
|
|
682
681
|
|
|
683
|
-
export function prependAll<
|
|
684
|
-
fx: Fx<
|
|
682
|
+
export function prependAll<A, E, R, B>(
|
|
683
|
+
fx: Fx<A, E, R>,
|
|
685
684
|
start: Iterable<B>
|
|
686
|
-
): Fx<
|
|
685
|
+
): Fx<A | B, E, R> {
|
|
687
686
|
return new PadWith(fx, start, [])
|
|
688
687
|
}
|
|
689
688
|
|
|
690
|
-
export function appendAll<
|
|
691
|
-
fx: Fx<
|
|
689
|
+
export function appendAll<A, E, R, C>(
|
|
690
|
+
fx: Fx<A, E, R>,
|
|
692
691
|
end: Iterable<C>
|
|
693
|
-
): Fx<
|
|
692
|
+
): Fx<A | C, E, R> {
|
|
694
693
|
return new PadWith(fx, [], end)
|
|
695
694
|
}
|
|
696
695
|
|
|
697
|
-
export function prepend<
|
|
696
|
+
export function prepend<A, E, R, B>(fx: Fx<A, E, R>, start: B): Fx<A | B, E, R> {
|
|
698
697
|
return new PadWith(fx, [start], [])
|
|
699
698
|
}
|
|
700
699
|
|
|
701
|
-
export function append<
|
|
702
|
-
return new PadWith<
|
|
700
|
+
export function append<A, E, R, C>(fx: Fx<A, E, R>, end: C): Fx<A | C, E, R> {
|
|
701
|
+
return new PadWith<A, E, R, never, C>(fx, [], [end])
|
|
703
702
|
}
|
|
704
703
|
|
|
705
|
-
export function scan<
|
|
704
|
+
export function scan<A, E, R, B>(fx: Fx<A, E, R>, seed: B, f: (b: B, a: A) => B): Fx<B, E, R> {
|
|
706
705
|
return prepend(
|
|
707
706
|
loop(fx, seed, (b, a) => {
|
|
708
707
|
const b2 = f(b, a)
|
|
@@ -713,17 +712,17 @@ export function scan<R, E, A, B>(fx: Fx<R, E, A>, seed: B, f: (b: B, a: A) => B)
|
|
|
713
712
|
}
|
|
714
713
|
|
|
715
714
|
class PadWith<
|
|
716
|
-
R,
|
|
717
|
-
E,
|
|
718
715
|
A,
|
|
716
|
+
E,
|
|
717
|
+
R,
|
|
719
718
|
B,
|
|
720
719
|
C
|
|
721
|
-
> extends FxBase<
|
|
722
|
-
constructor(readonly i0: Fx<
|
|
720
|
+
> extends FxBase<A | B | C, E, R> {
|
|
721
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Iterable<B>, readonly i2: Iterable<C>) {
|
|
723
722
|
super()
|
|
724
723
|
}
|
|
725
724
|
|
|
726
|
-
run<R2>(sink: Sink.Sink<
|
|
725
|
+
run<R2>(sink: Sink.Sink<A | B | C, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
727
726
|
const onSuccess = (a: A | B | C) => sink.onSuccess(a)
|
|
728
727
|
|
|
729
728
|
return Effect.forEach(this.i1, onSuccess, DISCARD).pipe(
|
|
@@ -732,11 +731,11 @@ class PadWith<
|
|
|
732
731
|
)
|
|
733
732
|
}
|
|
734
733
|
|
|
735
|
-
static make<
|
|
736
|
-
fx: Fx<
|
|
734
|
+
static make<A, E, R, B, C>(
|
|
735
|
+
fx: Fx<A, E, R>,
|
|
737
736
|
start: Iterable<B>,
|
|
738
737
|
end: Iterable<C>
|
|
739
|
-
): Fx<
|
|
738
|
+
): Fx<A | B | C, E, R> {
|
|
740
739
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
741
740
|
else if (isPadWith(fx)) {
|
|
742
741
|
return new PadWith(fx.i0, concat(start, fx.i1), concat(fx.i2, end))
|
|
@@ -758,74 +757,74 @@ function concat<A, B>(a: Iterable<A>, b: Iterable<B>): Iterable<A | B> {
|
|
|
758
757
|
/**
|
|
759
758
|
* @internal
|
|
760
759
|
*/
|
|
761
|
-
export function isPadWith<
|
|
762
|
-
fx: Fx<
|
|
763
|
-
): fx is PadWith<
|
|
760
|
+
export function isPadWith<A, E, R>(
|
|
761
|
+
fx: Fx<A, E, R>
|
|
762
|
+
): fx is PadWith<A, E, R, A, A> {
|
|
764
763
|
return fx.constructor === PadWith
|
|
765
764
|
}
|
|
766
765
|
|
|
767
|
-
export function flatMapWithStrategy<
|
|
768
|
-
fx: Fx<
|
|
769
|
-
f: (a: A) => Fx<
|
|
766
|
+
export function flatMapWithStrategy<A, E, R, B, E2, R2>(
|
|
767
|
+
fx: Fx<A, E, R>,
|
|
768
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
770
769
|
strategy: FlattenStrategy,
|
|
771
770
|
executionStrategy: ExecutionStrategy.ExecutionStrategy = ExecutionStrategy.sequential
|
|
772
|
-
): Fx<R | R2 | Scope.Scope
|
|
771
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
773
772
|
return FlatMapWithStrategy.make(fx, f, strategy, executionStrategy)
|
|
774
773
|
}
|
|
775
774
|
|
|
776
|
-
export function switchMap<
|
|
777
|
-
fx: Fx<
|
|
778
|
-
f: (a: A) => Fx<
|
|
775
|
+
export function switchMap<A, E, R, B, E2, R2>(
|
|
776
|
+
fx: Fx<A, E, R>,
|
|
777
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
779
778
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
780
|
-
): Fx<R | R2 | Scope.Scope
|
|
779
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
781
780
|
return flatMapWithStrategy(fx, f, Switch, executionStrategy)
|
|
782
781
|
}
|
|
783
782
|
|
|
784
|
-
export function switchMapEffect<
|
|
785
|
-
fx: Fx<
|
|
786
|
-
f: (a: A) => Effect.Effect<
|
|
783
|
+
export function switchMapEffect<A, E, R, B, E2, R2>(
|
|
784
|
+
fx: Fx<A, E, R>,
|
|
785
|
+
f: (a: A) => Effect.Effect<B, E2, R2>,
|
|
787
786
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
788
|
-
): Fx<R | R2 | Scope.Scope
|
|
787
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
789
788
|
return switchMap(fx, (a) => fromEffect(f(a)), executionStrategy)
|
|
790
789
|
}
|
|
791
790
|
|
|
792
|
-
export function exhaustMap<
|
|
793
|
-
fx: Fx<
|
|
794
|
-
f: (a: A) => Fx<
|
|
791
|
+
export function exhaustMap<A, E, R, B, E2, R2>(
|
|
792
|
+
fx: Fx<A, E, R>,
|
|
793
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
795
794
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
796
|
-
): Fx<R | R2 | Scope.Scope
|
|
795
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
797
796
|
return flatMapWithStrategy(fx, f, Exhaust, executionStrategy)
|
|
798
797
|
}
|
|
799
798
|
|
|
800
|
-
export function exhaustMapEffect<
|
|
801
|
-
fx: Fx<
|
|
802
|
-
f: (a: A) => Effect.Effect<
|
|
799
|
+
export function exhaustMapEffect<A, E, R, B, E2, R2>(
|
|
800
|
+
fx: Fx<A, E, R>,
|
|
801
|
+
f: (a: A) => Effect.Effect<B, E2, R2>,
|
|
803
802
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
804
|
-
): Fx<R | R2 | Scope.Scope
|
|
803
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
805
804
|
return exhaustMap(fx, (a) => fromEffect(f(a)), executionStrategy)
|
|
806
805
|
}
|
|
807
806
|
|
|
808
|
-
export function exhaustMapLatest<
|
|
809
|
-
fx: Fx<
|
|
810
|
-
f: (a: A) => Fx<
|
|
807
|
+
export function exhaustMapLatest<A, E, R, B, E2, R2>(
|
|
808
|
+
fx: Fx<A, E, R>,
|
|
809
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
811
810
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
812
|
-
): Fx<R | R2 | Scope.Scope
|
|
811
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
813
812
|
return flatMapWithStrategy(fx, f, ExhaustLatest, executionStrategy)
|
|
814
813
|
}
|
|
815
814
|
|
|
816
|
-
export function exhaustMapLatestEffect<
|
|
817
|
-
fx: Fx<
|
|
818
|
-
f: (a: A) => Effect.Effect<
|
|
815
|
+
export function exhaustMapLatestEffect<A, E, R, B, E2, R2>(
|
|
816
|
+
fx: Fx<A, E, R>,
|
|
817
|
+
f: (a: A) => Effect.Effect<B, E2, R2>,
|
|
819
818
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
820
|
-
): Fx<R | R2 | Scope.Scope
|
|
819
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
821
820
|
return exhaustMapLatest(fx, (a) => fromEffect(f(a)), executionStrategy)
|
|
822
821
|
}
|
|
823
822
|
|
|
824
|
-
export function exhaustFilterMapLatestEffect<
|
|
825
|
-
fx: Fx<
|
|
826
|
-
f: (a: A) => Effect.Effect<
|
|
823
|
+
export function exhaustFilterMapLatestEffect<A, E, R, B, E2, R2>(
|
|
824
|
+
fx: Fx<A, E, R>,
|
|
825
|
+
f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>,
|
|
827
826
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
828
|
-
): Fx<R | R2 | Scope.Scope
|
|
827
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
829
828
|
return exhaustMapLatest(fx, (a) =>
|
|
830
829
|
fromFxEffect(Effect.map(
|
|
831
830
|
f(a),
|
|
@@ -836,67 +835,67 @@ export function exhaustFilterMapLatestEffect<R, E, A, R2, E2, B>(
|
|
|
836
835
|
)), executionStrategy)
|
|
837
836
|
}
|
|
838
837
|
|
|
839
|
-
export function flatMapConcurrently<
|
|
840
|
-
fx: Fx<
|
|
841
|
-
f: (a: A) => Fx<
|
|
838
|
+
export function flatMapConcurrently<A, E, R, B, E2, R2>(
|
|
839
|
+
fx: Fx<A, E, R>,
|
|
840
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
842
841
|
capacity: number,
|
|
843
842
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
844
|
-
): Fx<R | R2 | Scope.Scope
|
|
843
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
845
844
|
return flatMapWithStrategy(fx, f, Bounded(capacity), executionStrategy)
|
|
846
845
|
}
|
|
847
846
|
|
|
848
|
-
export function concatMap<
|
|
849
|
-
fx: Fx<
|
|
850
|
-
f: (a: A) => Fx<
|
|
847
|
+
export function concatMap<A, E, R, B, E2, R2>(
|
|
848
|
+
fx: Fx<A, E, R>,
|
|
849
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
851
850
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
852
|
-
): Fx<R | R2 | Scope.Scope
|
|
851
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
853
852
|
return flatMapConcurrently(fx, f, 1, executionStrategy)
|
|
854
853
|
}
|
|
855
854
|
|
|
856
|
-
export function flatMapConcurrentlyEffect<
|
|
857
|
-
fx: Fx<
|
|
858
|
-
f: (a: A) => Effect.Effect<
|
|
855
|
+
export function flatMapConcurrentlyEffect<A, E, R, B, E2, R2>(
|
|
856
|
+
fx: Fx<A, E, R>,
|
|
857
|
+
f: (a: A) => Effect.Effect<B, E2, R2>,
|
|
859
858
|
capacity: number,
|
|
860
859
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
861
|
-
): Fx<R | R2 | Scope.Scope
|
|
860
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
862
861
|
return flatMapConcurrently(fx, (a) => fromEffect(f(a)), capacity, executionStrategy)
|
|
863
862
|
}
|
|
864
863
|
|
|
865
|
-
export function flatMap<
|
|
866
|
-
fx: Fx<
|
|
867
|
-
f: (a: A) => Fx<
|
|
864
|
+
export function flatMap<A, E, R, B, E2, R2>(
|
|
865
|
+
fx: Fx<A, E, R>,
|
|
866
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
868
867
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
869
|
-
): Fx<R | R2 | Scope.Scope
|
|
868
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
870
869
|
return flatMapWithStrategy(fx, f, Unbounded, executionStrategy)
|
|
871
870
|
}
|
|
872
871
|
|
|
873
|
-
export function flatMapEffect<
|
|
874
|
-
fx: Fx<
|
|
875
|
-
f: (a: A) => Effect.Effect<
|
|
872
|
+
export function flatMapEffect<A, E, R, B, E2, R2>(
|
|
873
|
+
fx: Fx<A, E, R>,
|
|
874
|
+
f: (a: A) => Effect.Effect<B, E2, R2>,
|
|
876
875
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
877
|
-
): Fx<R | R2 | Scope.Scope
|
|
876
|
+
): Fx<B, E | E2, R | R2 | Scope.Scope> {
|
|
878
877
|
return flatMap(fx, (a) => fromEffect(f(a)), executionStrategy)
|
|
879
878
|
}
|
|
880
879
|
|
|
881
880
|
class FlatMapWithStrategy<
|
|
882
|
-
R,
|
|
883
|
-
E,
|
|
884
881
|
A,
|
|
882
|
+
E,
|
|
883
|
+
R,
|
|
885
884
|
R2,
|
|
886
885
|
E2,
|
|
887
886
|
B
|
|
888
|
-
> extends FxBase<R | R2 | Scope.Scope
|
|
889
|
-
private withFork: <
|
|
887
|
+
> extends FxBase<B, E | E2, R | R2 | Scope.Scope> {
|
|
888
|
+
private withFork: <A, E, R>(
|
|
890
889
|
f: (
|
|
891
890
|
fork: FxFork,
|
|
892
891
|
scope: Scope.Scope
|
|
893
|
-
) => Effect.Effect<
|
|
892
|
+
) => Effect.Effect<A, E, R>,
|
|
894
893
|
executionStrategy: ExecutionStrategy.ExecutionStrategy
|
|
895
|
-
) => Effect.Effect<Scope.Scope | R
|
|
894
|
+
) => Effect.Effect<void, E, Scope.Scope | R>
|
|
896
895
|
|
|
897
896
|
constructor(
|
|
898
|
-
readonly i0: Fx<
|
|
899
|
-
readonly i1: (a: A) => Fx<
|
|
897
|
+
readonly i0: Fx<A, E, R>,
|
|
898
|
+
readonly i1: (a: A) => Fx<B, E2, R2>,
|
|
900
899
|
readonly i2: FlattenStrategy,
|
|
901
900
|
readonly i3: ExecutionStrategy.ExecutionStrategy
|
|
902
901
|
) {
|
|
@@ -905,7 +904,7 @@ class FlatMapWithStrategy<
|
|
|
905
904
|
this.withFork = withFlattenStrategy(i2)
|
|
906
905
|
}
|
|
907
906
|
|
|
908
|
-
run<R3>(sink: Sink.Sink<
|
|
907
|
+
run<R3>(sink: Sink.Sink<B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
|
|
909
908
|
return this.withFork(
|
|
910
909
|
(fork) =>
|
|
911
910
|
Sink.withEarlyExit(sink, (sink) =>
|
|
@@ -919,9 +918,9 @@ class FlatMapWithStrategy<
|
|
|
919
918
|
)
|
|
920
919
|
}
|
|
921
920
|
|
|
922
|
-
static make<
|
|
923
|
-
fx: Fx<
|
|
924
|
-
f: (a: A) => Fx<
|
|
921
|
+
static make<A, E, R, B, E2, R2>(
|
|
922
|
+
fx: Fx<A, E, R>,
|
|
923
|
+
f: (a: A) => Fx<B, E2, R2>,
|
|
925
924
|
strategy: FlattenStrategy,
|
|
926
925
|
executionStrategy: ExecutionStrategy.ExecutionStrategy
|
|
927
926
|
) {
|
|
@@ -958,9 +957,9 @@ class FlatMapWithStrategy<
|
|
|
958
957
|
}
|
|
959
958
|
}
|
|
960
959
|
|
|
961
|
-
export function fromFxEffect<
|
|
962
|
-
effect: Effect.Effect<
|
|
963
|
-
): Fx<
|
|
960
|
+
export function fromFxEffect<B, E, R, E2, R2>(
|
|
961
|
+
effect: Effect.Effect<Fx<B, E2, R2>, E, R>
|
|
962
|
+
): Fx<B, E | E2, R | R2> {
|
|
964
963
|
return new FromFxEffect(effect)
|
|
965
964
|
}
|
|
966
965
|
|
|
@@ -970,12 +969,12 @@ class FromFxEffect<
|
|
|
970
969
|
R2,
|
|
971
970
|
E2,
|
|
972
971
|
B
|
|
973
|
-
> extends FxBase<
|
|
974
|
-
constructor(readonly i0: Effect.Effect<
|
|
972
|
+
> extends FxBase<B, E | E2, R | R2> {
|
|
973
|
+
constructor(readonly i0: Effect.Effect<Fx<B, E2, R2>, E, R>) {
|
|
975
974
|
super()
|
|
976
975
|
}
|
|
977
976
|
|
|
978
|
-
run<R3>(sink: Sink.Sink<
|
|
977
|
+
run<R3>(sink: Sink.Sink<B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
979
978
|
return Effect.matchCauseEffect(this.i0, {
|
|
980
979
|
onFailure: (cause) => sink.onFailure(cause),
|
|
981
980
|
onSuccess: (fx) => fx.run(sink)
|
|
@@ -986,9 +985,9 @@ class FromFxEffect<
|
|
|
986
985
|
export function gen<Y extends Effect.EffectGen<any, any, any>, FX extends Fx<any, any, any>>(
|
|
987
986
|
f: (_: Effect.Adapter) => Generator<Y, FX, any>
|
|
988
987
|
): Fx<
|
|
989
|
-
|
|
988
|
+
Fx.Success<FX>,
|
|
990
989
|
Effect.Effect.Error<Y["value"]> | Fx.Error<FX>,
|
|
991
|
-
Fx.
|
|
990
|
+
Effect.Effect.Context<Y["value"]> | Fx.Context<FX>
|
|
992
991
|
> {
|
|
993
992
|
return fromFxEffect(Effect.gen(f))
|
|
994
993
|
}
|
|
@@ -996,40 +995,40 @@ export function gen<Y extends Effect.EffectGen<any, any, any>, FX extends Fx<any
|
|
|
996
995
|
export function genScoped<Y extends Effect.EffectGen<any, any, any>, FX extends Fx<any, any, any>>(
|
|
997
996
|
f: (_: Effect.Adapter) => Generator<Y, FX, any>
|
|
998
997
|
): Fx<
|
|
999
|
-
|
|
998
|
+
Fx.Success<FX>,
|
|
1000
999
|
Effect.Effect.Error<Y["value"]> | Fx.Error<FX>,
|
|
1001
|
-
Fx.
|
|
1000
|
+
Exclude<Effect.Effect.Context<Y["value"]> | Fx.Context<FX>, Scope.Scope>
|
|
1002
1001
|
> {
|
|
1003
1002
|
return scoped(fromFxEffect(Effect.gen(f)))
|
|
1004
1003
|
}
|
|
1005
1004
|
|
|
1006
|
-
export function continueWith<
|
|
1007
|
-
fx: Fx<
|
|
1008
|
-
f: () => Fx<
|
|
1009
|
-
): Fx<
|
|
1005
|
+
export function continueWith<A, E, R, B, E2, R2>(
|
|
1006
|
+
fx: Fx<A, E, R>,
|
|
1007
|
+
f: () => Fx<B, E2, R2>
|
|
1008
|
+
): Fx<A | B, E | E2, R | R2> {
|
|
1010
1009
|
return ContinueWith.make(fx, f)
|
|
1011
1010
|
}
|
|
1012
1011
|
|
|
1013
1012
|
class ContinueWith<
|
|
1014
|
-
R,
|
|
1015
|
-
E,
|
|
1016
1013
|
A,
|
|
1014
|
+
E,
|
|
1015
|
+
R,
|
|
1017
1016
|
R2,
|
|
1018
1017
|
E2,
|
|
1019
1018
|
B
|
|
1020
|
-
> extends FxBase<
|
|
1021
|
-
constructor(readonly i0: Fx<
|
|
1019
|
+
> extends FxBase<A | B, E | E2, R | R2> {
|
|
1020
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: () => Fx<B, E2, R2>) {
|
|
1022
1021
|
super()
|
|
1023
1022
|
}
|
|
1024
1023
|
|
|
1025
|
-
run<R3>(sink: Sink.Sink<
|
|
1024
|
+
run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1026
1025
|
return Effect.flatMap(this.i0.run(sink), () => this.i1().run(sink))
|
|
1027
1026
|
}
|
|
1028
1027
|
|
|
1029
|
-
static make<
|
|
1030
|
-
fx: Fx<
|
|
1031
|
-
f: () => Fx<
|
|
1032
|
-
): Fx<
|
|
1028
|
+
static make<A, E, R, B, E2, R2>(
|
|
1029
|
+
fx: Fx<A, E, R>,
|
|
1030
|
+
f: () => Fx<B, E2, R2>
|
|
1031
|
+
): Fx<A | B, E | E2, R | R2> {
|
|
1033
1032
|
if (isEmpty(fx)) return f()
|
|
1034
1033
|
else if (isNever(fx)) return fx
|
|
1035
1034
|
else if (isProducer(fx)) {
|
|
@@ -1045,33 +1044,33 @@ class ContinueWith<
|
|
|
1045
1044
|
}
|
|
1046
1045
|
}
|
|
1047
1046
|
|
|
1048
|
-
export function orElseCause<
|
|
1049
|
-
fx: Fx<
|
|
1050
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
1051
|
-
): Fx<
|
|
1047
|
+
export function orElseCause<A, E, R, B, E2, R2>(
|
|
1048
|
+
fx: Fx<A, E, R>,
|
|
1049
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>
|
|
1050
|
+
): Fx<A | B, E2, R | R2> {
|
|
1052
1051
|
return OrElseCause.make(fx, f)
|
|
1053
1052
|
}
|
|
1054
1053
|
|
|
1055
1054
|
class OrElseCause<
|
|
1056
|
-
R,
|
|
1057
|
-
E,
|
|
1058
1055
|
A,
|
|
1056
|
+
E,
|
|
1057
|
+
R,
|
|
1059
1058
|
R2,
|
|
1060
1059
|
E2,
|
|
1061
1060
|
B
|
|
1062
|
-
> extends FxBase<
|
|
1063
|
-
constructor(readonly i0: Fx<
|
|
1061
|
+
> extends FxBase<A | B, E2, R | R2> {
|
|
1062
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: (cause: Cause.Cause<E>) => Fx<B, E2, R2>) {
|
|
1064
1063
|
super()
|
|
1065
1064
|
}
|
|
1066
1065
|
|
|
1067
|
-
run<R3>(sink: Sink.Sink<
|
|
1066
|
+
run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1068
1067
|
return Effect.catchAllCause(observe(this.i0, sink.onSuccess), (cause) => this.i1(cause).run(sink))
|
|
1069
1068
|
}
|
|
1070
1069
|
|
|
1071
|
-
static make<
|
|
1072
|
-
fx: Fx<
|
|
1073
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
1074
|
-
): Fx<
|
|
1070
|
+
static make<A, E, R, B, E2, R2>(
|
|
1071
|
+
fx: Fx<A, E, R>,
|
|
1072
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>
|
|
1073
|
+
): Fx<A | B, E2, R | R2> {
|
|
1075
1074
|
if (isEmpty(fx)) return fx
|
|
1076
1075
|
else if (isNever(fx)) return fx
|
|
1077
1076
|
else {
|
|
@@ -1080,28 +1079,28 @@ class OrElseCause<
|
|
|
1080
1079
|
}
|
|
1081
1080
|
}
|
|
1082
1081
|
|
|
1083
|
-
export function orElse<
|
|
1084
|
-
fx: Fx<
|
|
1085
|
-
f: (error: E) => Fx<
|
|
1086
|
-
): Fx<
|
|
1082
|
+
export function orElse<A, E, R, B, E2, R2>(
|
|
1083
|
+
fx: Fx<A, E, R>,
|
|
1084
|
+
f: (error: E) => Fx<B, E2, R2>
|
|
1085
|
+
): Fx<A | B, E2, R | R2> {
|
|
1087
1086
|
return OrElse.make(fx, f)
|
|
1088
1087
|
}
|
|
1089
1088
|
|
|
1090
1089
|
class OrElse<
|
|
1091
|
-
R,
|
|
1092
|
-
E,
|
|
1093
1090
|
A,
|
|
1091
|
+
E,
|
|
1092
|
+
R,
|
|
1094
1093
|
R2,
|
|
1095
1094
|
E2,
|
|
1096
1095
|
B
|
|
1097
|
-
> extends FxBase<
|
|
1098
|
-
constructor(readonly i0: Fx<
|
|
1096
|
+
> extends FxBase<A | B, E2, R | R2> {
|
|
1097
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: (error: E) => Fx<B, E2, R2>) {
|
|
1099
1098
|
super()
|
|
1100
1099
|
}
|
|
1101
1100
|
|
|
1102
|
-
run<R3>(sink: Sink.Sink<
|
|
1101
|
+
run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1103
1102
|
return Effect.catchAll(
|
|
1104
|
-
Effect.asyncEffect<
|
|
1103
|
+
Effect.asyncEffect<unknown, E, never, void, never, R | R2 | R3>((resume) =>
|
|
1105
1104
|
Effect.zipRight(
|
|
1106
1105
|
this.i0.run(
|
|
1107
1106
|
Sink.make(
|
|
@@ -1116,14 +1115,14 @@ class OrElse<
|
|
|
1116
1115
|
Effect.sync(() => resume(Effect.unit))
|
|
1117
1116
|
)
|
|
1118
1117
|
),
|
|
1119
|
-
(error) => this.i1(error).run(sink)
|
|
1118
|
+
(error: E) => this.i1(error).run(sink)
|
|
1120
1119
|
)
|
|
1121
1120
|
}
|
|
1122
1121
|
|
|
1123
|
-
static make<
|
|
1124
|
-
fx: Fx<
|
|
1125
|
-
f: (error: E) => Fx<
|
|
1126
|
-
): Fx<
|
|
1122
|
+
static make<A, E, R, B, E2, R2>(
|
|
1123
|
+
fx: Fx<A, E, R>,
|
|
1124
|
+
f: (error: E) => Fx<B, E2, R2>
|
|
1125
|
+
): Fx<A | B, E2, R | R2> {
|
|
1127
1126
|
if (isEmpty(fx)) return fx
|
|
1128
1127
|
else if (isNever(fx)) return fx
|
|
1129
1128
|
else {
|
|
@@ -1132,35 +1131,35 @@ class OrElse<
|
|
|
1132
1131
|
}
|
|
1133
1132
|
}
|
|
1134
1133
|
|
|
1135
|
-
export function suspend<
|
|
1134
|
+
export function suspend<A, E, R>(f: () => Fx<A, E, R>): Fx<A, E, R> {
|
|
1136
1135
|
return new Suspend(f)
|
|
1137
1136
|
}
|
|
1138
1137
|
|
|
1139
|
-
class Suspend<
|
|
1140
|
-
constructor(readonly i0: () => Fx<
|
|
1138
|
+
class Suspend<A, E, R> extends FxBase<A, E, R> {
|
|
1139
|
+
constructor(readonly i0: () => Fx<A, E, R>) {
|
|
1141
1140
|
super()
|
|
1142
1141
|
}
|
|
1143
1142
|
|
|
1144
|
-
run<R2>(sink: Sink.Sink<
|
|
1143
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
1145
1144
|
return this.i0().run(sink)
|
|
1146
1145
|
}
|
|
1147
1146
|
}
|
|
1148
1147
|
|
|
1149
|
-
function isSuspend<
|
|
1148
|
+
function isSuspend<A, E, R>(fx: Fx<A, E, R>): fx is Suspend<A, E, R> {
|
|
1150
1149
|
return fx.constructor === Suspend
|
|
1151
1150
|
}
|
|
1152
1151
|
|
|
1153
|
-
class SuspendedTransformer<
|
|
1154
|
-
constructor(readonly i0: () => Fx<
|
|
1152
|
+
class SuspendedTransformer<A, E, R, B, E2, R2> extends FxBase<B, E2, R | R2> {
|
|
1153
|
+
constructor(readonly i0: () => Fx<A, E, R>, readonly i1: Op.Operator) {
|
|
1155
1154
|
super()
|
|
1156
1155
|
}
|
|
1157
1156
|
|
|
1158
|
-
run<R3>(sink: Sink.Sink<
|
|
1157
|
+
run<R3>(sink: Sink.Sink<B, E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1159
1158
|
return this.i0().run(Op.compileOperatorSink(this.i1, sink))
|
|
1160
1159
|
}
|
|
1161
1160
|
}
|
|
1162
1161
|
|
|
1163
|
-
function isSuspendedTransformer<
|
|
1162
|
+
function isSuspendedTransformer<A, E, R>(fx: Fx<A, E, R>): fx is SuspendedTransformer<A, E, R, any, any, any> {
|
|
1164
1163
|
return fx.constructor === SuspendedTransformer
|
|
1165
1164
|
}
|
|
1166
1165
|
|
|
@@ -1168,59 +1167,59 @@ export function mergeWithStrategy<const FX extends ReadonlyArray<Fx<any, any, an
|
|
|
1168
1167
|
fx: FX,
|
|
1169
1168
|
stategy: MergeStrategy
|
|
1170
1169
|
): Fx<
|
|
1171
|
-
Fx.
|
|
1170
|
+
Fx.Success<FX[number]>,
|
|
1172
1171
|
Fx.Error<FX[number]>,
|
|
1173
|
-
Fx.
|
|
1172
|
+
Fx.Context<FX[number]>
|
|
1174
1173
|
> {
|
|
1175
1174
|
return MergeWithStrategy.make(fx, stategy)
|
|
1176
1175
|
}
|
|
1177
1176
|
|
|
1178
|
-
export function merge<
|
|
1179
|
-
fx: Fx<
|
|
1180
|
-
other: Fx<
|
|
1181
|
-
): Fx<
|
|
1177
|
+
export function merge<A, E, R, B, E2, R2>(
|
|
1178
|
+
fx: Fx<A, E, R>,
|
|
1179
|
+
other: Fx<B, E2, R2>
|
|
1180
|
+
): Fx<A | B, E | E2, R | R2> {
|
|
1182
1181
|
return mergeWithStrategy([fx, other], Unordered(2))
|
|
1183
1182
|
}
|
|
1184
1183
|
|
|
1185
1184
|
export function mergeAll<FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
1186
1185
|
fx: FX
|
|
1187
|
-
): Fx<Fx.
|
|
1186
|
+
): Fx<Fx.Success<FX[number]>, Fx.Error<FX[number]>, Fx.Context<FX[number]>> {
|
|
1188
1187
|
return mergeWithStrategy(fx, Unordered(Infinity))
|
|
1189
1188
|
}
|
|
1190
1189
|
|
|
1191
1190
|
export function mergeOrdered<FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
1192
1191
|
fx: FX
|
|
1193
|
-
): Fx<Fx.
|
|
1192
|
+
): Fx<Fx.Success<FX[number]>, Fx.Error<FX[number]>, Fx.Context<FX[number]>> {
|
|
1194
1193
|
return mergeOrderedConcurrently(fx, Infinity)
|
|
1195
1194
|
}
|
|
1196
1195
|
|
|
1197
1196
|
export function mergeOrderedConcurrently<FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
1198
1197
|
fx: FX,
|
|
1199
1198
|
concurrency: number
|
|
1200
|
-
): Fx<Fx.
|
|
1199
|
+
): Fx<Fx.Success<FX[number]>, Fx.Error<FX[number]>, Fx.Context<FX[number]>> {
|
|
1201
1200
|
return mergeWithStrategy(fx, Ordered(concurrency))
|
|
1202
1201
|
}
|
|
1203
1202
|
|
|
1204
1203
|
export function mergeSwitch<FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
1205
1204
|
fx: FX
|
|
1206
|
-
): Fx<Fx.
|
|
1205
|
+
): Fx<Fx.Success<FX[number]>, Fx.Error<FX[number]>, Fx.Context<FX[number]>> {
|
|
1207
1206
|
return mergeWithStrategy(fx, Switch)
|
|
1208
1207
|
}
|
|
1209
1208
|
|
|
1210
1209
|
class MergeWithStrategy<
|
|
1211
1210
|
const FX extends ReadonlyArray<Fx<any, any, any>>
|
|
1212
1211
|
> extends FxBase<
|
|
1213
|
-
Fx.
|
|
1212
|
+
Fx.Success<FX[number]>,
|
|
1214
1213
|
Fx.Error<FX[number]>,
|
|
1215
|
-
Fx.
|
|
1214
|
+
Fx.Context<FX[number]>
|
|
1216
1215
|
> {
|
|
1217
1216
|
constructor(readonly i0: FX, readonly i1: MergeStrategy) {
|
|
1218
1217
|
super()
|
|
1219
1218
|
}
|
|
1220
1219
|
|
|
1221
1220
|
run<R2>(
|
|
1222
|
-
sink: Sink.Sink<
|
|
1223
|
-
): Effect.Effect<Fx.Context<FX[number]> | R2
|
|
1221
|
+
sink: Sink.Sink<Fx.Success<FX[number]>, Fx.Error<FX[number]>, R2>
|
|
1222
|
+
): Effect.Effect<unknown, never, Fx.Context<FX[number]> | R2> {
|
|
1224
1223
|
switch (this.i1._tag) {
|
|
1225
1224
|
case "Unordered":
|
|
1226
1225
|
return runUnordered(this.i0, sink, this.i1.concurrency === Infinity ? "unbounded" : this.i1.concurrency)
|
|
@@ -1235,9 +1234,9 @@ class MergeWithStrategy<
|
|
|
1235
1234
|
fx: FX,
|
|
1236
1235
|
strategy: MergeStrategy
|
|
1237
1236
|
): Fx<
|
|
1238
|
-
Fx.
|
|
1237
|
+
Fx.Success<FX[number]>,
|
|
1239
1238
|
Fx.Error<FX[number]>,
|
|
1240
|
-
Fx.
|
|
1239
|
+
Fx.Context<FX[number]>
|
|
1241
1240
|
> {
|
|
1242
1241
|
if (fx.length === 0) return empty
|
|
1243
1242
|
else if (fx.length === 1) return fx[0]
|
|
@@ -1250,9 +1249,9 @@ function runUnordered<
|
|
|
1250
1249
|
R2
|
|
1251
1250
|
>(
|
|
1252
1251
|
fx: FX,
|
|
1253
|
-
sink: Sink.Sink<
|
|
1252
|
+
sink: Sink.Sink<any, any, R2>,
|
|
1254
1253
|
concurrency: number | "unbounded"
|
|
1255
|
-
): Effect.Effect<R2 | Fx.Context<FX[number]
|
|
1254
|
+
): Effect.Effect<unknown, never, R2 | Fx.Context<FX[number]>> {
|
|
1256
1255
|
return Effect.forEach(fx, (fx) => fx.run(sink), { concurrency, discard: true })
|
|
1257
1256
|
}
|
|
1258
1257
|
|
|
@@ -1261,9 +1260,9 @@ function runOrdered<
|
|
|
1261
1260
|
R2
|
|
1262
1261
|
>(
|
|
1263
1262
|
fx: FX,
|
|
1264
|
-
sink: Sink.Sink<
|
|
1263
|
+
sink: Sink.Sink<any, any, R2>,
|
|
1265
1264
|
concurrency: number | "unbounded"
|
|
1266
|
-
): Effect.Effect<R2 | Fx.Context<FX[number]
|
|
1265
|
+
): Effect.Effect<unknown, never, R2 | Fx.Context<FX[number]>> {
|
|
1267
1266
|
return Effect.suspend(
|
|
1268
1267
|
() => {
|
|
1269
1268
|
const buffers = withBuffers(fx.length, sink)
|
|
@@ -1292,35 +1291,35 @@ function runSwitch<
|
|
|
1292
1291
|
R2
|
|
1293
1292
|
>(
|
|
1294
1293
|
fx: FX,
|
|
1295
|
-
sink: Sink.Sink<
|
|
1296
|
-
): Effect.Effect<R2 | Fx.Context<FX[number]
|
|
1294
|
+
sink: Sink.Sink<any, any, R2>
|
|
1295
|
+
): Effect.Effect<unknown, never, R2 | Fx.Context<FX[number]>> {
|
|
1297
1296
|
return Effect.forEach(fx, (fx) => fx.run(sink), { concurrency: 1, discard: true })
|
|
1298
1297
|
}
|
|
1299
1298
|
|
|
1300
|
-
export function takeWhile<
|
|
1301
|
-
fx: Fx<
|
|
1299
|
+
export function takeWhile<A, E, R>(
|
|
1300
|
+
fx: Fx<A, E, R>,
|
|
1302
1301
|
f: Predicate.Predicate<A>
|
|
1303
|
-
): Fx<
|
|
1302
|
+
): Fx<A, E, R> {
|
|
1304
1303
|
return TakeWhile.make(fx, f)
|
|
1305
1304
|
}
|
|
1306
1305
|
|
|
1307
|
-
export function takeUntil<
|
|
1308
|
-
fx: Fx<
|
|
1306
|
+
export function takeUntil<A, E, R>(
|
|
1307
|
+
fx: Fx<A, E, R>,
|
|
1309
1308
|
f: Predicate.Predicate<A>
|
|
1310
|
-
): Fx<
|
|
1309
|
+
): Fx<A, E, R> {
|
|
1311
1310
|
return TakeWhile.make(fx, Predicate.not(f))
|
|
1312
1311
|
}
|
|
1313
1312
|
|
|
1314
|
-
class TakeWhile<
|
|
1315
|
-
constructor(readonly i0: Fx<
|
|
1313
|
+
class TakeWhile<A, E, R> extends FxBase<A, E, R> {
|
|
1314
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Predicate.Predicate<A>) {
|
|
1316
1315
|
super()
|
|
1317
1316
|
}
|
|
1318
1317
|
|
|
1319
|
-
run<R2>(sink: Sink.Sink<
|
|
1318
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
1320
1319
|
return Sink.takeWhile(sink, this.i1, (s) => this.i0.run(s))
|
|
1321
1320
|
}
|
|
1322
1321
|
|
|
1323
|
-
static make<
|
|
1322
|
+
static make<A, E, R>(fx: Fx<A, E, R>, predicate: Predicate.Predicate<A>): Fx<A, E, R> {
|
|
1324
1323
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1325
1324
|
else {
|
|
1326
1325
|
return new TakeWhile(fx, predicate)
|
|
@@ -1328,30 +1327,30 @@ class TakeWhile<R, E, A> extends FxBase<R, E, A> {
|
|
|
1328
1327
|
}
|
|
1329
1328
|
}
|
|
1330
1329
|
|
|
1331
|
-
export function dropWhile<
|
|
1332
|
-
fx: Fx<
|
|
1330
|
+
export function dropWhile<A, E, R>(
|
|
1331
|
+
fx: Fx<A, E, R>,
|
|
1333
1332
|
f: Predicate.Predicate<A>
|
|
1334
|
-
): Fx<
|
|
1333
|
+
): Fx<A, E, R> {
|
|
1335
1334
|
return DropUntil.make(fx, f)
|
|
1336
1335
|
}
|
|
1337
1336
|
|
|
1338
|
-
export function dropUntil<
|
|
1339
|
-
fx: Fx<
|
|
1337
|
+
export function dropUntil<A, E, R>(
|
|
1338
|
+
fx: Fx<A, E, R>,
|
|
1340
1339
|
f: Predicate.Predicate<A>
|
|
1341
|
-
): Fx<
|
|
1340
|
+
): Fx<A, E, R> {
|
|
1342
1341
|
return DropUntil.make(fx, Predicate.not(f))
|
|
1343
1342
|
}
|
|
1344
1343
|
|
|
1345
|
-
class DropUntil<
|
|
1346
|
-
constructor(readonly i0: Fx<
|
|
1344
|
+
class DropUntil<A, E, R> extends FxBase<A, E, R> {
|
|
1345
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Predicate.Predicate<A>) {
|
|
1347
1346
|
super()
|
|
1348
1347
|
}
|
|
1349
1348
|
|
|
1350
|
-
run<R2>(sink: Sink.Sink<
|
|
1349
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
1351
1350
|
return this.i0.run(Sink.dropWhile(sink, this.i1))
|
|
1352
1351
|
}
|
|
1353
1352
|
|
|
1354
|
-
static make<
|
|
1353
|
+
static make<A, E, R>(fx: Fx<A, E, R>, predicate: Predicate.Predicate<A>): Fx<A, E, R> {
|
|
1355
1354
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1356
1355
|
else {
|
|
1357
1356
|
return new DropUntil(fx, predicate)
|
|
@@ -1359,23 +1358,23 @@ class DropUntil<R, E, A> extends FxBase<R, E, A> {
|
|
|
1359
1358
|
}
|
|
1360
1359
|
}
|
|
1361
1360
|
|
|
1362
|
-
export function dropAfter<
|
|
1363
|
-
fx: Fx<
|
|
1361
|
+
export function dropAfter<A, E, R>(
|
|
1362
|
+
fx: Fx<A, E, R>,
|
|
1364
1363
|
f: Predicate.Predicate<A>
|
|
1365
|
-
): Fx<
|
|
1364
|
+
): Fx<A, E, R> {
|
|
1366
1365
|
return DropAfter.make(fx, f)
|
|
1367
1366
|
}
|
|
1368
1367
|
|
|
1369
|
-
class DropAfter<
|
|
1370
|
-
constructor(readonly i0: Fx<
|
|
1368
|
+
class DropAfter<A, E, R> extends FxBase<A, E, R> {
|
|
1369
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Predicate.Predicate<A>) {
|
|
1371
1370
|
super()
|
|
1372
1371
|
}
|
|
1373
1372
|
|
|
1374
|
-
run<R2>(sink: Sink.Sink<
|
|
1373
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
1375
1374
|
return this.i0.run(Sink.dropAfter(sink, this.i1))
|
|
1376
1375
|
}
|
|
1377
1376
|
|
|
1378
|
-
static make<
|
|
1377
|
+
static make<A, E, R>(fx: Fx<A, E, R>, predicate: Predicate.Predicate<A>): Fx<A, E, R> {
|
|
1379
1378
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1380
1379
|
else {
|
|
1381
1380
|
return new DropAfter(fx, predicate)
|
|
@@ -1383,33 +1382,33 @@ class DropAfter<R, E, A> extends FxBase<R, E, A> {
|
|
|
1383
1382
|
}
|
|
1384
1383
|
}
|
|
1385
1384
|
|
|
1386
|
-
export function takeWhileEffect<
|
|
1387
|
-
fx: Fx<
|
|
1388
|
-
f: (a: A) => Effect.Effect<
|
|
1389
|
-
): Fx<
|
|
1385
|
+
export function takeWhileEffect<A, E, R, R2, E2>(
|
|
1386
|
+
fx: Fx<A, E, R>,
|
|
1387
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
1388
|
+
): Fx<A, E | E2, R | R2> {
|
|
1390
1389
|
return TakeWhileEffect.make(fx, f)
|
|
1391
1390
|
}
|
|
1392
1391
|
|
|
1393
|
-
export function takeUntilEffect<
|
|
1394
|
-
fx: Fx<
|
|
1395
|
-
f: (a: A) => Effect.Effect<
|
|
1396
|
-
): Fx<
|
|
1392
|
+
export function takeUntilEffect<A, E, R, R2, E2>(
|
|
1393
|
+
fx: Fx<A, E, R>,
|
|
1394
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
1395
|
+
): Fx<A, E | E2, R | R2> {
|
|
1397
1396
|
return TakeWhileEffect.make(fx, (a) => Effect.map(f(a), Boolean.not))
|
|
1398
1397
|
}
|
|
1399
1398
|
|
|
1400
|
-
class TakeWhileEffect<
|
|
1401
|
-
constructor(readonly i0: Fx<
|
|
1399
|
+
class TakeWhileEffect<A, E, R, R2, E2> extends FxBase<A, E | E2, R | R2> {
|
|
1400
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: (a: A) => Effect.Effect<boolean, E2, R2>) {
|
|
1402
1401
|
super()
|
|
1403
1402
|
}
|
|
1404
1403
|
|
|
1405
|
-
run<R3>(sink: Sink.Sink<
|
|
1404
|
+
run<R3>(sink: Sink.Sink<A, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1406
1405
|
return Sink.takeWhileEffect(sink, this.i1, (s) => this.i0.run(s))
|
|
1407
1406
|
}
|
|
1408
1407
|
|
|
1409
|
-
static make<
|
|
1410
|
-
fx: Fx<
|
|
1411
|
-
f: (a: A) => Effect.Effect<
|
|
1412
|
-
): Fx<
|
|
1408
|
+
static make<A, E, R, R2, E2>(
|
|
1409
|
+
fx: Fx<A, E, R>,
|
|
1410
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
1411
|
+
): Fx<A, E | E2, R | R2> {
|
|
1413
1412
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1414
1413
|
else {
|
|
1415
1414
|
return new TakeWhileEffect(fx, f)
|
|
@@ -1417,33 +1416,33 @@ class TakeWhileEffect<R, E, A, R2, E2> extends FxBase<R | R2, E | E2, A> {
|
|
|
1417
1416
|
}
|
|
1418
1417
|
}
|
|
1419
1418
|
|
|
1420
|
-
export function dropWhileEffect<
|
|
1421
|
-
fx: Fx<
|
|
1422
|
-
f: (a: A) => Effect.Effect<
|
|
1423
|
-
): Fx<
|
|
1419
|
+
export function dropWhileEffect<A, E, R>(
|
|
1420
|
+
fx: Fx<A, E, R>,
|
|
1421
|
+
f: (a: A) => Effect.Effect<boolean, E, R>
|
|
1422
|
+
): Fx<A, E, R> {
|
|
1424
1423
|
return DropWhileEffect.make(fx, f)
|
|
1425
1424
|
}
|
|
1426
1425
|
|
|
1427
|
-
export function dropUntilEffect<
|
|
1428
|
-
fx: Fx<
|
|
1429
|
-
f: (a: A) => Effect.Effect<
|
|
1430
|
-
): Fx<
|
|
1426
|
+
export function dropUntilEffect<A, E, R>(
|
|
1427
|
+
fx: Fx<A, E, R>,
|
|
1428
|
+
f: (a: A) => Effect.Effect<boolean, E, R>
|
|
1429
|
+
): Fx<A, E, R> {
|
|
1431
1430
|
return DropWhileEffect.make(fx, (a) => Effect.map(f(a), Boolean.not))
|
|
1432
1431
|
}
|
|
1433
1432
|
|
|
1434
|
-
class DropWhileEffect<
|
|
1435
|
-
constructor(readonly i0: Fx<
|
|
1433
|
+
class DropWhileEffect<A, E, R> extends FxBase<A, E, R> {
|
|
1434
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: (a: A) => Effect.Effect<boolean, E, R>) {
|
|
1436
1435
|
super()
|
|
1437
1436
|
}
|
|
1438
1437
|
|
|
1439
|
-
run<R2>(sink: Sink.Sink<
|
|
1438
|
+
run<R2>(sink: Sink.Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
1440
1439
|
return this.i0.run(Sink.dropWhileEffect(sink, this.i1))
|
|
1441
1440
|
}
|
|
1442
1441
|
|
|
1443
|
-
static make<
|
|
1444
|
-
fx: Fx<
|
|
1445
|
-
f: (a: A) => Effect.Effect<
|
|
1446
|
-
): Fx<
|
|
1442
|
+
static make<A, E, R>(
|
|
1443
|
+
fx: Fx<A, E, R>,
|
|
1444
|
+
f: (a: A) => Effect.Effect<boolean, E, R>
|
|
1445
|
+
): Fx<A, E, R> {
|
|
1447
1446
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1448
1447
|
else {
|
|
1449
1448
|
return new DropWhileEffect(fx, f)
|
|
@@ -1451,26 +1450,26 @@ class DropWhileEffect<R, E, A> extends FxBase<R, E, A> {
|
|
|
1451
1450
|
}
|
|
1452
1451
|
}
|
|
1453
1452
|
|
|
1454
|
-
export function dropAfterEffect<
|
|
1455
|
-
fx: Fx<
|
|
1456
|
-
f: (a: A) => Effect.Effect<
|
|
1457
|
-
): Fx<
|
|
1453
|
+
export function dropAfterEffect<A, E, R, R2, E2>(
|
|
1454
|
+
fx: Fx<A, E, R>,
|
|
1455
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
1456
|
+
): Fx<A, E | E2, R | R2> {
|
|
1458
1457
|
return DropAfterEffect.make(fx, f)
|
|
1459
1458
|
}
|
|
1460
1459
|
|
|
1461
|
-
class DropAfterEffect<
|
|
1462
|
-
constructor(readonly i0: Fx<
|
|
1460
|
+
class DropAfterEffect<A, E, R, R2, E2> extends FxBase<A, E | E2, R | R2> {
|
|
1461
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: (a: A) => Effect.Effect<boolean, E2, R2>) {
|
|
1463
1462
|
super()
|
|
1464
1463
|
}
|
|
1465
1464
|
|
|
1466
|
-
run<R3>(sink: Sink.Sink<
|
|
1465
|
+
run<R3>(sink: Sink.Sink<A, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
1467
1466
|
return this.i0.run(Sink.dropAfterEffect(sink, this.i1))
|
|
1468
1467
|
}
|
|
1469
1468
|
|
|
1470
|
-
static make<
|
|
1471
|
-
fx: Fx<
|
|
1472
|
-
f: (a: A) => Effect.Effect<
|
|
1473
|
-
): Fx<
|
|
1469
|
+
static make<A, E, R, R2, E2>(
|
|
1470
|
+
fx: Fx<A, E, R>,
|
|
1471
|
+
f: (a: A) => Effect.Effect<boolean, E2, R2>
|
|
1472
|
+
): Fx<A, E | E2, R | R2> {
|
|
1474
1473
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1475
1474
|
else {
|
|
1476
1475
|
return new DropAfterEffect(fx, f)
|
|
@@ -1478,33 +1477,33 @@ class DropAfterEffect<R, E, A, R2, E2> extends FxBase<R | R2, E | E2, A> {
|
|
|
1478
1477
|
}
|
|
1479
1478
|
}
|
|
1480
1479
|
|
|
1481
|
-
export function during<
|
|
1482
|
-
fx: Fx<
|
|
1483
|
-
window: Fx<
|
|
1484
|
-
): Fx<
|
|
1480
|
+
export function during<A, E, R, B, E2, R2, E3, R3>(
|
|
1481
|
+
fx: Fx<A, E, R>,
|
|
1482
|
+
window: Fx<Fx<B, E3, R3>, E2, R2>
|
|
1483
|
+
): Fx<A, E | E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
1485
1484
|
return During.make(fx, window)
|
|
1486
1485
|
}
|
|
1487
1486
|
|
|
1488
|
-
export function since<
|
|
1489
|
-
fx: Fx<
|
|
1490
|
-
window: Fx<
|
|
1491
|
-
): Fx<R | R2 | Scope.Scope
|
|
1487
|
+
export function since<A, E, R, B, E2, R2>(
|
|
1488
|
+
fx: Fx<A, E, R>,
|
|
1489
|
+
window: Fx<B, E2, R2>
|
|
1490
|
+
): Fx<A, E | E2, R | R2 | Scope.Scope> {
|
|
1492
1491
|
return During.make(fx, map(window, () => never))
|
|
1493
1492
|
}
|
|
1494
1493
|
|
|
1495
|
-
export function until<
|
|
1496
|
-
fx: Fx<
|
|
1497
|
-
window: Fx<
|
|
1498
|
-
): Fx<R | R2 | Scope.Scope
|
|
1494
|
+
export function until<A, E, R, B, E2, R2>(
|
|
1495
|
+
fx: Fx<A, E, R>,
|
|
1496
|
+
window: Fx<B, E2, R2>
|
|
1497
|
+
): Fx<A, E | E2, R | R2 | Scope.Scope> {
|
|
1499
1498
|
return During.make(fx, succeed(window))
|
|
1500
1499
|
}
|
|
1501
1500
|
|
|
1502
|
-
class During<
|
|
1503
|
-
constructor(readonly i0: Fx<
|
|
1501
|
+
class During<A, E, R, B, E2, R2, E3, R3> extends FxBase<A, E | E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
1502
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Fx<Fx<B, E3, R3>, E2, R2>) {
|
|
1504
1503
|
super()
|
|
1505
1504
|
}
|
|
1506
1505
|
|
|
1507
|
-
run<R4>(sink: Sink.Sink<
|
|
1506
|
+
run<R4>(sink: Sink.Sink<A, E | E2 | E3, R4>): Effect.Effect<unknown, never, R | R2 | R3 | R4 | Scope.Scope> {
|
|
1508
1507
|
return withScopedFork(
|
|
1509
1508
|
(fork) =>
|
|
1510
1509
|
Sink.withEarlyExit(sink, (s) => {
|
|
@@ -1538,10 +1537,10 @@ class During<R, E, A, R2, E2, R3, E3, B> extends FxBase<R | R2 | R3 | Scope.Scop
|
|
|
1538
1537
|
)
|
|
1539
1538
|
}
|
|
1540
1539
|
|
|
1541
|
-
static make<
|
|
1542
|
-
fx: Fx<
|
|
1543
|
-
window: Fx<
|
|
1544
|
-
): Fx<
|
|
1540
|
+
static make<A, E, R, B, E2, R2, E3, R3>(
|
|
1541
|
+
fx: Fx<A, E, R>,
|
|
1542
|
+
window: Fx<Fx<B, E3, R3>, E2, R2>
|
|
1543
|
+
): Fx<A, E | E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
1545
1544
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1546
1545
|
else {
|
|
1547
1546
|
return new During(fx, window)
|
|
@@ -1549,160 +1548,160 @@ class During<R, E, A, R2, E2, R3, E3, B> extends FxBase<R | R2 | R3 | Scope.Scop
|
|
|
1549
1548
|
}
|
|
1550
1549
|
}
|
|
1551
1550
|
|
|
1552
|
-
export function middleware<
|
|
1553
|
-
fx: Fx<
|
|
1554
|
-
effect: (effect: Effect.Effect<
|
|
1555
|
-
sink?: (sink: Sink.Sink<
|
|
1556
|
-
): Fx<
|
|
1551
|
+
export function middleware<A, E, R, R3>(
|
|
1552
|
+
fx: Fx<A, E, R>,
|
|
1553
|
+
effect: (effect: Effect.Effect<unknown, never, R>) => Effect.Effect<unknown, never, R3>,
|
|
1554
|
+
sink?: (sink: Sink.Sink<A, E>) => Sink.Sink<A, E, R>
|
|
1555
|
+
): Fx<A, E, R3> {
|
|
1557
1556
|
return new Middleware(fx, effect, sink)
|
|
1558
1557
|
}
|
|
1559
1558
|
|
|
1560
|
-
export function onExit<
|
|
1561
|
-
fx: Fx<
|
|
1562
|
-
f: (exit: Exit.Exit<
|
|
1563
|
-
): Fx<R | R2
|
|
1559
|
+
export function onExit<A, E, R, R2>(
|
|
1560
|
+
fx: Fx<A, E, R>,
|
|
1561
|
+
f: (exit: Exit.Exit<unknown>) => Effect.Effect<unknown, never, R2>
|
|
1562
|
+
): Fx<A, E, R | R2> {
|
|
1564
1563
|
return middleware(fx, Effect.onExit(f))
|
|
1565
1564
|
}
|
|
1566
1565
|
|
|
1567
|
-
export function onInterrupt<
|
|
1568
|
-
fx: Fx<
|
|
1569
|
-
f: (interruptors: HashSet.HashSet<FiberId.FiberId>) => Effect.Effect<
|
|
1570
|
-
): Fx<R | R2
|
|
1566
|
+
export function onInterrupt<A, E, R, R2>(
|
|
1567
|
+
fx: Fx<A, E, R>,
|
|
1568
|
+
f: (interruptors: HashSet.HashSet<FiberId.FiberId>) => Effect.Effect<unknown, never, R2>
|
|
1569
|
+
): Fx<A, E, R | R2> {
|
|
1571
1570
|
return middleware(fx, Effect.onInterrupt(f))
|
|
1572
1571
|
}
|
|
1573
1572
|
|
|
1574
|
-
export function onError<
|
|
1575
|
-
fx: Fx<
|
|
1576
|
-
f: (cause: Cause.Cause<never>) => Effect.Effect<
|
|
1577
|
-
): Fx<R | R2
|
|
1573
|
+
export function onError<A, E, R, R2>(
|
|
1574
|
+
fx: Fx<A, E, R>,
|
|
1575
|
+
f: (cause: Cause.Cause<never>) => Effect.Effect<unknown, never, R2>
|
|
1576
|
+
): Fx<A, E, R | R2> {
|
|
1578
1577
|
return middleware(fx, Effect.onError(f))
|
|
1579
1578
|
}
|
|
1580
1579
|
|
|
1581
|
-
export const scoped = <
|
|
1580
|
+
export const scoped = <A, E, R>(fx: Fx<A, E, R>): Fx<A, E, Exclude<R, Scope.Scope>> => middleware(fx, Effect.scoped)
|
|
1582
1581
|
|
|
1583
|
-
export function annotateLogs<
|
|
1584
|
-
fx: Fx<
|
|
1582
|
+
export function annotateLogs<A, E, R>(
|
|
1583
|
+
fx: Fx<A, E, R>,
|
|
1585
1584
|
key: string | Record<string, unknown>,
|
|
1586
1585
|
value?: unknown
|
|
1587
|
-
): Fx<
|
|
1586
|
+
): Fx<A, E, R> {
|
|
1588
1587
|
return middleware(fx, (effect) => Effect.annotateLogs(effect, key as string, value as unknown))
|
|
1589
1588
|
}
|
|
1590
1589
|
|
|
1591
|
-
export function annotateSpans<
|
|
1592
|
-
fx: Fx<
|
|
1590
|
+
export function annotateSpans<A, E, R>(
|
|
1591
|
+
fx: Fx<A, E, R>,
|
|
1593
1592
|
key: string | Record<string, unknown>,
|
|
1594
1593
|
value?: unknown
|
|
1595
|
-
): Fx<
|
|
1594
|
+
): Fx<A, E, R> {
|
|
1596
1595
|
return middleware(fx, (effect) => Effect.annotateSpans(effect, key as string, value as unknown))
|
|
1597
1596
|
}
|
|
1598
1597
|
|
|
1599
|
-
export const interruptible = <
|
|
1598
|
+
export const interruptible = <A, E, R>(fx: Fx<A, E, R>): Fx<A, E, R> => middleware(fx, Effect.interruptible)
|
|
1600
1599
|
|
|
1601
|
-
export const uninterruptible = <
|
|
1600
|
+
export const uninterruptible = <A, E, R>(fx: Fx<A, E, R>): Fx<A, E, R> => middleware(fx, Effect.uninterruptible)
|
|
1602
1601
|
|
|
1603
|
-
export function locally<
|
|
1604
|
-
use: Fx<
|
|
1602
|
+
export function locally<B, E, R, A>(
|
|
1603
|
+
use: Fx<B, E, R>,
|
|
1605
1604
|
self: FiberRef.FiberRef<A>,
|
|
1606
1605
|
value: A
|
|
1607
|
-
): Fx<
|
|
1606
|
+
): Fx<B, E, R> {
|
|
1608
1607
|
return middleware(use, (effect) => Effect.locally(effect, self, value))
|
|
1609
1608
|
}
|
|
1610
1609
|
|
|
1611
|
-
export function locallyWith<
|
|
1612
|
-
use: Fx<
|
|
1610
|
+
export function locallyWith<B, E, R, A>(
|
|
1611
|
+
use: Fx<B, E, R>,
|
|
1613
1612
|
self: FiberRef.FiberRef<A>,
|
|
1614
1613
|
f: (a: A) => A
|
|
1615
|
-
): Fx<
|
|
1614
|
+
): Fx<B, E, R> {
|
|
1616
1615
|
return middleware(use, (effect) => Effect.locallyWith(effect, self, f))
|
|
1617
1616
|
}
|
|
1618
1617
|
|
|
1619
|
-
export function withTracerTiming<
|
|
1620
|
-
fx: Fx<
|
|
1618
|
+
export function withTracerTiming<A, E, R>(
|
|
1619
|
+
fx: Fx<A, E, R>,
|
|
1621
1620
|
enabled: boolean
|
|
1622
|
-
): Fx<
|
|
1621
|
+
): Fx<A, E, R> {
|
|
1623
1622
|
return middleware(fx, (effect) => Effect.withTracerTiming(effect, enabled))
|
|
1624
1623
|
}
|
|
1625
1624
|
|
|
1626
|
-
export function withConcurrency<
|
|
1627
|
-
fx: Fx<
|
|
1625
|
+
export function withConcurrency<A, E, R>(
|
|
1626
|
+
fx: Fx<A, E, R>,
|
|
1628
1627
|
concurrency: number | "unbounded"
|
|
1629
|
-
): Fx<
|
|
1628
|
+
): Fx<A, E, R> {
|
|
1630
1629
|
return middleware(fx, (effect) => Effect.withConcurrency(effect, concurrency))
|
|
1631
1630
|
}
|
|
1632
1631
|
|
|
1633
|
-
export function withConfigProvider<
|
|
1634
|
-
fx: Fx<
|
|
1632
|
+
export function withConfigProvider<A, E, R>(
|
|
1633
|
+
fx: Fx<A, E, R>,
|
|
1635
1634
|
configProvider: ConfigProvider.ConfigProvider
|
|
1636
|
-
): Fx<
|
|
1635
|
+
): Fx<A, E, R> {
|
|
1637
1636
|
return middleware(fx, (effect) => Effect.withConfigProvider(effect, configProvider))
|
|
1638
1637
|
}
|
|
1639
1638
|
|
|
1640
|
-
export function withLogSpan<
|
|
1641
|
-
fx: Fx<
|
|
1639
|
+
export function withLogSpan<A, E, R>(
|
|
1640
|
+
fx: Fx<A, E, R>,
|
|
1642
1641
|
span: string
|
|
1643
|
-
): Fx<
|
|
1642
|
+
): Fx<A, E, R> {
|
|
1644
1643
|
return middleware(fx, (effect) => Effect.withLogSpan(effect, span))
|
|
1645
1644
|
}
|
|
1646
1645
|
|
|
1647
|
-
export function withMaxOpsBeforeYield<
|
|
1648
|
-
fx: Fx<
|
|
1646
|
+
export function withMaxOpsBeforeYield<A, E, R>(
|
|
1647
|
+
fx: Fx<A, E, R>,
|
|
1649
1648
|
maxOps: number
|
|
1650
|
-
): Fx<
|
|
1649
|
+
): Fx<A, E, R> {
|
|
1651
1650
|
return middleware(fx, (effect) => Effect.withMaxOpsBeforeYield(effect, maxOps))
|
|
1652
1651
|
}
|
|
1653
1652
|
|
|
1654
|
-
export function withParentSpan<
|
|
1655
|
-
fx: Fx<
|
|
1653
|
+
export function withParentSpan<A, E, R>(
|
|
1654
|
+
fx: Fx<A, E, R>,
|
|
1656
1655
|
parentSpan: Tracer.ParentSpan
|
|
1657
|
-
): Fx<
|
|
1656
|
+
): Fx<A, E, R> {
|
|
1658
1657
|
return middleware(fx, (effect) => Effect.withParentSpan(effect, parentSpan))
|
|
1659
1658
|
}
|
|
1660
1659
|
|
|
1661
|
-
export function withRequestBatching<
|
|
1662
|
-
fx: Fx<
|
|
1660
|
+
export function withRequestBatching<A, E, R>(
|
|
1661
|
+
fx: Fx<A, E, R>,
|
|
1663
1662
|
requestBatching: boolean
|
|
1664
|
-
): Fx<
|
|
1663
|
+
): Fx<A, E, R> {
|
|
1665
1664
|
return middleware(fx, (effect) => Effect.withRequestBatching(effect, requestBatching))
|
|
1666
1665
|
}
|
|
1667
1666
|
|
|
1668
|
-
export function withRequestCache<
|
|
1669
|
-
fx: Fx<
|
|
1667
|
+
export function withRequestCache<A, E, R>(
|
|
1668
|
+
fx: Fx<A, E, R>,
|
|
1670
1669
|
cache: Request.Cache
|
|
1671
|
-
): Fx<
|
|
1670
|
+
): Fx<A, E, R> {
|
|
1672
1671
|
return middleware(fx, (effect) => Effect.withRequestCache(effect, cache))
|
|
1673
1672
|
}
|
|
1674
1673
|
|
|
1675
|
-
export function withRequestCaching<
|
|
1676
|
-
fx: Fx<
|
|
1674
|
+
export function withRequestCaching<A, E, R>(
|
|
1675
|
+
fx: Fx<A, E, R>,
|
|
1677
1676
|
requestCaching: boolean
|
|
1678
|
-
): Fx<
|
|
1677
|
+
): Fx<A, E, R> {
|
|
1679
1678
|
return middleware(fx, (effect) => Effect.withRequestCaching(effect, requestCaching))
|
|
1680
1679
|
}
|
|
1681
1680
|
|
|
1682
|
-
export function withScheduler<
|
|
1683
|
-
fx: Fx<
|
|
1681
|
+
export function withScheduler<A, E, R>(
|
|
1682
|
+
fx: Fx<A, E, R>,
|
|
1684
1683
|
scheduler: Scheduler.Scheduler
|
|
1685
|
-
): Fx<
|
|
1684
|
+
): Fx<A, E, R> {
|
|
1686
1685
|
return middleware(fx, (effect) => Effect.withScheduler(effect, scheduler))
|
|
1687
1686
|
}
|
|
1688
1687
|
|
|
1689
|
-
export function withTracer<
|
|
1690
|
-
fx: Fx<
|
|
1688
|
+
export function withTracer<A, E, R>(
|
|
1689
|
+
fx: Fx<A, E, R>,
|
|
1691
1690
|
tracer: Tracer.Tracer
|
|
1692
|
-
): Fx<
|
|
1691
|
+
): Fx<A, E, R> {
|
|
1693
1692
|
return middleware(fx, (effect) => Effect.withTracer(effect, tracer))
|
|
1694
1693
|
}
|
|
1695
1694
|
|
|
1696
|
-
class Middleware<
|
|
1695
|
+
class Middleware<A, E, R, R2> extends FxBase<A, E, R2> {
|
|
1697
1696
|
constructor(
|
|
1698
|
-
readonly i0: Fx<
|
|
1699
|
-
readonly i1: (effect: Effect.Effect<
|
|
1700
|
-
readonly i2?: (sink: Sink.Sink<
|
|
1697
|
+
readonly i0: Fx<A, E, R>,
|
|
1698
|
+
readonly i1: (effect: Effect.Effect<unknown, never, R>) => Effect.Effect<unknown, never, R2>,
|
|
1699
|
+
readonly i2?: (sink: Sink.Sink<A, E>) => Sink.Sink<A, E, R>
|
|
1701
1700
|
) {
|
|
1702
1701
|
super()
|
|
1703
1702
|
}
|
|
1704
1703
|
|
|
1705
|
-
run<R3>(sink: Sink.Sink<
|
|
1704
|
+
run<R3>(sink: Sink.Sink<A, E, R3>): Effect.Effect<unknown, never, R2 | R3> {
|
|
1706
1705
|
return Effect.contextWithEffect((ctx) => {
|
|
1707
1706
|
const s = Sink.provide(sink, ctx)
|
|
1708
1707
|
|
|
@@ -1711,24 +1710,24 @@ class Middleware<R, E, A, R2> extends FxBase<R2, E, A> {
|
|
|
1711
1710
|
}
|
|
1712
1711
|
}
|
|
1713
1712
|
|
|
1714
|
-
export function acquireUseRelease<
|
|
1715
|
-
acquire: Effect.Effect<
|
|
1716
|
-
use: (a: A) => Fx<
|
|
1717
|
-
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<
|
|
1718
|
-
): Fx<
|
|
1713
|
+
export function acquireUseRelease<A, E, R, B, E2, R2, C, E3, R3>(
|
|
1714
|
+
acquire: Effect.Effect<A, E, R>,
|
|
1715
|
+
use: (a: A) => Fx<B, E2, R2>,
|
|
1716
|
+
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<C, E3, R3>
|
|
1717
|
+
): Fx<B, E | E2 | E3, R | R2 | R3> {
|
|
1719
1718
|
return new AcquireUseRelease(acquire, use, release)
|
|
1720
1719
|
}
|
|
1721
1720
|
|
|
1722
|
-
class AcquireUseRelease<
|
|
1721
|
+
class AcquireUseRelease<A, E, R, B, E2, R2, C, E3, R3> extends FxBase<B, E | E2 | E3, R | R2 | R3> {
|
|
1723
1722
|
constructor(
|
|
1724
|
-
readonly acquire: Effect.Effect<
|
|
1725
|
-
readonly use: (a: A) => Fx<
|
|
1726
|
-
readonly release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<
|
|
1723
|
+
readonly acquire: Effect.Effect<A, E, R>,
|
|
1724
|
+
readonly use: (a: A) => Fx<B, E2, R2>,
|
|
1725
|
+
readonly release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<C, E3, R3>
|
|
1727
1726
|
) {
|
|
1728
1727
|
super()
|
|
1729
1728
|
}
|
|
1730
1729
|
|
|
1731
|
-
run<R4>(sink: Sink.Sink<
|
|
1730
|
+
run<R4>(sink: Sink.Sink<B, E | E2 | E3, R4>): Effect.Effect<unknown, never, R | R2 | R3 | R4> {
|
|
1732
1731
|
return Effect.catchAllCause(
|
|
1733
1732
|
Effect.acquireUseRelease(
|
|
1734
1733
|
this.acquire,
|
|
@@ -1740,8 +1739,8 @@ class AcquireUseRelease<R, E, A, R2, E2, B, R3, E3, C> extends FxBase<R | R2 | R
|
|
|
1740
1739
|
}
|
|
1741
1740
|
}
|
|
1742
1741
|
|
|
1743
|
-
export function withSpan<
|
|
1744
|
-
self: Fx<
|
|
1742
|
+
export function withSpan<A, E, R>(
|
|
1743
|
+
self: Fx<A, E, R>,
|
|
1745
1744
|
name: string,
|
|
1746
1745
|
options: {
|
|
1747
1746
|
readonly attributes?: Record<string, unknown>
|
|
@@ -1750,7 +1749,7 @@ export function withSpan<R, E, A>(
|
|
|
1750
1749
|
readonly root?: boolean
|
|
1751
1750
|
readonly context?: Context.Context<never>
|
|
1752
1751
|
} = {}
|
|
1753
|
-
): Fx<
|
|
1752
|
+
): Fx<A, E, R> {
|
|
1754
1753
|
return acquireUseRelease(
|
|
1755
1754
|
Effect.flatMap(
|
|
1756
1755
|
Effect.optionFromOptional(Effect.currentSpan),
|
|
@@ -1766,58 +1765,58 @@ export function withSpan<R, E, A>(
|
|
|
1766
1765
|
)
|
|
1767
1766
|
}
|
|
1768
1767
|
|
|
1769
|
-
export function provideContext<
|
|
1770
|
-
fx: Fx<
|
|
1768
|
+
export function provideContext<A, E, R, R2>(
|
|
1769
|
+
fx: Fx<A, E, R>,
|
|
1771
1770
|
context: Context.Context<R2>
|
|
1772
|
-
): Fx<Exclude<R, R2
|
|
1771
|
+
): Fx<A, E, Exclude<R, R2>> {
|
|
1773
1772
|
return ProvideFx.make(fx, Provide.ProvideContext(context))
|
|
1774
1773
|
}
|
|
1775
1774
|
|
|
1776
|
-
export function provideLayer<
|
|
1777
|
-
fx: Fx<
|
|
1778
|
-
layer: Layer.Layer<
|
|
1779
|
-
): Fx<R2 | Exclude<R, S
|
|
1775
|
+
export function provideLayer<A, E, R, S, E2, R2>(
|
|
1776
|
+
fx: Fx<A, E, R>,
|
|
1777
|
+
layer: Layer.Layer<S, E2, R2>
|
|
1778
|
+
): Fx<A, E | E2, R2 | Exclude<R, S>> {
|
|
1780
1779
|
return ProvideFx.make(fx, Provide.ProvideLayer(layer))
|
|
1781
1780
|
}
|
|
1782
1781
|
|
|
1783
|
-
export function provideRuntime<
|
|
1784
|
-
fx: Fx<
|
|
1782
|
+
export function provideRuntime<A, E, R, R2>(
|
|
1783
|
+
fx: Fx<A, E, R>,
|
|
1785
1784
|
runtime: Runtime.Runtime<R2>
|
|
1786
|
-
): Fx<Exclude<R, R2
|
|
1785
|
+
): Fx<A, E, Exclude<R, R2>> {
|
|
1787
1786
|
return ProvideFx.make(fx, Provide.ProvideRuntime(runtime))
|
|
1788
1787
|
}
|
|
1789
1788
|
|
|
1790
|
-
export function provideService<
|
|
1791
|
-
fx: Fx<
|
|
1789
|
+
export function provideService<A, E, R, I, S>(
|
|
1790
|
+
fx: Fx<A, E, R>,
|
|
1792
1791
|
service: Context.Tag<I, S>,
|
|
1793
1792
|
instance: S
|
|
1794
|
-
): Fx<Exclude<R, I
|
|
1793
|
+
): Fx<A, E, Exclude<R, I>> {
|
|
1795
1794
|
return ProvideFx.make(fx, Provide.ProvideService(service, instance))
|
|
1796
1795
|
}
|
|
1797
1796
|
|
|
1798
|
-
export function provideServiceEffect<
|
|
1799
|
-
fx: Fx<
|
|
1797
|
+
export function provideServiceEffect<A, E, R, I, S, R2, E2>(
|
|
1798
|
+
fx: Fx<A, E, R>,
|
|
1800
1799
|
service: Context.Tag<I, S>,
|
|
1801
|
-
instance: Effect.Effect<
|
|
1802
|
-
): Fx<Exclude<R, I> | R2
|
|
1800
|
+
instance: Effect.Effect<S, E2, R2>
|
|
1801
|
+
): Fx<A, E | E2, Exclude<R, I> | R2> {
|
|
1803
1802
|
return ProvideFx.make(fx, Provide.ProvideServiceEffect(service, instance))
|
|
1804
1803
|
}
|
|
1805
1804
|
|
|
1806
|
-
export function provide<
|
|
1807
|
-
fx: Fx<
|
|
1808
|
-
provide: Layer.Layer<
|
|
1809
|
-
): Fx<Exclude<R, S> | R2
|
|
1810
|
-
if (Layer.isLayer(provide)) return provideLayer(fx, provide as Layer.Layer<
|
|
1805
|
+
export function provide<A, E, R, R2 = never, E2 = never, S = never>(
|
|
1806
|
+
fx: Fx<A, E, R>,
|
|
1807
|
+
provide: Layer.Layer<S, E2, R2> | Context.Context<S> | Runtime.Runtime<S>
|
|
1808
|
+
): Fx<A, E | E2, Exclude<R, S> | R2> {
|
|
1809
|
+
if (Layer.isLayer(provide)) return provideLayer(fx, provide as Layer.Layer<S, E2, R2>)
|
|
1811
1810
|
else if (Context.isContext(provide)) return provideContext(fx, provide as Context.Context<S>)
|
|
1812
1811
|
else return provideRuntime(fx, provide as Runtime.Runtime<S>)
|
|
1813
1812
|
}
|
|
1814
1813
|
|
|
1815
|
-
class ProvideFx<
|
|
1816
|
-
constructor(readonly i0: Fx<
|
|
1814
|
+
class ProvideFx<A, E, R, S, E2, R2> extends FxBase<A, E | E2, R2 | Exclude<R, S>> {
|
|
1815
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Provide.Provide<S, E2, R2>) {
|
|
1817
1816
|
super()
|
|
1818
1817
|
}
|
|
1819
1818
|
|
|
1820
|
-
run<R3>(sink: Sink.Sink<
|
|
1819
|
+
run<R3>(sink: Sink.Sink<A, E | E2, R3>): Effect.Effect<unknown, never, R2 | R3 | Exclude<R, S>> {
|
|
1821
1820
|
return Effect.acquireUseRelease(
|
|
1822
1821
|
Scope.make(),
|
|
1823
1822
|
(scope) =>
|
|
@@ -1829,10 +1828,10 @@ class ProvideFx<R, E, A, R2, E2, S> extends FxBase<R2 | Exclude<R, S>, E | E2, A
|
|
|
1829
1828
|
)
|
|
1830
1829
|
}
|
|
1831
1830
|
|
|
1832
|
-
static make<
|
|
1833
|
-
fx: Fx<
|
|
1834
|
-
provide: Provide.Provide<
|
|
1835
|
-
): Fx<Exclude<R, S> | R2
|
|
1831
|
+
static make<A, E, R, S, E2, R2>(
|
|
1832
|
+
fx: Fx<A, E, R>,
|
|
1833
|
+
provide: Provide.Provide<S, E2, R2>
|
|
1834
|
+
): Fx<A, E | E2, Exclude<R, S> | R2> {
|
|
1836
1835
|
if (isEmpty(fx) || isNever(fx)) return fx
|
|
1837
1836
|
else if (isProvideFx(fx)) {
|
|
1838
1837
|
return new ProvideFx(fx.i0, Provide.merge(fx.i1, provide))
|
|
@@ -1842,35 +1841,35 @@ class ProvideFx<R, E, A, R2, E2, S> extends FxBase<R2 | Exclude<R, S>, E | E2, A
|
|
|
1842
1841
|
}
|
|
1843
1842
|
}
|
|
1844
1843
|
|
|
1845
|
-
function isProvideFx<
|
|
1844
|
+
function isProvideFx<A, E, R>(u: Fx<A, E, R>): u is ProvideFx<A, E, R, R, E, never> {
|
|
1846
1845
|
return u.constructor === ProvideFx
|
|
1847
1846
|
}
|
|
1848
1847
|
|
|
1849
|
-
export function mapCause<
|
|
1850
|
-
fx: Fx<
|
|
1848
|
+
export function mapCause<A, E, R, E2>(
|
|
1849
|
+
fx: Fx<A, E, R>,
|
|
1851
1850
|
f: (cause: Cause.Cause<E>) => Cause.Cause<E2>
|
|
1852
|
-
): Fx<
|
|
1851
|
+
): Fx<A, E2, R> {
|
|
1853
1852
|
return new TransformerCause(fx, SyncOp.Map(f))
|
|
1854
1853
|
}
|
|
1855
1854
|
|
|
1856
|
-
export function mapError<
|
|
1857
|
-
fx: Fx<
|
|
1855
|
+
export function mapError<A, E, R, E2>(
|
|
1856
|
+
fx: Fx<A, E, R>,
|
|
1858
1857
|
f: (e: E) => E2
|
|
1859
|
-
): Fx<
|
|
1858
|
+
): Fx<A, E2, R> {
|
|
1860
1859
|
return mapCause(fx, Cause.map(f))
|
|
1861
1860
|
}
|
|
1862
1861
|
|
|
1863
|
-
export function filterCause<
|
|
1864
|
-
fx: Fx<
|
|
1862
|
+
export function filterCause<A, E, R>(
|
|
1863
|
+
fx: Fx<A, E, R>,
|
|
1865
1864
|
f: (cause: Cause.Cause<E>) => boolean
|
|
1866
|
-
): Fx<
|
|
1865
|
+
): Fx<A, E, R> {
|
|
1867
1866
|
return new TransformerCause(fx, SyncOp.Filter(f))
|
|
1868
1867
|
}
|
|
1869
1868
|
|
|
1870
|
-
export function filterError<
|
|
1871
|
-
fx: Fx<
|
|
1869
|
+
export function filterError<A, E, R>(
|
|
1870
|
+
fx: Fx<A, E, R>,
|
|
1872
1871
|
f: (e: E) => boolean
|
|
1873
|
-
): Fx<
|
|
1872
|
+
): Fx<A, E, R> {
|
|
1874
1873
|
return filterCause(fx, (cause) =>
|
|
1875
1874
|
Option.match(Cause.failureOption(cause), {
|
|
1876
1875
|
onNone: constTrue,
|
|
@@ -1878,17 +1877,17 @@ export function filterError<R, E, A>(
|
|
|
1878
1877
|
}))
|
|
1879
1878
|
}
|
|
1880
1879
|
|
|
1881
|
-
export function filterMapCause<
|
|
1882
|
-
fx: Fx<
|
|
1880
|
+
export function filterMapCause<A, E, R, E2>(
|
|
1881
|
+
fx: Fx<A, E, R>,
|
|
1883
1882
|
f: (cause: Cause.Cause<E>) => Option.Option<Cause.Cause<E2>>
|
|
1884
|
-
): Fx<
|
|
1883
|
+
): Fx<A, E2, R> {
|
|
1885
1884
|
return new TransformerCause(fx, SyncOp.FilterMap(f))
|
|
1886
1885
|
}
|
|
1887
1886
|
|
|
1888
|
-
export function filterMapError<
|
|
1889
|
-
fx: Fx<
|
|
1887
|
+
export function filterMapError<A, E, R, E2>(
|
|
1888
|
+
fx: Fx<A, E, R>,
|
|
1890
1889
|
f: (e: E) => Option.Option<E2>
|
|
1891
|
-
): Fx<
|
|
1890
|
+
): Fx<A, E2, R> {
|
|
1892
1891
|
return filterMapCause(fx, (cause) =>
|
|
1893
1892
|
Either.match(Cause.failureOrCause(cause), {
|
|
1894
1893
|
onLeft: (e) => Option.map(f(e), Cause.fail),
|
|
@@ -1896,17 +1895,17 @@ export function filterMapError<R, E, A, E2>(
|
|
|
1896
1895
|
}))
|
|
1897
1896
|
}
|
|
1898
1897
|
|
|
1899
|
-
export function mapCauseEffect<
|
|
1900
|
-
fx: Fx<
|
|
1901
|
-
f: (cause: Cause.Cause<E>) => Effect.Effect<
|
|
1902
|
-
): Fx<
|
|
1898
|
+
export function mapCauseEffect<A, E, R, R2, E2, E3>(
|
|
1899
|
+
fx: Fx<A, E, R>,
|
|
1900
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<Cause.Cause<E3>, E2, R2>
|
|
1901
|
+
): Fx<A, E2 | E3, R | R2> {
|
|
1903
1902
|
return new TransformerCause(fx, EffectOp.MapEffect(f))
|
|
1904
1903
|
}
|
|
1905
1904
|
|
|
1906
|
-
export function mapErrorEffect<
|
|
1907
|
-
fx: Fx<
|
|
1908
|
-
f: (e: E) => Effect.Effect<
|
|
1909
|
-
): Fx<
|
|
1905
|
+
export function mapErrorEffect<A, E, R, R2, E2, E3>(
|
|
1906
|
+
fx: Fx<A, E, R>,
|
|
1907
|
+
f: (e: E) => Effect.Effect<E3, E2, R2>
|
|
1908
|
+
): Fx<A, E2 | E3, R | R2> {
|
|
1910
1909
|
return mapCauseEffect(fx, (cause) =>
|
|
1911
1910
|
Either.match(Cause.failureOrCause(cause), {
|
|
1912
1911
|
onLeft: (e) => Effect.map(f(e), Cause.fail),
|
|
@@ -1914,17 +1913,17 @@ export function mapErrorEffect<R, E, A, R2, E2, E3>(
|
|
|
1914
1913
|
}))
|
|
1915
1914
|
}
|
|
1916
1915
|
|
|
1917
|
-
export function filterCauseEffect<
|
|
1918
|
-
fx: Fx<
|
|
1919
|
-
f: (cause: Cause.Cause<E>) => Effect.Effect<
|
|
1920
|
-
): Fx<R | R2
|
|
1916
|
+
export function filterCauseEffect<A, E, R, R2, E2>(
|
|
1917
|
+
fx: Fx<A, E, R>,
|
|
1918
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<boolean, E2, R2>
|
|
1919
|
+
): Fx<A, E2, R | R2> {
|
|
1921
1920
|
return new TransformerCause(fx, EffectOp.FilterEffect(f))
|
|
1922
1921
|
}
|
|
1923
1922
|
|
|
1924
|
-
export function filterErrorEffect<
|
|
1925
|
-
fx: Fx<
|
|
1926
|
-
f: (e: E) => Effect.Effect<
|
|
1927
|
-
): Fx<R | R2
|
|
1923
|
+
export function filterErrorEffect<A, E, R, R2, E2>(
|
|
1924
|
+
fx: Fx<A, E, R>,
|
|
1925
|
+
f: (e: E) => Effect.Effect<boolean, E2, R2>
|
|
1926
|
+
): Fx<A, E2, R | R2> {
|
|
1928
1927
|
return filterCauseEffect(fx, (cause) =>
|
|
1929
1928
|
Either.match(Cause.failureOrCause(cause), {
|
|
1930
1929
|
onLeft: f,
|
|
@@ -1932,17 +1931,17 @@ export function filterErrorEffect<R, E, A, R2, E2>(
|
|
|
1932
1931
|
}))
|
|
1933
1932
|
}
|
|
1934
1933
|
|
|
1935
|
-
export function filterMapCauseEffect<
|
|
1936
|
-
fx: Fx<
|
|
1937
|
-
f: (cause: Cause.Cause<E>) => Effect.Effect<
|
|
1938
|
-
): Fx<
|
|
1934
|
+
export function filterMapCauseEffect<A, E, R, R2, E2, E3>(
|
|
1935
|
+
fx: Fx<A, E, R>,
|
|
1936
|
+
f: (cause: Cause.Cause<E>) => Effect.Effect<Option.Option<Cause.Cause<E3>>, E2, R2>
|
|
1937
|
+
): Fx<A, E2 | E3, R | R2> {
|
|
1939
1938
|
return new TransformerCause(fx, EffectOp.FilterMapEffect(f))
|
|
1940
1939
|
}
|
|
1941
1940
|
|
|
1942
|
-
export function filterMapErrorEffect<
|
|
1943
|
-
fx: Fx<
|
|
1944
|
-
f: (e: E) => Effect.Effect<
|
|
1945
|
-
): Fx<
|
|
1941
|
+
export function filterMapErrorEffect<A, E, R, R2, E2, E3>(
|
|
1942
|
+
fx: Fx<A, E, R>,
|
|
1943
|
+
f: (e: E) => Effect.Effect<Option.Option<E3>, E2, R2>
|
|
1944
|
+
): Fx<A, E2 | E3, R | R2> {
|
|
1946
1945
|
return filterMapCauseEffect(fx, (cause) =>
|
|
1947
1946
|
Either.match(Cause.failureOrCause(cause), {
|
|
1948
1947
|
onLeft: (e) => Effect.map(f(e), Option.map(Cause.fail)),
|
|
@@ -1950,19 +1949,19 @@ export function filterMapErrorEffect<R, E, A, R2, E2, E3>(
|
|
|
1950
1949
|
}))
|
|
1951
1950
|
}
|
|
1952
1951
|
|
|
1953
|
-
export function loopCause<
|
|
1954
|
-
fx: Fx<
|
|
1952
|
+
export function loopCause<A, E, R, B, C>(
|
|
1953
|
+
fx: Fx<A, E, R>,
|
|
1955
1954
|
seed: B,
|
|
1956
1955
|
f: (b: B, cause: Cause.Cause<E>) => readonly [Cause.Cause<C>, B]
|
|
1957
|
-
): Fx<
|
|
1956
|
+
): Fx<A, C, R> {
|
|
1958
1957
|
return new TransformerCause(fx, SyncLoopOp.LoopOperator(seed, f))
|
|
1959
1958
|
}
|
|
1960
1959
|
|
|
1961
|
-
export function loopError<
|
|
1962
|
-
fx: Fx<
|
|
1960
|
+
export function loopError<A, E, R, B, C>(
|
|
1961
|
+
fx: Fx<A, E, R>,
|
|
1963
1962
|
seed: B,
|
|
1964
1963
|
f: (b: B, e: E) => readonly [C, B]
|
|
1965
|
-
): Fx<
|
|
1964
|
+
): Fx<A, C, R> {
|
|
1966
1965
|
return loopCause(fx, seed, (b, cause) =>
|
|
1967
1966
|
Either.match(Cause.failureOrCause(cause), {
|
|
1968
1967
|
onLeft: (e) => {
|
|
@@ -1973,18 +1972,18 @@ export function loopError<R, E, A, B, C>(
|
|
|
1973
1972
|
}))
|
|
1974
1973
|
}
|
|
1975
1974
|
|
|
1976
|
-
export function loopCauseEffect<
|
|
1977
|
-
fx: Fx<
|
|
1975
|
+
export function loopCauseEffect<A, E, R, B, E2, R2, C>(
|
|
1976
|
+
fx: Fx<A, E, R>,
|
|
1978
1977
|
seed: B,
|
|
1979
|
-
f: (b: B, cause: Cause.Cause<E>) => Effect.Effect<
|
|
1980
|
-
): Fx<
|
|
1978
|
+
f: (b: B, cause: Cause.Cause<E>) => Effect.Effect<readonly [Cause.Cause<C>, B], E2, R2>
|
|
1979
|
+
): Fx<A, E2 | C, R | R2> {
|
|
1981
1980
|
return new TransformerCause(fx, EffectLoopOp.LoopEffectOperator(seed, f))
|
|
1982
1981
|
}
|
|
1983
1982
|
|
|
1984
|
-
export function loopErrorEffect<
|
|
1985
|
-
fx: Fx<
|
|
1983
|
+
export function loopErrorEffect<A, E, R, B, E2, R2, C>(
|
|
1984
|
+
fx: Fx<A, E, R>,
|
|
1986
1985
|
seed: B,
|
|
1987
|
-
f: (b: B, e: E) => Effect.Effect<
|
|
1986
|
+
f: (b: B, e: E) => Effect.Effect<readonly [C, B], E2, R2>
|
|
1988
1987
|
) {
|
|
1989
1988
|
return loopCauseEffect(fx, seed, (b, cause) =>
|
|
1990
1989
|
Either.match(Cause.failureOrCause(cause), {
|
|
@@ -1993,16 +1992,16 @@ export function loopErrorEffect<R, E, A, R2, E2, B, C>(
|
|
|
1993
1992
|
}))
|
|
1994
1993
|
}
|
|
1995
1994
|
|
|
1996
|
-
export function filterMapLoopCause<
|
|
1997
|
-
fx: Fx<
|
|
1995
|
+
export function filterMapLoopCause<A, E, R, B, C>(
|
|
1996
|
+
fx: Fx<A, E, R>,
|
|
1998
1997
|
seed: B,
|
|
1999
1998
|
f: (b: B, cause: Cause.Cause<E>) => readonly [Option.Option<Cause.Cause<C>>, B]
|
|
2000
|
-
): Fx<
|
|
1999
|
+
): Fx<A, C, R> {
|
|
2001
2000
|
return new TransformerCause(fx, SyncLoopOp.FilterMapLoopOperator(seed, f))
|
|
2002
2001
|
}
|
|
2003
2002
|
|
|
2004
|
-
export function filterMapLoopError<
|
|
2005
|
-
fx: Fx<
|
|
2003
|
+
export function filterMapLoopError<A, E, R, B, C>(
|
|
2004
|
+
fx: Fx<A, E, R>,
|
|
2006
2005
|
seed: B,
|
|
2007
2006
|
f: (b: B, e: E) => readonly [Option.Option<C>, B]
|
|
2008
2007
|
) {
|
|
@@ -2016,18 +2015,18 @@ export function filterMapLoopError<R, E, A, B, C>(
|
|
|
2016
2015
|
}))
|
|
2017
2016
|
}
|
|
2018
2017
|
|
|
2019
|
-
export function filterMapLoopCauseEffect<
|
|
2020
|
-
fx: Fx<
|
|
2018
|
+
export function filterMapLoopCauseEffect<A, E, R, B, E2, R2, C>(
|
|
2019
|
+
fx: Fx<A, E, R>,
|
|
2021
2020
|
seed: B,
|
|
2022
|
-
f: (b: B, cause: Cause.Cause<E>) => Effect.Effect<
|
|
2023
|
-
): Fx<
|
|
2021
|
+
f: (b: B, cause: Cause.Cause<E>) => Effect.Effect<readonly [Option.Option<Cause.Cause<C>>, B], E2, R2>
|
|
2022
|
+
): Fx<A, E2 | C, R | R2> {
|
|
2024
2023
|
return new TransformerCause(fx, EffectLoopOp.FilterMapLoopEffectOperator(seed, f))
|
|
2025
2024
|
}
|
|
2026
2025
|
|
|
2027
|
-
export function filterMapLoopErrorEffect<
|
|
2028
|
-
fx: Fx<
|
|
2026
|
+
export function filterMapLoopErrorEffect<A, E, R, B, E2, R2, C>(
|
|
2027
|
+
fx: Fx<A, E, R>,
|
|
2029
2028
|
seed: B,
|
|
2030
|
-
f: (b: B, e: E) => Effect.Effect<
|
|
2029
|
+
f: (b: B, e: E) => Effect.Effect<readonly [Option.Option<C>, B], E2, R2>
|
|
2031
2030
|
) {
|
|
2032
2031
|
return filterMapLoopCauseEffect(fx, seed, (b, cause) =>
|
|
2033
2032
|
Either.match(Cause.failureOrCause(cause), {
|
|
@@ -2036,31 +2035,31 @@ export function filterMapLoopErrorEffect<R, E, A, R2, E2, B, C>(
|
|
|
2036
2035
|
}))
|
|
2037
2036
|
}
|
|
2038
2037
|
|
|
2039
|
-
class TransformerCause<
|
|
2040
|
-
constructor(readonly i0: Fx<
|
|
2038
|
+
class TransformerCause<A, E, R, R2, E2> extends FxBase<A, E2, R | R2> {
|
|
2039
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Op.Operator) {
|
|
2041
2040
|
super()
|
|
2042
2041
|
}
|
|
2043
2042
|
|
|
2044
|
-
run<R2>(sink: Sink.Sink<
|
|
2043
|
+
run<R2>(sink: Sink.Sink<A, E2, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
2045
2044
|
return this.i0.run(Op.compileOperatorSinkCause(this.i1, sink))
|
|
2046
2045
|
}
|
|
2047
2046
|
}
|
|
2048
2047
|
|
|
2049
|
-
export function flatMapCauseWithStrategy<
|
|
2050
|
-
fx: Fx<
|
|
2051
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2048
|
+
export function flatMapCauseWithStrategy<A, E, R, B, E2, R2>(
|
|
2049
|
+
fx: Fx<A, E, R>,
|
|
2050
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2052
2051
|
flattenStrategy: FlattenStrategy,
|
|
2053
2052
|
executionStrategy: ExecutionStrategy.ExecutionStrategy = ExecutionStrategy.sequential
|
|
2054
|
-
): Fx<R | R2 | Scope.Scope
|
|
2053
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2055
2054
|
return new FlatMapCauseWithStrategy(fx, f, flattenStrategy, executionStrategy)
|
|
2056
2055
|
}
|
|
2057
2056
|
|
|
2058
|
-
export function flatMapErrorWithStrategy<
|
|
2059
|
-
fx: Fx<
|
|
2060
|
-
f: (e: E) => Fx<
|
|
2057
|
+
export function flatMapErrorWithStrategy<A, E, R, B, E2, R2>(
|
|
2058
|
+
fx: Fx<A, E, R>,
|
|
2059
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2061
2060
|
flattenStrategy: FlattenStrategy,
|
|
2062
2061
|
executionStrategy: ExecutionStrategy.ExecutionStrategy = ExecutionStrategy.sequential
|
|
2063
|
-
): Fx<R | R2 | Scope.Scope
|
|
2062
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2064
2063
|
return flatMapCauseWithStrategy(
|
|
2065
2064
|
fx,
|
|
2066
2065
|
(cause) =>
|
|
@@ -2073,107 +2072,107 @@ export function flatMapErrorWithStrategy<R, E, A, R2, E2, B>(
|
|
|
2073
2072
|
)
|
|
2074
2073
|
}
|
|
2075
2074
|
|
|
2076
|
-
export function switchMapCause<
|
|
2077
|
-
fx: Fx<
|
|
2078
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2075
|
+
export function switchMapCause<A, E, R, B, E2, R2>(
|
|
2076
|
+
fx: Fx<A, E, R>,
|
|
2077
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2079
2078
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2080
|
-
): Fx<R | R2 | Scope.Scope
|
|
2079
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2081
2080
|
return flatMapCauseWithStrategy(fx, f, Switch, executionStrategy)
|
|
2082
2081
|
}
|
|
2083
2082
|
|
|
2084
|
-
export function switchMapError<
|
|
2085
|
-
fx: Fx<
|
|
2086
|
-
f: (e: E) => Fx<
|
|
2083
|
+
export function switchMapError<A, E, R, B, E2, R2>(
|
|
2084
|
+
fx: Fx<A, E, R>,
|
|
2085
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2087
2086
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2088
|
-
): Fx<R | R2 | Scope.Scope
|
|
2087
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2089
2088
|
return flatMapErrorWithStrategy(fx, f, Switch, executionStrategy)
|
|
2090
2089
|
}
|
|
2091
2090
|
|
|
2092
|
-
export function flatMapCause<
|
|
2093
|
-
fx: Fx<
|
|
2094
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2091
|
+
export function flatMapCause<A, E, R, B, E2, R2>(
|
|
2092
|
+
fx: Fx<A, E, R>,
|
|
2093
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2095
2094
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2096
|
-
): Fx<R | R2 | Scope.Scope
|
|
2095
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2097
2096
|
return flatMapCauseWithStrategy(fx, f, Unbounded, executionStrategy)
|
|
2098
2097
|
}
|
|
2099
2098
|
|
|
2100
|
-
export function flatMapError<
|
|
2101
|
-
fx: Fx<
|
|
2102
|
-
f: (e: E) => Fx<
|
|
2099
|
+
export function flatMapError<A, E, R, B, E2, R2>(
|
|
2100
|
+
fx: Fx<A, E, R>,
|
|
2101
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2103
2102
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2104
|
-
): Fx<R | R2 | Scope.Scope
|
|
2103
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2105
2104
|
return flatMapErrorWithStrategy(fx, f, Unbounded, executionStrategy)
|
|
2106
2105
|
}
|
|
2107
2106
|
|
|
2108
|
-
export function flatMapCauseConcurrently<
|
|
2109
|
-
fx: Fx<
|
|
2110
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2107
|
+
export function flatMapCauseConcurrently<A, E, R, B, E2, R2>(
|
|
2108
|
+
fx: Fx<A, E, R>,
|
|
2109
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2111
2110
|
concurrency: number,
|
|
2112
2111
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2113
|
-
): Fx<R | R2 | Scope.Scope
|
|
2112
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2114
2113
|
return flatMapCauseWithStrategy(fx, f, Bounded(concurrency), executionStrategy)
|
|
2115
2114
|
}
|
|
2116
2115
|
|
|
2117
|
-
export function flatMapErrorConcurrently<
|
|
2118
|
-
fx: Fx<
|
|
2119
|
-
f: (e: E) => Fx<
|
|
2116
|
+
export function flatMapErrorConcurrently<A, E, R, B, E2, R2>(
|
|
2117
|
+
fx: Fx<A, E, R>,
|
|
2118
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2120
2119
|
concurrency: number,
|
|
2121
2120
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2122
|
-
): Fx<R | R2 | Scope.Scope
|
|
2121
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2123
2122
|
return flatMapErrorWithStrategy(fx, f, Bounded(concurrency), executionStrategy)
|
|
2124
2123
|
}
|
|
2125
2124
|
|
|
2126
|
-
export function exhaustMapCause<
|
|
2127
|
-
fx: Fx<
|
|
2128
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2125
|
+
export function exhaustMapCause<A, E, R, B, E2, R2>(
|
|
2126
|
+
fx: Fx<A, E, R>,
|
|
2127
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2129
2128
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2130
|
-
): Fx<R | R2 | Scope.Scope
|
|
2129
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2131
2130
|
return flatMapCauseWithStrategy(fx, f, Exhaust, executionStrategy)
|
|
2132
2131
|
}
|
|
2133
2132
|
|
|
2134
|
-
export function exhaustMapError<
|
|
2135
|
-
fx: Fx<
|
|
2136
|
-
f: (e: E) => Fx<
|
|
2133
|
+
export function exhaustMapError<A, E, R, B, E2, R2>(
|
|
2134
|
+
fx: Fx<A, E, R>,
|
|
2135
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2137
2136
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2138
|
-
): Fx<R | R2 | Scope.Scope
|
|
2137
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2139
2138
|
return flatMapErrorWithStrategy(fx, f, Exhaust, executionStrategy)
|
|
2140
2139
|
}
|
|
2141
2140
|
|
|
2142
|
-
export function exhaustMapLatestCause<
|
|
2143
|
-
fx: Fx<
|
|
2144
|
-
f: (cause: Cause.Cause<E>) => Fx<
|
|
2141
|
+
export function exhaustMapLatestCause<A, E, R, B, E2, R2>(
|
|
2142
|
+
fx: Fx<A, E, R>,
|
|
2143
|
+
f: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2145
2144
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2146
|
-
): Fx<R | R2 | Scope.Scope
|
|
2145
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2147
2146
|
return flatMapCauseWithStrategy(fx, f, ExhaustLatest, executionStrategy)
|
|
2148
2147
|
}
|
|
2149
2148
|
|
|
2150
|
-
export function exhaustMapLatestError<
|
|
2151
|
-
fx: Fx<
|
|
2152
|
-
f: (e: E) => Fx<
|
|
2149
|
+
export function exhaustMapLatestError<A, E, R, B, E2, R2>(
|
|
2150
|
+
fx: Fx<A, E, R>,
|
|
2151
|
+
f: (e: E) => Fx<B, E2, R2>,
|
|
2153
2152
|
executionStrategy?: ExecutionStrategy.ExecutionStrategy
|
|
2154
|
-
): Fx<R | R2 | Scope.Scope
|
|
2153
|
+
): Fx<A | B, E2, R | R2 | Scope.Scope> {
|
|
2155
2154
|
return flatMapErrorWithStrategy(fx, f, ExhaustLatest, executionStrategy)
|
|
2156
2155
|
}
|
|
2157
2156
|
|
|
2158
2157
|
class FlatMapCauseWithStrategy<
|
|
2159
|
-
R,
|
|
2160
|
-
E,
|
|
2161
2158
|
A,
|
|
2159
|
+
E,
|
|
2160
|
+
R,
|
|
2162
2161
|
R2,
|
|
2163
2162
|
E2,
|
|
2164
2163
|
B
|
|
2165
|
-
> extends FxBase<R | R2 | Scope.Scope
|
|
2166
|
-
private withFork: <
|
|
2164
|
+
> extends FxBase<A | B, E2, R | R2 | Scope.Scope> {
|
|
2165
|
+
private withFork: <A, E, R>(
|
|
2167
2166
|
f: (
|
|
2168
2167
|
fork: FxFork,
|
|
2169
2168
|
scope: Scope.Scope
|
|
2170
|
-
) => Effect.Effect<
|
|
2169
|
+
) => Effect.Effect<A, E, R>,
|
|
2171
2170
|
executionStrategy: ExecutionStrategy.ExecutionStrategy
|
|
2172
|
-
) => Effect.Effect<Scope.Scope | R
|
|
2171
|
+
) => Effect.Effect<void, E, Scope.Scope | R>
|
|
2173
2172
|
|
|
2174
2173
|
constructor(
|
|
2175
|
-
readonly i0: Fx<
|
|
2176
|
-
readonly i1: (cause: Cause.Cause<E>) => Fx<
|
|
2174
|
+
readonly i0: Fx<A, E, R>,
|
|
2175
|
+
readonly i1: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2177
2176
|
readonly i2: FlattenStrategy,
|
|
2178
2177
|
readonly i3: ExecutionStrategy.ExecutionStrategy
|
|
2179
2178
|
) {
|
|
@@ -2182,7 +2181,7 @@ class FlatMapCauseWithStrategy<
|
|
|
2182
2181
|
this.withFork = withFlattenStrategy(this.i2)
|
|
2183
2182
|
}
|
|
2184
2183
|
|
|
2185
|
-
run<R3>(sink: Sink.Sink<
|
|
2184
|
+
run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
|
|
2186
2185
|
return this.withFork(
|
|
2187
2186
|
(fork) => this.i0.run(Sink.make((cause) => fork(this.i1(cause).run(sink)), (a) => sink.onSuccess(a))),
|
|
2188
2187
|
this.i3
|
|
@@ -2191,28 +2190,28 @@ class FlatMapCauseWithStrategy<
|
|
|
2191
2190
|
}
|
|
2192
2191
|
|
|
2193
2192
|
class MatchWithStrategy<
|
|
2194
|
-
R,
|
|
2195
|
-
E,
|
|
2196
2193
|
A,
|
|
2194
|
+
E,
|
|
2195
|
+
R,
|
|
2197
2196
|
R2,
|
|
2198
2197
|
E2,
|
|
2199
2198
|
B,
|
|
2200
2199
|
R3,
|
|
2201
2200
|
E3,
|
|
2202
2201
|
C
|
|
2203
|
-
> extends FxBase<
|
|
2204
|
-
private withFork: <
|
|
2202
|
+
> extends FxBase<B | C, E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
2203
|
+
private withFork: <A, E, R>(
|
|
2205
2204
|
f: (
|
|
2206
2205
|
fork: FxFork,
|
|
2207
2206
|
scope: Scope.Scope
|
|
2208
|
-
) => Effect.Effect<
|
|
2207
|
+
) => Effect.Effect<A, E, R>,
|
|
2209
2208
|
executionStrategy: ExecutionStrategy.ExecutionStrategy
|
|
2210
|
-
) => Effect.Effect<Scope.Scope | R
|
|
2209
|
+
) => Effect.Effect<void, E, Scope.Scope | R>
|
|
2211
2210
|
|
|
2212
2211
|
constructor(
|
|
2213
|
-
readonly i0: Fx<
|
|
2214
|
-
readonly i1: (cause: Cause.Cause<E>) => Fx<
|
|
2215
|
-
readonly i2: (a: A) => Fx<
|
|
2212
|
+
readonly i0: Fx<A, E, R>,
|
|
2213
|
+
readonly i1: (cause: Cause.Cause<E>) => Fx<B, E2, R2>,
|
|
2214
|
+
readonly i2: (a: A) => Fx<C, E3, R3>,
|
|
2216
2215
|
readonly i3: FlattenStrategy,
|
|
2217
2216
|
readonly i4: ExecutionStrategy.ExecutionStrategy
|
|
2218
2217
|
) {
|
|
@@ -2221,7 +2220,7 @@ class MatchWithStrategy<
|
|
|
2221
2220
|
this.withFork = withFlattenStrategy(this.i3)
|
|
2222
2221
|
}
|
|
2223
2222
|
|
|
2224
|
-
run<R4>(sink: Sink.Sink<
|
|
2223
|
+
run<R4>(sink: Sink.Sink<B | C, E2 | E3, R4>): Effect.Effect<unknown, never, R | R2 | R3 | R4 | Scope.Scope> {
|
|
2225
2224
|
return this.withFork(
|
|
2226
2225
|
(fork) =>
|
|
2227
2226
|
this.i0.run(Sink.make(
|
|
@@ -2233,17 +2232,17 @@ class MatchWithStrategy<
|
|
|
2233
2232
|
}
|
|
2234
2233
|
}
|
|
2235
2234
|
|
|
2236
|
-
export type MatchCauseOptions<E, A,
|
|
2237
|
-
readonly onFailure: (cause: Cause.Cause<E>) => Fx<
|
|
2238
|
-
readonly onSuccess: (a: A) => Fx<
|
|
2235
|
+
export type MatchCauseOptions<E, A, B, E2, R2, C, E3, R3> = {
|
|
2236
|
+
readonly onFailure: (cause: Cause.Cause<E>) => Fx<B, E2, R2>
|
|
2237
|
+
readonly onSuccess: (a: A) => Fx<C, E3, R3>
|
|
2239
2238
|
readonly executionStrategy?: ExecutionStrategy.ExecutionStrategy | undefined
|
|
2240
2239
|
}
|
|
2241
2240
|
|
|
2242
|
-
export function matchCauseWithStrategy<
|
|
2243
|
-
fx: Fx<
|
|
2241
|
+
export function matchCauseWithStrategy<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2242
|
+
fx: Fx<A, E, R>,
|
|
2244
2243
|
flattenStrategy: FlattenStrategy,
|
|
2245
|
-
opts: MatchCauseOptions<E, A,
|
|
2246
|
-
): Fx<
|
|
2244
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2245
|
+
): Fx<B | C, E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
2247
2246
|
return new MatchWithStrategy(
|
|
2248
2247
|
fx,
|
|
2249
2248
|
opts.onFailure,
|
|
@@ -2253,17 +2252,17 @@ export function matchCauseWithStrategy<R, E, A, R2, E2, B, R3, E3, C>(
|
|
|
2253
2252
|
)
|
|
2254
2253
|
}
|
|
2255
2254
|
|
|
2256
|
-
export type MatchErrorOptions<E, A,
|
|
2257
|
-
readonly onFailure: (e: E) => Fx<
|
|
2258
|
-
readonly onSuccess: (a: A) => Fx<
|
|
2255
|
+
export type MatchErrorOptions<E, A, B, E2, R2, C, E3, R3> = {
|
|
2256
|
+
readonly onFailure: (e: E) => Fx<B, E2, R2>
|
|
2257
|
+
readonly onSuccess: (a: A) => Fx<C, E3, R3>
|
|
2259
2258
|
readonly executionStrategy?: ExecutionStrategy.ExecutionStrategy | undefined
|
|
2260
2259
|
}
|
|
2261
2260
|
|
|
2262
|
-
export function matchErrorWithStrategy<
|
|
2263
|
-
fx: Fx<
|
|
2261
|
+
export function matchErrorWithStrategy<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2262
|
+
fx: Fx<A, E, R>,
|
|
2264
2263
|
flattenStrategy: FlattenStrategy,
|
|
2265
|
-
{ executionStrategy, onFailure, onSuccess }: MatchErrorOptions<E, A,
|
|
2266
|
-
): Fx<
|
|
2264
|
+
{ executionStrategy, onFailure, onSuccess }: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2265
|
+
): Fx<B | C, E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
2267
2266
|
return new MatchWithStrategy(
|
|
2268
2267
|
fx,
|
|
2269
2268
|
(cause) =>
|
|
@@ -2277,74 +2276,74 @@ export function matchErrorWithStrategy<R, E, A, R2, E2, B, R3, E3, C>(
|
|
|
2277
2276
|
)
|
|
2278
2277
|
}
|
|
2279
2278
|
|
|
2280
|
-
export function matchCause<
|
|
2281
|
-
fx: Fx<
|
|
2282
|
-
opts: MatchCauseOptions<E, A,
|
|
2279
|
+
export function matchCause<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2280
|
+
fx: Fx<A, E, R>,
|
|
2281
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2283
2282
|
) {
|
|
2284
2283
|
return matchCauseWithStrategy(fx, Unbounded, opts)
|
|
2285
2284
|
}
|
|
2286
2285
|
|
|
2287
|
-
export function matchError<
|
|
2288
|
-
fx: Fx<
|
|
2289
|
-
opts: MatchErrorOptions<E, A,
|
|
2286
|
+
export function matchError<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2287
|
+
fx: Fx<A, E, R>,
|
|
2288
|
+
opts: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2290
2289
|
) {
|
|
2291
2290
|
return matchErrorWithStrategy(fx, Unbounded, opts)
|
|
2292
2291
|
}
|
|
2293
2292
|
|
|
2294
|
-
export function matchCauseConcurrently<
|
|
2295
|
-
fx: Fx<
|
|
2293
|
+
export function matchCauseConcurrently<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2294
|
+
fx: Fx<A, E, R>,
|
|
2296
2295
|
concurrency: number,
|
|
2297
|
-
opts: MatchCauseOptions<E, A,
|
|
2296
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2298
2297
|
) {
|
|
2299
2298
|
return matchCauseWithStrategy(fx, Bounded(concurrency), opts)
|
|
2300
2299
|
}
|
|
2301
2300
|
|
|
2302
|
-
export function matchErrorConcurrently<
|
|
2303
|
-
fx: Fx<
|
|
2301
|
+
export function matchErrorConcurrently<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2302
|
+
fx: Fx<A, E, R>,
|
|
2304
2303
|
concurrency: number,
|
|
2305
|
-
opts: MatchErrorOptions<E, A,
|
|
2304
|
+
opts: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2306
2305
|
) {
|
|
2307
2306
|
return matchErrorWithStrategy(fx, Bounded(concurrency), opts)
|
|
2308
2307
|
}
|
|
2309
2308
|
|
|
2310
|
-
export function switchMatchCause<
|
|
2311
|
-
fx: Fx<
|
|
2312
|
-
opts: MatchCauseOptions<E, A,
|
|
2309
|
+
export function switchMatchCause<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2310
|
+
fx: Fx<A, E, R>,
|
|
2311
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2313
2312
|
) {
|
|
2314
2313
|
return matchCauseWithStrategy(fx, Switch, opts)
|
|
2315
2314
|
}
|
|
2316
2315
|
|
|
2317
|
-
export function switchMatchError<
|
|
2318
|
-
fx: Fx<
|
|
2319
|
-
opts: MatchErrorOptions<E, A,
|
|
2316
|
+
export function switchMatchError<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2317
|
+
fx: Fx<A, E, R>,
|
|
2318
|
+
opts: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2320
2319
|
) {
|
|
2321
2320
|
return matchErrorWithStrategy(fx, Switch, opts)
|
|
2322
2321
|
}
|
|
2323
2322
|
|
|
2324
|
-
export function exhaustMatchCause<
|
|
2325
|
-
fx: Fx<
|
|
2326
|
-
opts: MatchCauseOptions<E, A,
|
|
2323
|
+
export function exhaustMatchCause<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2324
|
+
fx: Fx<A, E, R>,
|
|
2325
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2327
2326
|
) {
|
|
2328
2327
|
return matchCauseWithStrategy(fx, Exhaust, opts)
|
|
2329
2328
|
}
|
|
2330
2329
|
|
|
2331
|
-
export function exhaustMatchError<
|
|
2332
|
-
fx: Fx<
|
|
2333
|
-
opts: MatchErrorOptions<E, A,
|
|
2330
|
+
export function exhaustMatchError<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2331
|
+
fx: Fx<A, E, R>,
|
|
2332
|
+
opts: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2334
2333
|
) {
|
|
2335
2334
|
return matchErrorWithStrategy(fx, Exhaust, opts)
|
|
2336
2335
|
}
|
|
2337
2336
|
|
|
2338
|
-
export function exhaustMatchLatestCause<
|
|
2339
|
-
fx: Fx<
|
|
2340
|
-
opts: MatchCauseOptions<E, A,
|
|
2337
|
+
export function exhaustMatchLatestCause<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2338
|
+
fx: Fx<A, E, R>,
|
|
2339
|
+
opts: MatchCauseOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2341
2340
|
) {
|
|
2342
2341
|
return matchCauseWithStrategy(fx, ExhaustLatest, opts)
|
|
2343
2342
|
}
|
|
2344
2343
|
|
|
2345
|
-
export function exhaustMatchLatestError<
|
|
2346
|
-
fx: Fx<
|
|
2347
|
-
opts: MatchErrorOptions<E, A,
|
|
2344
|
+
export function exhaustMatchLatestError<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2345
|
+
fx: Fx<A, E, R>,
|
|
2346
|
+
opts: MatchErrorOptions<E, A, B, E2, R2, C, E3, R3>
|
|
2348
2347
|
) {
|
|
2349
2348
|
return matchErrorWithStrategy(fx, ExhaustLatest, opts)
|
|
2350
2349
|
}
|
|
@@ -2352,29 +2351,29 @@ export function exhaustMatchLatestError<R, E, A, R2, E2, B, R3, E3, C>(
|
|
|
2352
2351
|
export function tuple<const FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
2353
2352
|
fx: FX
|
|
2354
2353
|
): Fx<
|
|
2355
|
-
Fx.Context<FX[number]>,
|
|
2356
|
-
Fx.Error<FX[number]>,
|
|
2357
2354
|
{
|
|
2358
2355
|
readonly [K in keyof FX]: Fx.Success<FX[K]>
|
|
2359
|
-
}
|
|
2356
|
+
},
|
|
2357
|
+
Fx.Error<FX[number]>,
|
|
2358
|
+
Fx.Context<FX[number]>
|
|
2360
2359
|
> {
|
|
2361
2360
|
return new Tuple(fx)
|
|
2362
2361
|
}
|
|
2363
2362
|
|
|
2364
2363
|
class Tuple<const FX extends ReadonlyArray<Fx<any, any, any>>> extends FxBase<
|
|
2365
|
-
Fx.Context<FX[number]>,
|
|
2366
|
-
Fx.Error<FX[number]>,
|
|
2367
2364
|
{
|
|
2368
2365
|
readonly [K in keyof FX]: Fx.Success<FX[K]>
|
|
2369
|
-
}
|
|
2366
|
+
},
|
|
2367
|
+
Fx.Error<FX[number]>,
|
|
2368
|
+
Fx.Context<FX[number]>
|
|
2370
2369
|
> {
|
|
2371
2370
|
constructor(readonly i0: FX) {
|
|
2372
2371
|
super()
|
|
2373
2372
|
}
|
|
2374
2373
|
|
|
2375
2374
|
run<R2>(
|
|
2376
|
-
sink: Sink.Sink<
|
|
2377
|
-
): Effect.Effect<Fx.Context<FX[number]> | R2
|
|
2375
|
+
sink: Sink.Sink<{ readonly [K in keyof FX]: Fx.Success<FX[K]> }, Fx.Error<FX[number]>, R2>
|
|
2376
|
+
): Effect.Effect<unknown, never, Fx.Context<FX[number]> | R2> {
|
|
2378
2377
|
return tupleSink(
|
|
2379
2378
|
sink,
|
|
2380
2379
|
(onSuccess) =>
|
|
@@ -2397,11 +2396,11 @@ class Tuple<const FX extends ReadonlyArray<Fx<any, any, any>>> extends FxBase<
|
|
|
2397
2396
|
export function struct<const FX extends Readonly<Record<string, Fx<any, any, any>>>>(
|
|
2398
2397
|
fx: FX
|
|
2399
2398
|
): Fx<
|
|
2400
|
-
Fx.Context<FX[string]>,
|
|
2401
|
-
Fx.Error<FX[string]>,
|
|
2402
2399
|
{
|
|
2403
2400
|
readonly [K in keyof FX]: Fx.Success<FX[K]>
|
|
2404
|
-
}
|
|
2401
|
+
},
|
|
2402
|
+
Fx.Error<FX[string]>,
|
|
2403
|
+
Fx.Context<FX[string]>
|
|
2405
2404
|
> {
|
|
2406
2405
|
const entries: ReadonlyArray<readonly [keyof FX, FX[keyof FX]]> = Object.entries(fx) as any
|
|
2407
2406
|
|
|
@@ -2410,57 +2409,45 @@ export function struct<const FX extends Readonly<Record<string, Fx<any, any, any
|
|
|
2410
2409
|
|
|
2411
2410
|
export function all<const FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
2412
2411
|
fx: FX
|
|
2413
|
-
): Fx<
|
|
2414
|
-
Fx.Context<FX[number]>,
|
|
2415
|
-
Fx.Error<FX[number]>,
|
|
2416
|
-
{ readonly [K in keyof FX]: Fx.Success<FX[K]> }
|
|
2417
|
-
>
|
|
2412
|
+
): Fx<{ readonly [K in keyof FX]: Fx.Success<FX[K]> }, Fx.Error<FX[number]>, Fx.Context<FX[number]>>
|
|
2418
2413
|
|
|
2419
2414
|
export function all<const FX extends Readonly<Record<string, Fx<any, any, any>>>>(
|
|
2420
2415
|
fx: FX
|
|
2421
|
-
): Fx<
|
|
2422
|
-
Fx.Context<FX[string]>,
|
|
2423
|
-
Fx.Error<FX[string]>,
|
|
2424
|
-
{ readonly [K in keyof FX]: Fx.Success<FX[K]> }
|
|
2425
|
-
>
|
|
2416
|
+
): Fx<{ readonly [K in keyof FX]: Fx.Success<FX[K]> }, Fx.Error<FX[string]>, Fx.Context<FX[string]>>
|
|
2426
2417
|
|
|
2427
2418
|
export function all<const FX extends ReadonlyArray<Fx<any, any, any> | Readonly<Record<string, Fx<any, any, any>>>>>(
|
|
2428
2419
|
fx: FX
|
|
2429
|
-
): Fx<
|
|
2430
|
-
Fx.Context<FX[keyof FX]>,
|
|
2431
|
-
Fx.Error<FX[keyof FX]>,
|
|
2432
|
-
any
|
|
2433
|
-
> {
|
|
2420
|
+
): Fx<any, Fx.Error<FX[keyof FX]>, Fx.Context<FX[keyof FX]>> {
|
|
2434
2421
|
if (Array.isArray(fx)) return tuple(fx)
|
|
2435
2422
|
else return struct(fx as any) as any
|
|
2436
2423
|
}
|
|
2437
2424
|
|
|
2438
|
-
export function exit<
|
|
2439
|
-
fx: Fx<
|
|
2440
|
-
): Fx<
|
|
2425
|
+
export function exit<A, E, R>(
|
|
2426
|
+
fx: Fx<A, E, R>
|
|
2427
|
+
): Fx<Exit.Exit<A, E>, never, R> {
|
|
2441
2428
|
return new ExitFx(fx)
|
|
2442
2429
|
}
|
|
2443
2430
|
|
|
2444
|
-
class ExitFx<
|
|
2445
|
-
constructor(readonly i0: Fx<
|
|
2431
|
+
class ExitFx<A, E, R> extends FxBase<Exit.Exit<A, E>, never, R> {
|
|
2432
|
+
constructor(readonly i0: Fx<A, E, R>) {
|
|
2446
2433
|
super()
|
|
2447
2434
|
}
|
|
2448
2435
|
|
|
2449
|
-
run<R2>(sink: Sink.Sink<
|
|
2436
|
+
run<R2>(sink: Sink.Sink<Exit.Exit<A, E>, never, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
2450
2437
|
return this.i0.run(
|
|
2451
2438
|
Sink.make((cause) => sink.onSuccess(Exit.failCause(cause)), (a) => sink.onSuccess(Exit.succeed(a)))
|
|
2452
2439
|
)
|
|
2453
2440
|
}
|
|
2454
2441
|
}
|
|
2455
2442
|
|
|
2456
|
-
export function toEnqueue<
|
|
2457
|
-
fx: Fx<
|
|
2443
|
+
export function toEnqueue<A, E, R, R2 = never>(
|
|
2444
|
+
fx: Fx<A, E, R>,
|
|
2458
2445
|
queue: Context.Enqueue<R2, A> | Queue.Enqueue<A>
|
|
2459
2446
|
) {
|
|
2460
2447
|
return observe(fx, (a) => queue.offer(a))
|
|
2461
2448
|
}
|
|
2462
2449
|
|
|
2463
|
-
export function debounce<
|
|
2450
|
+
export function debounce<A, E, R>(fx: Fx<A, E, R>, delay: Duration.DurationInput): Fx<A, E, R | Scope.Scope> {
|
|
2464
2451
|
return switchMapEffect(fx, (a) => Effect.as(Effect.sleep(delay), a))
|
|
2465
2452
|
}
|
|
2466
2453
|
|
|
@@ -2468,27 +2455,27 @@ function emitAndSleep<A>(value: A, delay: Duration.DurationInput) {
|
|
|
2468
2455
|
return make<A>((sink) => Effect.zipRight(sink.onSuccess(value), Effect.sleep(delay)))
|
|
2469
2456
|
}
|
|
2470
2457
|
|
|
2471
|
-
export function throttle<
|
|
2458
|
+
export function throttle<A, E, R>(fx: Fx<A, E, R>, delay: Duration.DurationInput): Fx<A, E, R | Scope.Scope> {
|
|
2472
2459
|
return exhaustMap(fx, (a) => emitAndSleep(a, delay))
|
|
2473
2460
|
}
|
|
2474
2461
|
|
|
2475
|
-
export function throttleLatest<
|
|
2462
|
+
export function throttleLatest<A, E, R>(fx: Fx<A, E, R>, delay: Duration.DurationInput): Fx<A, E, R | Scope.Scope> {
|
|
2476
2463
|
return exhaustMapLatest(fx, (a) => emitAndSleep(a, delay))
|
|
2477
2464
|
}
|
|
2478
2465
|
|
|
2479
|
-
export function fromAsyncIterable<A>(iterable: AsyncIterable<A>): Fx<
|
|
2466
|
+
export function fromAsyncIterable<A>(iterable: AsyncIterable<A>): Fx<A> {
|
|
2480
2467
|
return new FromAsyncIterable(iterable)
|
|
2481
2468
|
}
|
|
2482
2469
|
|
|
2483
|
-
class FromAsyncIterable<A> extends FxBase<
|
|
2470
|
+
class FromAsyncIterable<A> extends FxBase<A, never, never> {
|
|
2484
2471
|
constructor(readonly i0: AsyncIterable<A>) {
|
|
2485
2472
|
super()
|
|
2486
2473
|
}
|
|
2487
2474
|
|
|
2488
|
-
run<R>(sink: Sink.Sink<
|
|
2475
|
+
run<R>(sink: Sink.Sink<A, never, R>): Effect.Effect<unknown, never, R> {
|
|
2489
2476
|
return Effect.asyncEffect((cb) => {
|
|
2490
2477
|
const iterator = this.i0[Symbol.asyncIterator]()
|
|
2491
|
-
const loop = (result: IteratorResult<A>): Effect.Effect<
|
|
2478
|
+
const loop = (result: IteratorResult<A>): Effect.Effect<unknown, never, R> =>
|
|
2492
2479
|
result.done
|
|
2493
2480
|
? Effect.sync(() => cb(Effect.unit))
|
|
2494
2481
|
: Effect.zipRight(sink.onSuccess(result.value), Effect.flatMap(Effect.promise(() => iterator.next()), loop))
|
|
@@ -2501,26 +2488,26 @@ class FromAsyncIterable<A> extends FxBase<never, never, A> {
|
|
|
2501
2488
|
}
|
|
2502
2489
|
}
|
|
2503
2490
|
|
|
2504
|
-
export function findFirst<
|
|
2491
|
+
export function findFirst<A, E, R>(fx: Fx<A, E, R>, predicate: Predicate.Predicate<A>): Effect.Effect<A, E, R> {
|
|
2505
2492
|
return Effect.asyncEffect((cb) =>
|
|
2506
2493
|
observe(fx, (a) => predicate(a) ? Effect.sync(() => cb(Effect.succeed(a))) : Effect.unit)
|
|
2507
2494
|
)
|
|
2508
2495
|
}
|
|
2509
2496
|
|
|
2510
|
-
export function first<
|
|
2497
|
+
export function first<A, E, R>(fx: Fx<A, E, R>): Effect.Effect<A, E, R> {
|
|
2511
2498
|
return findFirst(fx, constTrue)
|
|
2512
2499
|
}
|
|
2513
2500
|
|
|
2514
|
-
export function either<
|
|
2501
|
+
export function either<A, E, R>(fx: Fx<A, E, R>): Fx<Either.Either<E, A>, never, R> {
|
|
2515
2502
|
return new EitherFx(fx)
|
|
2516
2503
|
}
|
|
2517
2504
|
|
|
2518
|
-
class EitherFx<
|
|
2519
|
-
constructor(readonly i0: Fx<
|
|
2505
|
+
class EitherFx<A, E, R> extends FxBase<Either.Either<E, A>, never, R> {
|
|
2506
|
+
constructor(readonly i0: Fx<A, E, R>) {
|
|
2520
2507
|
super()
|
|
2521
2508
|
}
|
|
2522
2509
|
|
|
2523
|
-
run<R2>(sink: Sink.Sink<
|
|
2510
|
+
run<R2>(sink: Sink.Sink<Either.Either<E, A>, never, R2>): Effect.Effect<unknown, never, R | R2> {
|
|
2524
2511
|
return this.i0.run(
|
|
2525
2512
|
Sink.make(
|
|
2526
2513
|
(cause) =>
|
|
@@ -2534,26 +2521,26 @@ class EitherFx<R, E, A> extends FxBase<R, never, Either.Either<E, A>> {
|
|
|
2534
2521
|
}
|
|
2535
2522
|
}
|
|
2536
2523
|
|
|
2537
|
-
export function mergeFirst<
|
|
2538
|
-
fx: Fx<
|
|
2539
|
-
that: Fx<
|
|
2540
|
-
): Fx<
|
|
2541
|
-
return merge(fx, filter(that, constFalse) as Fx<
|
|
2524
|
+
export function mergeFirst<A, E, R, B, E2, R2>(
|
|
2525
|
+
fx: Fx<A, E, R>,
|
|
2526
|
+
that: Fx<B, E2, R2>
|
|
2527
|
+
): Fx<A, E | E2, R | R2> {
|
|
2528
|
+
return merge(fx, filter(that, constFalse) as Fx<never, E2, R2>)
|
|
2542
2529
|
}
|
|
2543
2530
|
|
|
2544
|
-
export function mergeRace<
|
|
2545
|
-
fx: Fx<
|
|
2546
|
-
that: Fx<
|
|
2547
|
-
): Fx<
|
|
2531
|
+
export function mergeRace<A, E, R, B, E2, R2>(
|
|
2532
|
+
fx: Fx<A, E, R>,
|
|
2533
|
+
that: Fx<B, E2, R2>
|
|
2534
|
+
): Fx<A | B, E | E2, R | R2> {
|
|
2548
2535
|
return new MergeRace(fx, that)
|
|
2549
2536
|
}
|
|
2550
2537
|
|
|
2551
|
-
class MergeRace<
|
|
2552
|
-
constructor(readonly i0: Fx<
|
|
2538
|
+
class MergeRace<A, E, R, B, E2, R2> extends FxBase<A | B, E | E2, R | R2> {
|
|
2539
|
+
constructor(readonly i0: Fx<A, E, R>, readonly i1: Fx<B, E2, R2>) {
|
|
2553
2540
|
super()
|
|
2554
2541
|
}
|
|
2555
2542
|
|
|
2556
|
-
run<R3>(sink: Sink.Sink<
|
|
2543
|
+
run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
2557
2544
|
return Effect.gen(this, function*(_) {
|
|
2558
2545
|
const fiber1 = yield* _(Effect.fork(this.i0.run(Sink.make(
|
|
2559
2546
|
sink.onFailure,
|
|
@@ -2569,38 +2556,38 @@ class MergeRace<R, E, A, R2, E2, B> extends FxBase<R | R2, E | E2, A | B> {
|
|
|
2569
2556
|
export function raceAll<const FX extends ReadonlyArray<Fx<any, any, any>>>(
|
|
2570
2557
|
fx: FX
|
|
2571
2558
|
): Fx<
|
|
2572
|
-
Fx.
|
|
2559
|
+
Fx.Success<FX[number]>,
|
|
2573
2560
|
Fx.Error<FX[number]>,
|
|
2574
|
-
Fx.
|
|
2561
|
+
Fx.Context<FX[number]>
|
|
2575
2562
|
> {
|
|
2576
2563
|
return new RaceAll(fx)
|
|
2577
2564
|
}
|
|
2578
2565
|
|
|
2579
|
-
export function race<
|
|
2580
|
-
fx: Fx<
|
|
2581
|
-
that: Fx<
|
|
2582
|
-
): Fx<
|
|
2566
|
+
export function race<A, E, R, B, E2, R2>(
|
|
2567
|
+
fx: Fx<A, E, R>,
|
|
2568
|
+
that: Fx<B, E2, R2>
|
|
2569
|
+
): Fx<A | B, E | E2, R | R2> {
|
|
2583
2570
|
return raceAll([fx, that])
|
|
2584
2571
|
}
|
|
2585
2572
|
|
|
2586
2573
|
class RaceAll<const FX extends ReadonlyArray<Fx<any, any, any>>> extends FxBase<
|
|
2587
|
-
Fx.
|
|
2574
|
+
Fx.Success<FX[number]>,
|
|
2588
2575
|
Fx.Error<FX[number]>,
|
|
2589
|
-
Fx.
|
|
2576
|
+
Fx.Context<FX[number]>
|
|
2590
2577
|
> {
|
|
2591
2578
|
constructor(readonly i0: FX) {
|
|
2592
2579
|
super()
|
|
2593
2580
|
}
|
|
2594
2581
|
|
|
2595
2582
|
run<R2>(
|
|
2596
|
-
sink: Sink.Sink<
|
|
2597
|
-
): Effect.Effect<Fx.Context<FX[number]> | R2
|
|
2583
|
+
sink: Sink.Sink<Fx.Success<FX[number]>, Fx.Error<FX[number]>, R2>
|
|
2584
|
+
): Effect.Effect<unknown, never, Fx.Context<FX[number]> | R2> {
|
|
2598
2585
|
return Effect.gen(this, function*(_) {
|
|
2599
|
-
const winner = yield* _(Deferred.make<
|
|
2600
|
-
const fibers: Array<Fiber.RuntimeFiber<
|
|
2586
|
+
const winner = yield* _(Deferred.make<Fiber.RuntimeFiber<unknown>>())
|
|
2587
|
+
const fibers: Array<Fiber.RuntimeFiber<unknown>> = []
|
|
2601
2588
|
|
|
2602
2589
|
for (const fx of this.i0) {
|
|
2603
|
-
const fiber: Fiber.RuntimeFiber<
|
|
2590
|
+
const fiber: Fiber.RuntimeFiber<unknown> = yield* _(Effect.fork(fx.run(Sink.make(
|
|
2604
2591
|
sink.onFailure,
|
|
2605
2592
|
(a) => Effect.flatMap(Deferred.succeed(winner, fiber), () => sink.onSuccess(a))
|
|
2606
2593
|
))))
|
|
@@ -2616,31 +2603,31 @@ class RaceAll<const FX extends ReadonlyArray<Fx<any, any, any>>> extends FxBase<
|
|
|
2616
2603
|
}
|
|
2617
2604
|
}
|
|
2618
2605
|
|
|
2619
|
-
export function snapshot<
|
|
2620
|
-
fx: Fx<
|
|
2621
|
-
sampled: Fx<
|
|
2606
|
+
export function snapshot<A, E, R, B, E2, R2, C>(
|
|
2607
|
+
fx: Fx<A, E, R>,
|
|
2608
|
+
sampled: Fx<B, E2, R2>,
|
|
2622
2609
|
f: (a: A, b: B) => C
|
|
2623
|
-
): Fx<
|
|
2610
|
+
): Fx<C, E | E2, R | R2> {
|
|
2624
2611
|
return new Snapshot(fx, sampled, f)
|
|
2625
2612
|
}
|
|
2626
2613
|
|
|
2627
|
-
export function sample<
|
|
2628
|
-
fx: Fx<
|
|
2629
|
-
sampled: Fx<
|
|
2630
|
-
): Fx<
|
|
2614
|
+
export function sample<A, E, R, B, E2, R2>(
|
|
2615
|
+
fx: Fx<A, E, R>,
|
|
2616
|
+
sampled: Fx<B, E2, R2>
|
|
2617
|
+
): Fx<B, E | E2, R | R2> {
|
|
2631
2618
|
return snapshot(fx, sampled, (_, b) => b)
|
|
2632
2619
|
}
|
|
2633
2620
|
|
|
2634
|
-
class Snapshot<
|
|
2621
|
+
class Snapshot<A, E, R, B, E2, R2, C> extends FxBase<C, E | E2, R | R2> {
|
|
2635
2622
|
constructor(
|
|
2636
|
-
readonly i0: Fx<
|
|
2637
|
-
readonly i1: Fx<
|
|
2623
|
+
readonly i0: Fx<A, E, R>,
|
|
2624
|
+
readonly i1: Fx<B, E2, R2>,
|
|
2638
2625
|
readonly i2: (a: A, b: B) => C
|
|
2639
2626
|
) {
|
|
2640
2627
|
super()
|
|
2641
2628
|
}
|
|
2642
2629
|
|
|
2643
|
-
run<R3>(sink: Sink.Sink<
|
|
2630
|
+
run<R3>(sink: Sink.Sink<C, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
|
|
2644
2631
|
return Effect.flatMap(
|
|
2645
2632
|
Ref.make(Option.none<B>()),
|
|
2646
2633
|
(ref) =>
|
|
@@ -2665,24 +2652,24 @@ class Snapshot<R, E, A, R2, E2, B, C> extends FxBase<R | R2, E | E2, C> {
|
|
|
2665
2652
|
}
|
|
2666
2653
|
}
|
|
2667
2654
|
|
|
2668
|
-
export function snapshotEffect<
|
|
2669
|
-
fx: Fx<
|
|
2670
|
-
sampled: Fx<
|
|
2671
|
-
f: (a: A, b: B) => Effect.Effect<
|
|
2672
|
-
): Fx<
|
|
2655
|
+
export function snapshotEffect<A, E, R, B, E2, R2, C, E3, R3>(
|
|
2656
|
+
fx: Fx<A, E, R>,
|
|
2657
|
+
sampled: Fx<B, E2, R2>,
|
|
2658
|
+
f: (a: A, b: B) => Effect.Effect<C, E3, R3>
|
|
2659
|
+
): Fx<C, E | E2 | E3, R | R2 | R3> {
|
|
2673
2660
|
return new SnapshotEffect(fx, sampled, f)
|
|
2674
2661
|
}
|
|
2675
2662
|
|
|
2676
|
-
class SnapshotEffect<
|
|
2663
|
+
class SnapshotEffect<A, E, R, B, E2, R2, C, E3, R3> extends FxBase<C, E | E2 | E3, R | R2 | R3> {
|
|
2677
2664
|
constructor(
|
|
2678
|
-
readonly i0: Fx<
|
|
2679
|
-
readonly i1: Fx<
|
|
2680
|
-
readonly i2: (a: A, b: B) => Effect.Effect<
|
|
2665
|
+
readonly i0: Fx<A, E, R>,
|
|
2666
|
+
readonly i1: Fx<B, E2, R2>,
|
|
2667
|
+
readonly i2: (a: A, b: B) => Effect.Effect<C, E3, R3>
|
|
2681
2668
|
) {
|
|
2682
2669
|
super()
|
|
2683
2670
|
}
|
|
2684
2671
|
|
|
2685
|
-
run<R4>(sink: Sink.Sink<
|
|
2672
|
+
run<R4>(sink: Sink.Sink<C, E | E2 | E3, R4>): Effect.Effect<unknown, never, R | R2 | R3 | R4> {
|
|
2686
2673
|
return Effect.flatMap(
|
|
2687
2674
|
Ref.make(Option.none<B>()),
|
|
2688
2675
|
(ref) =>
|
|
@@ -2710,38 +2697,38 @@ class SnapshotEffect<R, E, A, R2, E2, B, R3, E3, C> extends FxBase<R | R2 | R3,
|
|
|
2710
2697
|
}
|
|
2711
2698
|
}
|
|
2712
2699
|
|
|
2713
|
-
function if_<
|
|
2714
|
-
bool: Fx<
|
|
2700
|
+
function if_<B, E, R, E2, R2, C, E3, R3>(
|
|
2701
|
+
bool: Fx<boolean, E, R>,
|
|
2715
2702
|
options: {
|
|
2716
|
-
readonly onTrue: Fx<
|
|
2717
|
-
readonly onFalse: Fx<
|
|
2703
|
+
readonly onTrue: Fx<B, E2, R2>
|
|
2704
|
+
readonly onFalse: Fx<C, E3, R3>
|
|
2718
2705
|
}
|
|
2719
|
-
): Fx<
|
|
2706
|
+
): Fx<B | C, E | E2 | E3, R | R2 | R3 | Scope.Scope> {
|
|
2720
2707
|
return switchMap(
|
|
2721
2708
|
skipRepeatsWith(bool, boolean),
|
|
2722
|
-
(b): Fx<
|
|
2709
|
+
(b): Fx<B | C, E2 | E3, R2 | R3> => b ? options.onTrue : options.onFalse
|
|
2723
2710
|
)
|
|
2724
2711
|
}
|
|
2725
2712
|
|
|
2726
2713
|
export { if_ as if }
|
|
2727
2714
|
|
|
2728
|
-
export function when<
|
|
2729
|
-
bool: Fx<
|
|
2715
|
+
export function when<B, E, R, C>(
|
|
2716
|
+
bool: Fx<boolean, E, R>,
|
|
2730
2717
|
options: {
|
|
2731
2718
|
readonly onTrue: B
|
|
2732
2719
|
readonly onFalse: C
|
|
2733
2720
|
}
|
|
2734
|
-
): Fx<
|
|
2721
|
+
): Fx<B | C, E, R | Scope.Scope> {
|
|
2735
2722
|
return if_(bool, {
|
|
2736
2723
|
onTrue: succeed(options.onTrue),
|
|
2737
2724
|
onFalse: succeed(options.onFalse)
|
|
2738
2725
|
})
|
|
2739
2726
|
}
|
|
2740
2727
|
|
|
2741
|
-
export function mapBoth<
|
|
2742
|
-
fx: Fx<
|
|
2728
|
+
export function mapBoth<A, E, R, B, C>(
|
|
2729
|
+
fx: Fx<A, E, R>,
|
|
2743
2730
|
f: (e: E) => B,
|
|
2744
2731
|
g: (a: A) => C
|
|
2745
|
-
): Fx<
|
|
2732
|
+
): Fx<C, B, R> {
|
|
2746
2733
|
return map(mapError(fx, f), g)
|
|
2747
2734
|
}
|