@typed/fx 1.25.0 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/Match.js +2 -5
  2. package/dist/cjs/Match.js.map +1 -1
  3. package/dist/cjs/Pull.js.map +1 -1
  4. package/dist/cjs/RefSubject.js +2 -2
  5. package/dist/cjs/RefSubject.js.map +1 -1
  6. package/dist/cjs/Sink.js +2 -2
  7. package/dist/cjs/Sink.js.map +1 -1
  8. package/dist/cjs/index.js +1 -4
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/internal/core.js +12 -11
  11. package/dist/cjs/internal/core.js.map +1 -1
  12. package/dist/cjs/internal/effect-producer.js +2 -2
  13. package/dist/cjs/internal/effect-producer.js.map +1 -1
  14. package/dist/cjs/internal/helpers.js +1 -1
  15. package/dist/cjs/internal/helpers.js.map +1 -1
  16. package/dist/dts/Fx.d.ts +9 -9
  17. package/dist/dts/Fx.d.ts.map +1 -1
  18. package/dist/dts/Match.d.ts +5 -11
  19. package/dist/dts/Match.d.ts.map +1 -1
  20. package/dist/dts/Pull.d.ts +4 -4
  21. package/dist/dts/Pull.d.ts.map +1 -1
  22. package/dist/dts/index.d.ts +0 -5
  23. package/dist/dts/index.d.ts.map +1 -1
  24. package/dist/dts/internal/core.d.ts +4 -4
  25. package/dist/dts/internal/core.d.ts.map +1 -1
  26. package/dist/dts/internal/effect-producer.d.ts +4 -4
  27. package/dist/dts/internal/effect-producer.d.ts.map +1 -1
  28. package/dist/dts/internal/helpers.d.ts.map +1 -1
  29. package/dist/dts/internal/loop-operator.d.ts +2 -2
  30. package/dist/dts/internal/loop-operator.d.ts.map +1 -1
  31. package/dist/esm/Match.js +1 -5
  32. package/dist/esm/Match.js.map +1 -1
  33. package/dist/esm/Pull.js.map +1 -1
  34. package/dist/esm/RefSubject.js +3 -3
  35. package/dist/esm/RefSubject.js.map +1 -1
  36. package/dist/esm/Sink.js +2 -2
  37. package/dist/esm/Sink.js.map +1 -1
  38. package/dist/esm/index.js +0 -5
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/internal/core.js +12 -11
  41. package/dist/esm/internal/core.js.map +1 -1
  42. package/dist/esm/internal/effect-producer.js +1 -1
  43. package/dist/esm/internal/effect-producer.js.map +1 -1
  44. package/dist/esm/internal/helpers.js +2 -2
  45. package/dist/esm/internal/helpers.js.map +1 -1
  46. package/package.json +7 -14
  47. package/src/Fx.ts +11 -11
  48. package/src/Match.ts +9 -21
  49. package/src/Pull.ts +7 -7
  50. package/src/RefSubject.ts +3 -3
  51. package/src/Sink.ts +3 -3
  52. package/src/Subject.ts +1 -1
  53. package/src/Typeclass.ts +1 -1
  54. package/src/index.ts +0 -6
  55. package/src/internal/core.ts +34 -33
  56. package/src/internal/effect-producer.ts +7 -7
  57. package/src/internal/helpers.ts +3 -3
  58. package/src/internal/loop-operator.ts +2 -2
  59. package/Guard/package.json +0 -6
  60. package/dist/cjs/Guard.js +0 -75
  61. package/dist/cjs/Guard.js.map +0 -1
  62. package/dist/dts/Guard.d.ts +0 -102
  63. package/dist/dts/Guard.d.ts.map +0 -1
  64. package/dist/esm/Guard.js +0 -60
  65. package/dist/esm/Guard.js.map +0 -1
  66. package/src/Guard.ts +0 -170
package/src/Match.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @since 1.18.0
3
3
  */
4
4
 
5
+ import { getGuard, type GuardInput } from "@typed/guard"
5
6
  import * as Cause from "effect/Cause"
6
7
  import * as Chunk from "effect/Chunk"
7
8
  import * as Effect from "effect/Effect"
@@ -14,7 +15,6 @@ import * as Option from "effect/Option"
14
15
  import { isNonEmptyReadonlyArray, reduce } from "effect/ReadonlyArray"
15
16
  import * as Scope from "effect/Scope"
16
17
  import * as Fx from "./Fx.js"
17
- import type { Guard } from "./Guard.js"
18
18
  import { withScopedFork } from "./internal/helpers.js"
19
19
  import { FxBase } from "./internal/protos.js"
20
20
  import * as RefSubject from "./RefSubject.js"
@@ -39,12 +39,12 @@ export interface TypeMatcher<I, O = never, E = never, R = never> {
39
39
  readonly [MatcherTypeId]: Matcher.Variance<I, O, E, R>
40
40
 
41
41
  readonly when: <R2 = never, E2 = never, A = never, R3 = never, E3 = never, B = never>(
42
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
42
+ guard: GuardInput<I, A, E2, R2>,
43
43
  onMatch: (value: RefSubject.RefSubject<A>) => Fx.Fx<B, E3, R3>
44
44
  ) => TypeMatcher<I, O | B, E | E2 | E3, R | R2 | R3>
45
45
 
46
46
  readonly to: <R2 = never, E2 = never, A = never, B = never>(
47
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
47
+ guard: GuardInput<I, A, E2, R2>,
48
48
  onMatch: B
49
49
  ) => TypeMatcher<I, O | B, E | E2, R | R2>
50
50
 
@@ -64,12 +64,12 @@ export interface ValueMatcher<I, O = never, E = never, R = never> extends Fx.Fx<
64
64
  readonly value: Fx.Fx<I, E, R>
65
65
 
66
66
  readonly when: <A, E2, R2, R3 = never, E3 = never, B = never>(
67
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
67
+ guard: GuardInput<I, A, E2, R2>,
68
68
  onMatch: (value: RefSubject.RefSubject<A>) => Fx.Fx<B, E3, R3>
69
69
  ) => ValueMatcher<I, O | B, E | E2 | E3, R | R2 | R3>
70
70
 
71
71
  readonly to: <A, E2, R2, B>(
72
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
72
+ guard: GuardInput<I, A, E2, R2>,
73
73
  onMatch: B
74
74
  ) => ValueMatcher<I, O | B, E | E2, R | R2>
75
75
 
@@ -139,7 +139,7 @@ class TypeMatcherImpl<I, O, E, R> implements TypeMatcher<I, O, E, R> {
139
139
  }
140
140
 
141
141
  when<A, E2, R2, R3 = never, E3 = never, B = never>(
142
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
142
+ guard: GuardInput<I, A, E2, R2>,
143
143
  onMatch: (value: RefSubject.RefSubject<A>) => Fx.Fx<B, E3, R3>
144
144
  ): TypeMatcher<I, O | B, E | E2 | E3, R | R2 | R3> {
145
145
  return new TypeMatcherImpl<I, O | B, E | E2 | E3, R | R2 | R3>(
@@ -148,7 +148,7 @@ class TypeMatcherImpl<I, O, E, R> implements TypeMatcher<I, O, E, R> {
148
148
  }
149
149
 
150
150
  to<A, E2, R2, B>(
151
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
151
+ guard: GuardInput<I, A, E2, R2>,
152
152
  onMatch: B
153
153
  ): TypeMatcher<I, O | B, E | E2, R | R2> {
154
154
  return this.when(guard, () => Fx.succeed(onMatch))
@@ -296,7 +296,7 @@ class ValueMatcherImpl<I, O, E, R> extends FxBase<Option.Option<O>, E, R | Scope
296
296
  }
297
297
 
298
298
  when<A, E2, R2, R3 = never, E3 = never, B = never>(
299
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
299
+ guard: GuardInput<I, A, E2, R2>,
300
300
  onMatch: (value: RefSubject.RefSubject<A>) => Fx.Fx<B, E3, R3>
301
301
  ): ValueMatcher<I, O | B, E | E2 | E3, R | R2 | R3> {
302
302
  return new ValueMatcherImpl<I, O | B, E | E2 | E3, R | R2 | R3>(
@@ -306,7 +306,7 @@ class ValueMatcherImpl<I, O, E, R> extends FxBase<Option.Option<O>, E, R | Scope
306
306
  }
307
307
 
308
308
  to<A, E2, R2, B>(
309
- guard: Guard<I, A, E2, R2> | AsGuard<I, A, E2, R2>,
309
+ guard: GuardInput<I, A, E2, R2>,
310
310
  onMatch: B
311
311
  ): ValueMatcher<I, O | B, E | E2, R | R2> {
312
312
  return this.when(guard, () => Fx.succeed(onMatch))
@@ -314,15 +314,3 @@ class ValueMatcherImpl<I, O, E, R> extends FxBase<Option.Option<O>, E, R | Scope
314
314
 
315
315
  getOrElse: ValueMatcher<I, O, E, R>["getOrElse"] = (f) => Fx.getOrElse(this.matcher.run(this.value), f)
316
316
  }
317
-
318
- /**
319
- * @since 1.18.0
320
- */
321
- export interface AsGuard<I, A, E = never, R = never> {
322
- readonly asGuard: () => Guard<I, A, E, R>
323
- }
324
-
325
- function getGuard<I, A, E = never, R = never>(guard: Guard<I, A, E, R> | AsGuard<I, A, E, R>): Guard<I, A, E, R> {
326
- if (typeof guard === "function") return guard
327
- return guard.asGuard()
328
- }
package/src/Pull.ts CHANGED
@@ -26,7 +26,7 @@ function schedulePull<A, E, R, R2, R3>(
26
26
  f: (effect: Effect.Effect<unknown, never, R | R3>) => Effect.Effect<unknown, never, R2>,
27
27
  sink: Sink<A, E, R3>
28
28
  ): Effect.Effect<void, never, R2> {
29
- return Effect.asyncEffect<void, never, never, void, never, R2>((resume) =>
29
+ return Effect.asyncEffect<void, never, never, R2, never, R2>((resume) =>
30
30
  Effect.matchCauseEffect(pull, {
31
31
  onFailure: (cause: Cause.Cause<Option.Option<E>>) =>
32
32
  Cause.failureOrCause(cause).pipe(
@@ -53,18 +53,18 @@ function schedulePull<A, E, R, R2, R3>(
53
53
  */
54
54
  export const schedule: {
55
55
  <R2, A, E, R3>(
56
- schedule: Schedule.Schedule<R2, unknown, unknown>,
56
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
57
57
  sink: Sink<A, E, R3>
58
58
  ): <R>(pull: Pull<A, E, R>) => Effect.Effect<unknown, never, R | R2 | R3>
59
59
 
60
60
  <A, E, R, R2, R3>(
61
61
  pull: Pull<A, E, R>,
62
- schedule: Schedule.Schedule<R2, unknown, unknown>,
62
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
63
63
  sink: Sink<A, E, R3>
64
64
  ): Effect.Effect<unknown, never, R | R2 | R3>
65
65
  } = dual(3, function schedule<A, E, R, R2, R3>(
66
66
  pull: Pull<A, E, R>,
67
- schedule: Schedule.Schedule<R2, unknown, unknown>,
67
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
68
68
  sink: Sink<A, E, R3>
69
69
  ): Effect.Effect<void, never, R | R2 | R3> {
70
70
  return schedulePull(pull, Effect.schedule(schedule), sink)
@@ -77,18 +77,18 @@ export const schedule: {
77
77
  */
78
78
  export const repeat: {
79
79
  <R2, A, E, R3>(
80
- schedule: Schedule.Schedule<R2, unknown, unknown>,
80
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
81
81
  sink: Sink<A, E, R3>
82
82
  ): <R>(pull: Pull<A, E, R>) => Effect.Effect<unknown, never, R | R2 | R3>
83
83
 
84
84
  <A, E, R, R2, R3>(
85
85
  pull: Pull<A, E, R>,
86
- schedule: Schedule.Schedule<R2, unknown, unknown>,
86
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
87
87
  sink: Sink<A, E, R3>
88
88
  ): Effect.Effect<unknown, never, R | R2 | R3>
89
89
  } = dual(3, function repeat<A, E, R, R2, R3>(
90
90
  pull: Pull<A, E, R>,
91
- schedule: Schedule.Schedule<R2, unknown, unknown>,
91
+ schedule: Schedule.Schedule<unknown, unknown, R2>,
92
92
  sink: Sink<A, E, R3>
93
93
  ): Effect.Effect<void, never, R | R2 | R3> {
94
94
  return schedulePull(pull, Effect.repeat(schedule), sink)
package/src/RefSubject.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import * as C from "@typed/context"
7
7
  import type { Equivalence, FiberId, Runtime } from "effect"
8
- import { Fiber, MutableRef } from "effect"
8
+ import { Fiber, MutableRef, Unify } from "effect"
9
9
  import * as Boolean from "effect/Boolean"
10
10
  import * as Cause from "effect/Cause"
11
11
  import * as Effect from "effect/Effect"
@@ -581,7 +581,7 @@ export const runUpdates: {
581
581
  (initial) =>
582
582
  f(ref).pipe(
583
583
  restore,
584
- Effect.tapErrorCause(Effect.unifiedFn((cause) =>
584
+ Effect.tapErrorCause(Unify.unify((cause) =>
585
585
  Cause.isInterruptedOnly(cause)
586
586
  ? options.onInterrupt(initial)
587
587
  : Effect.unit
@@ -595,7 +595,7 @@ export const runUpdates: {
595
595
  Effect.uninterruptibleMask((restore) =>
596
596
  f(ref).pipe(
597
597
  restore,
598
- Effect.tapErrorCause(Effect.unifiedFn((cause) =>
598
+ Effect.tapErrorCause(Unify.unify((cause) =>
599
599
  Cause.isInterruptedOnly(cause)
600
600
  ? Effect.flatMap(ref.get, options.onInterrupt)
601
601
  : Effect.unit
package/src/Sink.ts CHANGED
@@ -95,16 +95,16 @@ export function withEarlyExit<A, E, R, B, R2>(
95
95
  sink: Sink<A, E, R>,
96
96
  f: (sink: WithEarlyExit<A, E, R>) => Effect.Effect<B, E, R2>
97
97
  ): Effect.Effect<void, never, R | R2> {
98
- return Effect.asyncEffect<void, never, never, void, never, R | R2>((resume) => {
98
+ return Effect.asyncEffect((resume: (effect: Effect.Effect<void>) => void) => {
99
99
  const earlyExit: WithEarlyExit<A, E, R> = {
100
100
  ...sink,
101
101
  earlyExit: Effect.sync(() => resume(Effect.unit))
102
102
  }
103
103
 
104
- return Effect.matchCauseEffect(f(earlyExit), {
104
+ return Effect.asUnit(Effect.matchCauseEffect(f(earlyExit), {
105
105
  onFailure: (cause) => sink.onFailure(cause),
106
106
  onSuccess: () => earlyExit.earlyExit
107
- })
107
+ }))
108
108
  })
109
109
  }
110
110
 
package/src/Subject.ts CHANGED
@@ -111,7 +111,7 @@ export class SubjectImpl<A, E> extends FxBase<A, E, Scope.Scope> implements Subj
111
111
  )
112
112
  )
113
113
 
114
- protected addSink<R, R2, B>(
114
+ protected addSink<R, B, R2>(
115
115
  sink: Sink<A, E, R>,
116
116
  f: (scope: Scope.Scope) => Effect.Effect<B, never, R2>
117
117
  ): Effect.Effect<B, never, R2 | Scope.Scope> {
package/src/Typeclass.ts CHANGED
@@ -302,7 +302,7 @@ export const Applicative: App.Applicative<FxTypeLambda> = {
302
302
  * @category Filterable
303
303
  */
304
304
  export const Filterable: Filter.Filterable<FxTypeLambda> = {
305
- partitionMap: dual(2, <A, E, R, B, C>(self: Fx.Fx<A, E, R>, f: (a: A) => Either<B, C>) => {
305
+ partitionMap: dual(2, <A, E, R, B, C>(self: Fx.Fx<A, E, R>, f: (a: A) => Either<C, B>) => {
306
306
  const m = multicast(Fx.map(self, f))
307
307
 
308
308
  return [
package/src/index.ts CHANGED
@@ -39,12 +39,6 @@ export * as Form from "./Form.js"
39
39
  */
40
40
  export * as FormEntry from "./FormEntry.js"
41
41
 
42
- /**
43
- * [Guard documentation](https://tylors.github.io/typed/fx/Guard.ts.html)
44
- * @since 1.18.0
45
- */
46
- export * as Guard from "./Guard.js"
47
-
48
42
  /**
49
43
  * [Idle documentation](https://tylors.github.io/typed/fx/Idle.ts.html)
50
44
  * @since 1.18.0
@@ -1,16 +1,17 @@
1
1
  import * as Context from "@typed/context"
2
- import type {
3
- ConfigProvider,
4
- Duration,
5
- Equivalence,
6
- FiberId,
7
- FiberRef,
8
- HashSet,
9
- Queue,
10
- Request,
11
- Runtime,
12
- Schedule,
13
- Scheduler
2
+ import {
3
+ type ConfigProvider,
4
+ type Duration,
5
+ type Equivalence,
6
+ type FiberId,
7
+ type FiberRef,
8
+ type HashSet,
9
+ type Queue,
10
+ type Request,
11
+ type Runtime,
12
+ type Schedule,
13
+ type Scheduler,
14
+ Unify
14
15
  } from "effect"
15
16
  import * as Boolean from "effect/Boolean"
16
17
  import * as Cause from "effect/Cause"
@@ -138,12 +139,12 @@ export const fromEffect = <A, E, R>(effect: Effect.Effect<A, E, R>): Fx<A, E, R>
138
139
 
139
140
  export const fromScheduled = <R, E, I, R2, O>(
140
141
  input: Effect.Effect<I, E, R>,
141
- schedule: Schedule.Schedule<R2, I, O>
142
+ schedule: Schedule.Schedule<O, I, R2>
142
143
  ): Fx<O, E, R | R2> => new ProducerEffect(EffectProducer.FromScheduled(input, schedule))
143
144
 
144
145
  export const schedule = <A, E, R, R2, O>(
145
146
  input: Effect.Effect<A, E, R>,
146
- schedule: Schedule.Schedule<R2, unknown, O>
147
+ schedule: Schedule.Schedule<O, unknown, R2>
147
148
  ): Fx<A, E, R | R2> => new ProducerEffect(EffectProducer.Scheduled(input, schedule))
148
149
 
149
150
  class FailCause<E> extends FxBase<never, E, never> {
@@ -325,13 +326,13 @@ class Observe<A, E, R, B, E2, R2> extends EffectBase<void, E | E2, R | R2> {
325
326
  SyncProducer.effectOnce(() => SyncProducer.runEffect(fx.i0, (a) => f(op.f(a)))),
326
327
  Filter: (op) =>
327
328
  SyncProducer.effectOnce(() =>
328
- SyncProducer.runEffect(fx.i0, Effect.unifiedFn((a) => op.f(a) ? f(a) : Effect.unit))
329
+ SyncProducer.runEffect(fx.i0, Unify.unify((a) => op.f(a) ? f(a) : Effect.unit))
329
330
  ),
330
331
  FilterMap: (op) =>
331
332
  SyncProducer.effectOnce(() =>
332
333
  SyncProducer.runEffect(
333
334
  fx.i0,
334
- Effect.unifiedFn((a) => Option.match(op.f(a), { onNone: () => Effect.unit, onSome: f }))
335
+ Unify.unify((a) => Option.match(op.f(a), { onNone: () => Effect.unit, onSome: f }))
335
336
  )
336
337
  )
337
338
  }),
@@ -341,12 +342,12 @@ class Observe<A, E, R, B, E2, R2> extends EffectBase<void, E | E2, R | R2> {
341
342
  SyncProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), f)),
342
343
  FilterMapEffect: (op) =>
343
344
  SyncProducer.runEffect(fx.i0, (a) =>
344
- Effect.flatMap(op.f(a), Effect.unifiedFn(Option.match({ onNone: () => Effect.unit, onSome: f })))),
345
+ Effect.flatMap(op.f(a), Unify.unify(Option.match({ onNone: () => Effect.unit, onSome: f })))),
345
346
  FilterEffect: (op) =>
346
347
  SyncProducer.runEffect(
347
348
  fx.i0,
348
- Effect.unifiedFn((a) =>
349
- Effect.flatMap(op.f(a), Effect.unifiedFn((b) => b ? f(a) : Effect.unit))
349
+ Unify.unify((a) =>
350
+ Effect.flatMap(op.f(a), Unify.unify((b) => b ? f(a) : Effect.unit))
350
351
  )
351
352
  ),
352
353
  TapEffect: (op) => SyncProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), () => f(a)))
@@ -399,13 +400,13 @@ class Observe<A, E, R, B, E2, R2> extends EffectBase<void, E | E2, R | R2> {
399
400
  SyncProducer.effectOnce(() => EffectProducer.runEffect(fx.i0, (a) => f(op.f(a)))),
400
401
  Filter: (op) =>
401
402
  SyncProducer.effectOnce(() =>
402
- EffectProducer.runEffect(fx.i0, Effect.unifiedFn((a) => op.f(a) ? f(a) : Effect.unit))
403
+ EffectProducer.runEffect(fx.i0, Unify.unify((a) => op.f(a) ? f(a) : Effect.unit))
403
404
  ),
404
405
  FilterMap: (op) =>
405
406
  SyncProducer.effectOnce(() =>
406
407
  EffectProducer.runEffect(
407
408
  fx.i0,
408
- Effect.unifiedFn((a) => Option.match(op.f(a), { onNone: () => Effect.unit, onSome: f }))
409
+ Unify.unify((a) => Option.match(op.f(a), { onNone: () => Effect.unit, onSome: f }))
409
410
  )
410
411
  )
411
412
  }),
@@ -415,12 +416,12 @@ class Observe<A, E, R, B, E2, R2> extends EffectBase<void, E | E2, R | R2> {
415
416
  EffectProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), f)),
416
417
  FilterMapEffect: (op) =>
417
418
  EffectProducer.runEffect(fx.i0, (a) =>
418
- Effect.flatMap(op.f(a), Effect.unifiedFn(Option.match({ onNone: () => Effect.unit, onSome: f })))),
419
+ Effect.flatMap(op.f(a), Unify.unify(Option.match({ onNone: () => Effect.unit, onSome: f })))),
419
420
  FilterEffect: (op) =>
420
421
  EffectProducer.runEffect(
421
422
  fx.i0,
422
- Effect.unifiedFn((a) =>
423
- Effect.flatMap(op.f(a), Effect.unifiedFn((b) => b ? f(a) : Effect.unit))
423
+ Unify.unify((a) =>
424
+ Effect.flatMap(op.f(a), Unify.unify((b) => b ? f(a) : Effect.unit))
424
425
  )
425
426
  ),
426
427
  TapEffect: (op) => EffectProducer.runEffect(fx.i0, (a) => Effect.flatMap(op.f(a), () => f(a)))
@@ -1100,8 +1101,8 @@ class OrElse<
1100
1101
 
1101
1102
  run<R3>(sink: Sink.Sink<A | B, E | E2, R3>): Effect.Effect<unknown, never, R | R2 | R3> {
1102
1103
  return Effect.catchAll(
1103
- Effect.asyncEffect<unknown, E, never, void, never, R | R2 | R3>((resume) =>
1104
- Effect.zipRight(
1104
+ Effect.asyncEffect<unknown, E, never, never, never, R | R2 | R3>((resume) =>
1105
+ Effect.asUnit(Effect.zipRight(
1105
1106
  this.i0.run(
1106
1107
  Sink.make(
1107
1108
  (cause) =>
@@ -1113,7 +1114,7 @@ class OrElse<
1113
1114
  )
1114
1115
  ),
1115
1116
  Effect.sync(() => resume(Effect.unit))
1116
- )
1117
+ ))
1117
1118
  ),
1118
1119
  (error: E) => this.i1(error).run(sink)
1119
1120
  )
@@ -2474,17 +2475,17 @@ class FromAsyncIterable<A> extends FxBase<A, never, never> {
2474
2475
  }
2475
2476
 
2476
2477
  run<R>(sink: Sink.Sink<A, never, R>): Effect.Effect<unknown, never, R> {
2477
- return Effect.asyncEffect((cb) => {
2478
+ return Effect.asyncEffect<unknown, never, R, R, never, R>((cb) => {
2478
2479
  const iterator = this.i0[Symbol.asyncIterator]()
2479
2480
  const loop = (result: IteratorResult<A>): Effect.Effect<unknown, never, R> =>
2480
2481
  result.done
2481
2482
  ? Effect.sync(() => cb(Effect.unit))
2482
2483
  : Effect.zipRight(sink.onSuccess(result.value), Effect.flatMap(Effect.promise(() => iterator.next()), loop))
2483
2484
 
2484
- return Effect.flatMap(
2485
+ return Effect.asUnit(Effect.flatMap(
2485
2486
  Effect.promise(() => iterator.next()),
2486
2487
  loop
2487
- )
2488
+ ))
2488
2489
  })
2489
2490
  }
2490
2491
  }
@@ -2499,16 +2500,16 @@ export function first<A, E, R>(fx: Fx<A, E, R>): Effect.Effect<A, E, R> {
2499
2500
  return findFirst(fx, constTrue)
2500
2501
  }
2501
2502
 
2502
- export function either<A, E, R>(fx: Fx<A, E, R>): Fx<Either.Either<E, A>, never, R> {
2503
+ export function either<A, E, R>(fx: Fx<A, E, R>): Fx<Either.Either<A, E>, never, R> {
2503
2504
  return new EitherFx(fx)
2504
2505
  }
2505
2506
 
2506
- class EitherFx<A, E, R> extends FxBase<Either.Either<E, A>, never, R> {
2507
+ class EitherFx<A, E, R> extends FxBase<Either.Either<A, E>, never, R> {
2507
2508
  constructor(readonly i0: Fx<A, E, R>) {
2508
2509
  super()
2509
2510
  }
2510
2511
 
2511
- run<R2>(sink: Sink.Sink<Either.Either<E, A>, never, R2>): Effect.Effect<unknown, never, R | R2> {
2512
+ run<R2>(sink: Sink.Sink<Either.Either<A, E>, never, R2>): Effect.Effect<unknown, never, R | R2> {
2512
2513
  return this.i0.run(
2513
2514
  Sink.make(
2514
2515
  (cause) =>
@@ -20,12 +20,12 @@ export function FromEffect<A, E, R>(source: Effect.Effect<A, E, R>): FromEffect<
20
20
  export interface FromScheduled<I, E, R, O> {
21
21
  readonly _tag: "FromScheduled"
22
22
  readonly input: Effect.Effect<I, E, R>
23
- readonly schedule: Schedule.Schedule<R, I, O>
23
+ readonly schedule: Schedule.Schedule<O, I, R>
24
24
  }
25
25
 
26
26
  export function FromScheduled<I, E, R, R2, O>(
27
27
  input: Effect.Effect<I, E, R>,
28
- schedule: Schedule.Schedule<R2, I, O>
28
+ schedule: Schedule.Schedule<O, I, R2>
29
29
  ): FromScheduled<I, E, R | R2, O> {
30
30
  return { _tag: "FromScheduled", schedule, input }
31
31
  }
@@ -33,12 +33,12 @@ export function FromScheduled<I, E, R, R2, O>(
33
33
  export interface Scheduled<A, E, R, O> {
34
34
  readonly _tag: "Scheduled"
35
35
  readonly input: Effect.Effect<A, E, R>
36
- readonly schedule: Schedule.Schedule<R, unknown, O>
36
+ readonly schedule: Schedule.Schedule<O, unknown, R>
37
37
  }
38
38
 
39
39
  export function Scheduled<A, E, R, R2, O>(
40
40
  input: Effect.Effect<A, E, R>,
41
- schedule: Schedule.Schedule<R2, unknown, O>
41
+ schedule: Schedule.Schedule<O, unknown, R2>
42
42
  ): Scheduled<A, E, R | R2, O> {
43
43
  return { _tag: "Scheduled", schedule, input }
44
44
  }
@@ -91,10 +91,10 @@ export function runEffect<A, E, R, B, E2, R2>(
91
91
  return Effect.flatMap(
92
92
  producer.input,
93
93
  (i) =>
94
- Effect.asyncEffect<unknown, E | E2, never, unknown, never, R | R2>((resume) => {
94
+ Effect.asyncEffect((resume) => {
95
95
  const onFailure = (cause: Cause.Cause<E | E2>) => Effect.succeed(resume(Effect.failCause(cause)))
96
96
 
97
- return Effect.matchCauseEffect(
97
+ return Effect.asUnit(Effect.matchCauseEffect(
98
98
  Effect.scheduleFrom(
99
99
  producer.input,
100
100
  i,
@@ -104,7 +104,7 @@ export function runEffect<A, E, R, B, E2, R2>(
104
104
  )
105
105
  ),
106
106
  { onFailure, onSuccess: () => Effect.succeed(resume(Effect.unit)) }
107
- )
107
+ ))
108
108
  })
109
109
  )
110
110
  case "Scheduled":
@@ -1,5 +1,5 @@
1
1
  import { getOption } from "@typed/context"
2
- import { Equivalence } from "effect"
2
+ import { Equivalence, Unify } from "effect"
3
3
  import type { Duration, Exit } from "effect"
4
4
  import * as Cause from "effect/Cause"
5
5
  import * as Effect from "effect/Effect"
@@ -327,7 +327,7 @@ export function matchEffectPrimitive<A, E, R, Z>(
327
327
  export function adjustTime(input: Duration.DurationInput = 1) {
328
328
  return Effect.flatMap(
329
329
  Effect.context<never>(),
330
- Effect.unifiedFn((ctx) => {
330
+ Unify.unify((ctx) => {
331
331
  const testClock = getOption(ctx, TestClock.TestClock)
332
332
 
333
333
  if (Option.isSome(testClock)) {
@@ -450,7 +450,7 @@ export class RingBuffer<A> {
450
450
  }
451
451
 
452
452
  export function awaitScopeClose(scope: Scope.Scope) {
453
- return Effect.asyncEffect<unknown, never, never, void, never, never>((cb) =>
453
+ return Effect.asyncEffect<unknown, never, never, never, never, never>((cb) =>
454
454
  Scope.addFinalizerExit(scope, () => Effect.sync(() => cb(Effect.unit)))
455
455
  )
456
456
  }
@@ -43,12 +43,12 @@ export function SliceOperator(bounds: Bounds): SliceOperator {
43
43
  export interface FilterMapSliceOperator<A, B, C> {
44
44
  readonly _tag: "FilterMapSlice"
45
45
  readonly seed: B
46
- readonly f: (acc: B, a: A) => Either.Either<Option.Option<C>, readonly [Option.Option<C>, B]>
46
+ readonly f: (acc: B, a: A) => Either.Either<readonly [Option.Option<C>, B], Option.Option<C>>
47
47
  }
48
48
 
49
49
  export function FilterMapSliceOperator<const B, A, C>(
50
50
  seed: B,
51
- f: (acc: B, a: A) => Either.Either<Option.Option<C>, readonly [Option.Option<C>, B]>
51
+ f: (acc: B, a: A) => Either.Either<readonly [Option.Option<C>, B], Option.Option<C>>
52
52
  ): FilterMapSliceOperator<A, B, C> {
53
53
  return { _tag: "FilterMapSlice", seed, f }
54
54
  }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/Guard.js",
3
- "module": "../dist/esm/Guard.js",
4
- "types": "../dist/dts/Guard.d.ts",
5
- "sideEffects": []
6
- }
package/dist/cjs/Guard.js DELETED
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.any = any;
7
- exports.filterMap = exports.filter = exports.compose = void 0;
8
- exports.liftPredicate = liftPredicate;
9
- exports.tap = exports.mapEffect = exports.map = void 0;
10
- var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
11
- var _Function = /*#__PURE__*/require("effect/Function");
12
- var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Option"));
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- /**
16
- * @since 1.18.0
17
- */
18
-
19
- /**
20
- * @since 1.18.0
21
- */
22
- const compose = exports.compose = /*#__PURE__*/(0, _Function.dual)(2, function flatMap(input, output) {
23
- return i => Effect.flatMap(input(i), Option.match({
24
- onNone: () => Effect.succeedNone,
25
- onSome: output
26
- }));
27
- });
28
- /**
29
- * @since 1.18.0
30
- */
31
- const mapEffect = exports.mapEffect = /*#__PURE__*/(0, _Function.dual)(2, function mapEffect(guard, f) {
32
- return compose(guard, o => Effect.asSome(f(o)));
33
- });
34
- /**
35
- * @since 1.18.0
36
- */
37
- const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, function map(guard, f) {
38
- return mapEffect(guard, o => Effect.sync(() => f(o)));
39
- });
40
- /**
41
- * @since 1.18.0
42
- */
43
- const tap = exports.tap = /*#__PURE__*/(0, _Function.dual)(2, function tap(guard, f) {
44
- return compose(guard, o => Effect.as(f(o), Option.some(o)));
45
- });
46
- /**
47
- * @since 1.18.0
48
- */
49
- const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (guard, f) => i => Effect.map(guard(i), Option.filterMap(f)));
50
- /**
51
- * @since 1.18.0
52
- */
53
- const filter = exports.filter = /*#__PURE__*/(0, _Function.dual)(2, (guard, predicate) => i => Effect.map(guard(i), Option.filter(predicate)));
54
- /**
55
- * @since 1.18.0
56
- */
57
- function any(guards) {
58
- const entries = Object.entries(guards);
59
- return i => Effect.gen(function* (_) {
60
- for (const [_tag, guard] of entries) {
61
- const match = yield* _(guard(i));
62
- if (Option.isSome(match)) {
63
- return Option.some({
64
- _tag,
65
- value: match.value
66
- });
67
- }
68
- }
69
- return Option.none();
70
- });
71
- }
72
- function liftPredicate(predicate) {
73
- return a => Effect.sync(() => predicate(a) ? Option.some(a) : Option.none());
74
- }
75
- //# sourceMappingURL=Guard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Guard.js","names":["Effect","_interopRequireWildcard","require","_Function","Option","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","compose","exports","dual","flatMap","input","output","match","onNone","succeedNone","onSome","mapEffect","guard","f","o","asSome","map","sync","tap","as","some","filterMap","filter","predicate","any","guards","entries","gen","_","_tag","isSome","value","none","liftPredicate"],"sources":["../../src/Guard.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AAKA,IAAAA,MAAA,gBAAAC,uBAAA,eAAAC,OAAA;AACA,IAAAC,SAAA,gBAAAD,OAAA;AACA,IAAAE,MAAA,gBAAAH,uBAAA,eAAAC,OAAA;AAAuC,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAA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