@fncts/io 0.0.42 → 0.0.44

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 (110) hide show
  1. package/IO/api.d.ts +11 -5
  2. package/IO.d.ts +1 -0
  3. package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -8
  4. package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
  5. package/_cjs/Channel/api/mergeAllWith.cjs +14 -23
  6. package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
  7. package/_cjs/Channel/api/mergeWith.cjs +4 -16
  8. package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
  9. package/_cjs/Channel/api.cjs +18 -33
  10. package/_cjs/Channel/api.cjs.map +1 -1
  11. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +2 -8
  12. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
  13. package/_cjs/IO/api/asyncInterrupt.cjs +4 -7
  14. package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
  15. package/_cjs/IO/api.cjs +31 -47
  16. package/_cjs/IO/api.cjs.map +1 -1
  17. package/_cjs/IO/runtime.cjs +3 -6
  18. package/_cjs/IO/runtime.cjs.map +1 -1
  19. package/_cjs/IO.cjs +11 -0
  20. package/_cjs/IO.cjs.map +1 -1
  21. package/_cjs/Layer/api.cjs +2 -5
  22. package/_cjs/Layer/api.cjs.map +1 -1
  23. package/_cjs/Push/api.cjs +1 -4
  24. package/_cjs/Push/api.cjs.map +1 -1
  25. package/_cjs/Ref/Derived.cjs +8 -35
  26. package/_cjs/Ref/Derived.cjs.map +1 -1
  27. package/_cjs/Ref/DerivedAll.cjs +8 -35
  28. package/_cjs/Ref/DerivedAll.cjs.map +1 -1
  29. package/_cjs/STM/api/core-api.cjs +1 -4
  30. package/_cjs/STM/api/core-api.cjs.map +1 -1
  31. package/_cjs/STM/api.cjs +4 -16
  32. package/_cjs/STM/api.cjs.map +1 -1
  33. package/_cjs/Schedule/api.cjs +1 -7
  34. package/_cjs/Schedule/api.cjs.map +1 -1
  35. package/_cjs/Sink/api.cjs +1 -7
  36. package/_cjs/Sink/api.cjs.map +1 -1
  37. package/_cjs/Stream/api/zipAllWith.cjs +1 -4
  38. package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
  39. package/_cjs/Stream/api/zipWithChunks.cjs +1 -4
  40. package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
  41. package/_cjs/Stream/api.cjs +16 -37
  42. package/_cjs/Stream/api.cjs.map +1 -1
  43. package/_cjs/TRef/definition.cjs +20 -74
  44. package/_cjs/TRef/definition.cjs.map +1 -1
  45. package/_mjs/Channel/api/mapOutConcurrentIO.mjs +2 -8
  46. package/_mjs/Channel/api/mapOutConcurrentIO.mjs.map +1 -1
  47. package/_mjs/Channel/api/mergeAllWith.mjs +14 -23
  48. package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
  49. package/_mjs/Channel/api/mergeWith.mjs +4 -16
  50. package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
  51. package/_mjs/Channel/api.mjs +18 -33
  52. package/_mjs/Channel/api.mjs.map +1 -1
  53. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +2 -8
  54. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
  55. package/_mjs/IO/api/asyncInterrupt.mjs +4 -7
  56. package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
  57. package/_mjs/IO/api.mjs +29 -45
  58. package/_mjs/IO/api.mjs.map +1 -1
  59. package/_mjs/IO/runtime.mjs +3 -6
  60. package/_mjs/IO/runtime.mjs.map +1 -1
  61. package/_mjs/IO.mjs +1 -0
  62. package/_mjs/IO.mjs.map +1 -1
  63. package/_mjs/Layer/api.mjs +2 -5
  64. package/_mjs/Layer/api.mjs.map +1 -1
  65. package/_mjs/Push/api.mjs +1 -4
  66. package/_mjs/Push/api.mjs.map +1 -1
  67. package/_mjs/Ref/Derived.mjs +8 -35
  68. package/_mjs/Ref/Derived.mjs.map +1 -1
  69. package/_mjs/Ref/DerivedAll.mjs +8 -35
  70. package/_mjs/Ref/DerivedAll.mjs.map +1 -1
  71. package/_mjs/STM/api/core-api.mjs +1 -4
  72. package/_mjs/STM/api/core-api.mjs.map +1 -1
  73. package/_mjs/STM/api.mjs +4 -16
  74. package/_mjs/STM/api.mjs.map +1 -1
  75. package/_mjs/Schedule/api.mjs +1 -7
  76. package/_mjs/Schedule/api.mjs.map +1 -1
  77. package/_mjs/Sink/api.mjs +1 -7
  78. package/_mjs/Sink/api.mjs.map +1 -1
  79. package/_mjs/Stream/api/zipAllWith.mjs +1 -4
  80. package/_mjs/Stream/api/zipAllWith.mjs.map +1 -1
  81. package/_mjs/Stream/api/zipWithChunks.mjs +1 -4
  82. package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -1
  83. package/_mjs/Stream/api.mjs +16 -37
  84. package/_mjs/Stream/api.mjs.map +1 -1
  85. package/_mjs/TRef/definition.mjs +20 -74
  86. package/_mjs/TRef/definition.mjs.map +1 -1
  87. package/_src/Channel/api/mapOutConcurrentIO.ts +5 -5
  88. package/_src/Channel/api/mergeAllWith.ts +9 -9
  89. package/_src/Channel/api/mergeWith.ts +16 -16
  90. package/_src/Channel/api.ts +12 -32
  91. package/_src/Channel/internal/SingleProducerAsyncInput.ts +2 -2
  92. package/_src/IO/api/asyncInterrupt.ts +4 -4
  93. package/_src/IO/api.ts +46 -40
  94. package/_src/IO/runtime.ts +3 -6
  95. package/_src/IO.ts +1 -0
  96. package/_src/Layer/api.ts +1 -4
  97. package/_src/Push/api.ts +4 -4
  98. package/_src/Ref/Derived.ts +18 -20
  99. package/_src/Ref/DerivedAll.ts +18 -21
  100. package/_src/STM/api/core-api.ts +1 -1
  101. package/_src/STM/api.ts +4 -4
  102. package/_src/Schedule/api.ts +8 -8
  103. package/_src/Sink/api.ts +8 -8
  104. package/_src/Stream/api/zipAllWith.ts +4 -4
  105. package/_src/Stream/api/zipWithChunks.ts +4 -4
  106. package/_src/Stream/api.ts +20 -22
  107. package/_src/TRef/definition.ts +33 -36
  108. package/_src/index.ts +1 -0
  109. package/index.d.ts +1 -0
  110. package/package.json +4 -4
package/_src/IO/api.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Running } from "../FiberStatus.js";
2
+ import type { ShowOptions } from "@fncts/base/data/Showable.js";
2
3
  import type * as P from "@fncts/base/typeclass";
3
4
  import type { _E, _R } from "@fncts/base/types";
4
5
  import type { FiberRuntime } from "@fncts/io/Fiber/FiberRuntime";
@@ -6,6 +7,7 @@ import type { RuntimeFlags } from "@fncts/io/RuntimeFlags";
6
7
 
7
8
  import { IOError } from "@fncts/base/data/exceptions";
8
9
  import { identity, pipe, tuple } from "@fncts/base/data/function";
10
+ import { showWithOptions } from "@fncts/base/data/Showable";
9
11
  import { IOPrimitive, IOTag } from "@fncts/io/IO/definition";
10
12
  import { IO } from "@fncts/io/IO/definition";
11
13
 
@@ -20,8 +22,8 @@ export function async<R, E, A>(
20
22
  __tsplusTrace?: string,
21
23
  ): IO<R, E, A> {
22
24
  const io = new IOPrimitive(IOTag.Async) as any;
23
- io.i0 = register;
24
- io.i1 = () => blockingOn;
25
+ io.i0 = register;
26
+ io.i1 = () => blockingOn;
25
27
  io.trace = __tsplusTrace;
26
28
  return io;
27
29
  }
@@ -122,10 +124,10 @@ export function bitap<E, A, R1, E1, R2, E2>(
122
124
  return <R>(self: IO<R, E, A>): IO<R | R1 | R2, E | E1 | E2, A> => {
123
125
  return self.matchCauseIO(
124
126
  (cause) =>
125
- cause.failureOrCause.match({
126
- Left: (e) => onFailure(e).flatMap(() => IO.failCauseNow(cause)),
127
- Right: () => IO.failCauseNow(cause),
128
- }),
127
+ cause.failureOrCause.match(
128
+ (e) => onFailure(e).flatMap(() => IO.failCauseNow(cause)),
129
+ () => IO.failCauseNow(cause),
130
+ ),
129
131
  (a) => onSuccess(a).zipRight(IO.succeedNow(a)),
130
132
  );
131
133
  };
@@ -200,8 +202,7 @@ export function catchAllCause<R, E, A, R1, E1, A1>(f: (_: Cause<E>) => IO<R1, E1
200
202
  export function catchJust<E, R1, E1, A1>(f: (e: E) => Maybe<IO<R1, E1, A1>>, __tsplusTrace?: string) {
201
203
  return <R, A>(ma: IO<R, E, A>): IO<R | R1, E | E1, A | A1> => {
202
204
  return ma.matchCauseIO(
203
- (cause) =>
204
- cause.failureOrCause.match({ Left: (e) => f(e).getOrElse(IO.failCauseNow(cause)), Right: IO.failCauseNow }),
205
+ (cause) => cause.failureOrCause.match((e) => f(e).getOrElse(IO.failCauseNow(cause)), IO.failCauseNow),
205
206
  IO.succeedNow,
206
207
  );
207
208
  };
@@ -315,9 +316,10 @@ export function checkInterruptible<R, E, A>(
315
316
  export function flatMap<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
316
317
  return <R, E>(ma: IO<R, E, A>): IO<R | R1, E | E1, B> => {
317
318
  const io = new IOPrimitive(IOTag.OnSuccess) as any;
318
- io.i0 = ma;
319
- io.i1 = f;
319
+ io.i0 = ma;
320
+ io.i1 = f;
320
321
  io.trace = __tsplusTrace;
322
+
321
323
  return io;
322
324
  };
323
325
  }
@@ -363,8 +365,8 @@ export function condIO<R, R1, E, A>(
363
365
 
364
366
  /**
365
367
  * Returns a lazily constructed effect, whose construction may itself require
366
- * effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == unknown)
367
- * it is conceptually equivalent to `flatten(succeedWith(io))`. If you wonder if the effect throws exceptions,
368
+ * effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == never)
369
+ * it is conceptually equivalent to `flatten(succeed(io))`. If you wonder if the effect throws exceptions,
368
370
  * do not use this method, use `IO.deferTryCatch`.
369
371
  *
370
372
  * @tsplus static fncts.io.IOOps defer
@@ -375,7 +377,7 @@ export function defer<R = never, E = never, A = never>(io: Lazy<IO<R, E, A>>, __
375
377
 
376
378
  /**
377
379
  * Returns a lazily constructed effect, whose construction may itself require effects.
378
- * When no environment is required (i.e., when R == unknown) it is conceptually equivalent to `flatten(try(io))`.
380
+ * When no environment is required (i.e., when R == never) it is conceptually equivalent to `flatten(tryCatch(io))`.
379
381
  *
380
382
  * @tsplus static fncts.io.IOOps deferTry
381
383
  */
@@ -396,7 +398,7 @@ export function deferTry<R = never, E = never, A = never>(
396
398
  * Returns a lazily constructed effect, whose construction may itself require effects,
397
399
  * translating any thrown exceptions into typed failed effects and mapping the error.
398
400
  *
399
- * When no environment is required (i.e., when R == unknown) it is conceptually equivalent to `flatten(effect(io))`.
401
+ * When no environment is required (i.e., when R == never) it is conceptually equivalent to `flatten(try(io))`.
400
402
  *
401
403
  * @tsplus static IOOps deferTryCatch
402
404
  */
@@ -467,7 +469,7 @@ export function failNow<E>(e: E, __tsplusTrace?: string): FIO<E, never> {
467
469
  */
468
470
  export function refailCause<E>(cause: Cause<E>, __tsplusTrace?: string): FIO<E, never> {
469
471
  const io = new IOPrimitive(IOTag.Fail) as any;
470
- io.i0 = () => cause;
472
+ io.i0 = () => cause;
471
473
  io.trace = __tsplusTrace;
472
474
  return io;
473
475
  }
@@ -479,7 +481,7 @@ export function refailCause<E>(cause: Cause<E>, __tsplusTrace?: string): FIO<E,
479
481
  */
480
482
  export function failCauseNow<E>(cause: Cause<E>, __tsplusTrace?: string): FIO<E, never> {
481
483
  const io = new IOPrimitive(IOTag.Fail) as any;
482
- io.i0 = () => cause;
484
+ io.i0 = () => cause;
483
485
  io.trace = __tsplusTrace;
484
486
  return io;
485
487
  }
@@ -805,7 +807,7 @@ export function forever<R, E, A>(ma: IO<R, E, A>, __tsplusTrace?: string): IO<R,
805
807
  * @tsplus static fncts.io.IOOps fromEither
806
808
  */
807
809
  export function fromEither<E, A>(either: Lazy<Either<E, A>>, __tsplusTrace?: string): IO<never, E, A> {
808
- return IO.succeed(either).flatMap((ea) => ea.match({ Left: IO.failNow, Right: IO.succeedNow }));
810
+ return IO.succeed(either).flatMap((ea) => ea.match(IO.failNow, IO.succeedNow));
809
811
  }
810
812
 
811
813
  /**
@@ -815,7 +817,7 @@ export function fromEither<E, A>(either: Lazy<Either<E, A>>, __tsplusTrace?: str
815
817
  * @tsplus getter fncts.Either toIO
816
818
  */
817
819
  export function fromEitherNow<E, A>(either: Either<E, A>, __tsplusTrace?: string): IO<never, E, A> {
818
- return either.match({ Left: IO.failNow, Right: IO.succeedNow });
820
+ return either.match(IO.failNow, IO.succeedNow);
819
821
  }
820
822
 
821
823
  /**
@@ -1098,6 +1100,13 @@ export function log(message: Lazy<string>, __tsplusTrace?: string): UIO<void> {
1098
1100
  });
1099
1101
  }
1100
1102
 
1103
+ /**
1104
+ * @tsplus static fncts.io.IOOps show
1105
+ */
1106
+ export function show(message: Lazy<unknown>, options?: Partial<ShowOptions>, __tsplusTrace?: string): UIO<void> {
1107
+ return IO.log(showWithOptions(message, options));
1108
+ }
1109
+
1101
1110
  /**
1102
1111
  * Loops with the specified effectual function, collecting the results into a
1103
1112
  * list. The moral equivalent of:
@@ -1240,9 +1249,9 @@ export function matchCauseIO<E, A, R1, E1, A1, R2, E2, A2>(
1240
1249
  ) {
1241
1250
  return <R>(self: IO<R, E, A>): IO<R | R1 | R2, E1 | E2, A1 | A2> => {
1242
1251
  const io = new IOPrimitive(IOTag.OnSuccessAndFailure) as any;
1243
- io.i0 = self;
1244
- io.i1 = onFailure;
1245
- io.i2 = onSuccess;
1252
+ io.i0 = self;
1253
+ io.i1 = onFailure;
1254
+ io.i2 = onSuccess;
1246
1255
  io.trace = __tsplusTrace;
1247
1256
  return io;
1248
1257
  };
@@ -1257,10 +1266,7 @@ export function matchIO<R1, R2, E, E1, E2, A, A1, A2>(
1257
1266
  __tsplusTrace?: string,
1258
1267
  ) {
1259
1268
  return <R>(self: IO<R, E, A>): IO<R | R1 | R2, E1 | E2, A1 | A2> => {
1260
- return self.matchCauseIO(
1261
- (cause) => cause.failureOrCause.match({ Left: onFailure, Right: IO.failCauseNow }),
1262
- onSuccess,
1263
- );
1269
+ return self.matchCauseIO((cause) => cause.failureOrCause.match(onFailure, IO.failCauseNow), onSuccess);
1264
1270
  };
1265
1271
  }
1266
1272
 
@@ -1292,7 +1298,7 @@ export function matchTraceIO<E, A, R1, E1, A1, R2, E2, A2>(
1292
1298
  ) {
1293
1299
  return <R>(ma: IO<R, E, A>): IO<R | R1 | R2, E1 | E2, A1 | A2> => {
1294
1300
  return ma.matchCauseIO(
1295
- (cause) => cause.failureTraceOrCause.match({ Left: ([e, trace]) => onFailure(e, trace), Right: IO.failCauseNow }),
1301
+ (cause) => cause.failureTraceOrCause.match(([e, trace]) => onFailure(e, trace), IO.failCauseNow),
1296
1302
  onSuccess,
1297
1303
  );
1298
1304
  };
@@ -1689,7 +1695,7 @@ export function sequenceIterableDiscard<R, E, A>(as: Iterable<IO<R, E, A>>, __ts
1689
1695
  */
1690
1696
  export function succeedNow<A>(value: A, __tsplusTrace?: string): IO<never, never, A> {
1691
1697
  const io = new IOPrimitive(IOTag.SucceedNow) as any;
1692
- io.i0 = value;
1698
+ io.i0 = value;
1693
1699
  io.trace = __tsplusTrace;
1694
1700
  return io;
1695
1701
  }
@@ -1697,14 +1703,14 @@ export function succeedNow<A>(value: A, __tsplusTrace?: string): IO<never, never
1697
1703
  /**
1698
1704
  * Imports a total synchronous effect into a pure `IO` value.
1699
1705
  * The effect must not throw any exceptions. If you wonder if the effect
1700
- * throws exceptions, then do not use this method, use `IO.try`
1706
+ * throws exceptions, then do not use this method, use `IO.tryCatch`
1701
1707
  *
1702
1708
  * @tsplus static fncts.io.IOOps succeed
1703
1709
  * @tsplus static fncts.io.IOOps __call
1704
1710
  */
1705
1711
  export function succeed<A>(effect: Lazy<A>, __tsplusTrace?: string): UIO<A> {
1706
1712
  const io = new IOPrimitive(IOTag.Sync) as any;
1707
- io.i0 = effect;
1713
+ io.i0 = effect;
1708
1714
  io.trace = __tsplusTrace;
1709
1715
  return io;
1710
1716
  }
@@ -1717,7 +1723,7 @@ export function summarized<R1, E1, B, C>(summary: IO<R1, E1, B>, f: (start: B, e
1717
1723
  return gen(function* (_) {
1718
1724
  const start = yield* _(summary);
1719
1725
  const value = yield* _(ma);
1720
- const end = yield* _(summary);
1726
+ const end = yield* _(summary);
1721
1727
  return tuple(f(start, end), value);
1722
1728
  });
1723
1729
  };
@@ -1782,7 +1788,7 @@ export function tryCatch<E, A>(effect: Lazy<A>, onThrow: (error: unknown) => E,
1782
1788
  } catch (u) {
1783
1789
  return IO.withFiberRuntime((fiberState) => {
1784
1790
  if (!fiberState.isFatal(u)) {
1785
- throw new IOError(Cause.fail(u));
1791
+ throw new IOError(Cause.fail(onThrow(u)));
1786
1792
  } else {
1787
1793
  throw u;
1788
1794
  }
@@ -1797,7 +1803,7 @@ export function tryCatch<E, A>(effect: Lazy<A>, onThrow: (error: unknown) => E,
1797
1803
  * @tsplus getter fncts.io.IO absolve
1798
1804
  */
1799
1805
  export function absolve<R, E, E1, A>(ma: IO<R, E, Either<E1, A>>, __tsplusTrace?: string): IO<R, E | E1, A> {
1800
- return ma.flatMap((ea) => ea.match({ Left: IO.failNow, Right: IO.succeedNow }));
1806
+ return ma.flatMap((ea) => ea.match(IO.failNow, IO.succeedNow));
1801
1807
  }
1802
1808
 
1803
1809
  /**
@@ -1835,10 +1841,10 @@ export function tapError<E, R1, E1>(f: (e: E) => IO<R1, E1, any>, __tsplusTrace?
1835
1841
  return <R, A>(self: IO<R, E, A>) =>
1836
1842
  self.matchCauseIO(
1837
1843
  (cause) =>
1838
- cause.failureOrCause.match({
1839
- Left: (e) => f(e).flatMap(() => IO.failCauseNow(cause)),
1840
- Right: (_) => IO.failCauseNow(cause),
1841
- }),
1844
+ cause.failureOrCause.match(
1845
+ (e) => f(e).flatMap(() => IO.failCauseNow(cause)),
1846
+ (_) => IO.failCauseNow(cause),
1847
+ ),
1842
1848
  IO.succeedNow,
1843
1849
  );
1844
1850
  }
@@ -1958,7 +1964,7 @@ export function withFiberRuntime<R, E, A>(
1958
1964
  __tsplusTrace?: string,
1959
1965
  ): IO<R, E, A> {
1960
1966
  const io = new IOPrimitive(IOTag.Stateful) as any;
1961
- io.i0 = onState;
1967
+ io.i0 = onState;
1962
1968
  io.trace = __tsplusTrace;
1963
1969
  return io;
1964
1970
  }
@@ -1968,7 +1974,7 @@ export function withFiberRuntime<R, E, A>(
1968
1974
  */
1969
1975
  export function updateRuntimeFlags(patch: RuntimeFlags.Patch, __tsplusTrace?: string): IO<never, never, void> {
1970
1976
  const io = new IOPrimitive(IOTag.UpdateRuntimeFlags) as any;
1971
- io.i0 = patch;
1977
+ io.i0 = patch;
1972
1978
  io.trace = __tsplusTrace;
1973
1979
  return io;
1974
1980
  }
@@ -2045,8 +2051,8 @@ export function gen<T extends GenIO<any, any, any>, A>(
2045
2051
  ): IO<_R<T>, _E<T>, A> {
2046
2052
  return IO.defer(() => {
2047
2053
  const iterator = f(adapter as any);
2048
- const state = iterator.next();
2049
- const run = (state: IteratorYieldResult<T> | IteratorReturnResult<A>): IO<any, any, A> => {
2054
+ const state = iterator.next();
2055
+ const run = (state: IteratorYieldResult<T> | IteratorReturnResult<A>): IO<any, any, A> => {
2050
2056
  if (state.done) {
2051
2057
  return IO.succeed(state.value);
2052
2058
  }
@@ -96,12 +96,9 @@ export class Runtime<R> {
96
96
  };
97
97
 
98
98
  unsafeRun = <E, A>(io: IO<R, E, A>, __tsplusTrace?: string): Exit<E, A> => {
99
- return this.unsafeRunOrFork(io).match({
100
- Left: () => {
101
- throw new Error("Encountered async boundary");
102
- },
103
- Right: Function.identity,
104
- });
99
+ return this.unsafeRunOrFork(io).match(() => {
100
+ throw new Error("Encountered async boundary");
101
+ }, Function.identity);
105
102
  };
106
103
  }
107
104
 
package/_src/IO.ts CHANGED
@@ -50,6 +50,7 @@ export * from "./IO/api/foreachConcurrent.js";
50
50
  export * from "./IO/api/environment.js";
51
51
  export * from "./IO/api/ensuringChildren.js";
52
52
  export * from "./IO/api/disconnect.js";
53
+ export * from "./IO/api/diffFiberRefs.js";
53
54
  export * from "./IO/api/descriptor.js";
54
55
  export * from "./IO/api/delay.js";
55
56
  export * from "./IO/api/daemonChildren.js";
package/_src/Layer/api.ts CHANGED
@@ -206,10 +206,7 @@ export function matchLayer<E, ROut, RIn1, E1, ROut1, RIn2, E2, ROut2>(
206
206
  __tsplusTrace?: string,
207
207
  ) {
208
208
  return <RIn>(self: Layer<RIn, E, ROut>): Layer<RIn | RIn1 | RIn2, E1 | E2, ROut1 | ROut2> => {
209
- return self.matchCauseLayer(
210
- (cause) => cause.failureOrCause.match({ Left: failure, Right: Layer.failCauseNow }),
211
- success,
212
- );
209
+ return self.matchCauseLayer((cause) => cause.failureOrCause.match(failure, Layer.failCauseNow), success);
213
210
  };
214
211
  }
215
212
 
package/_src/Push/api.ts CHANGED
@@ -36,10 +36,10 @@ export function asyncInterrupt<R, E, A>(
36
36
  };
37
37
  const eitherPush = Δ(IO(make(unsafeSink)));
38
38
  Δ(
39
- eitherPush.match({
40
- Left: (canceller) => future.await.onInterrupt(canceller),
41
- Right: (push) => push.run(sink),
42
- }),
39
+ eitherPush.match(
40
+ (canceller) => future.await.onInterrupt(canceller),
41
+ (push) => push.run(sink),
42
+ ),
43
43
  );
44
44
  }).scoped,
45
45
  );
@@ -35,8 +35,8 @@ export class Derived<EA, EB, A, B> extends RefInternal<never, never, EA, EB, A,
35
35
  new Derived<EC, ED, C, D>((f) =>
36
36
  f(
37
37
  value,
38
- (s) => getEither(s).match({ Left: (e) => Either.left(eb(e)), Right: bd }),
39
- (c) => ca(c).flatMap((a) => setEither(a).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
38
+ (s) => getEither(s).match((e) => Either.left(eb(e)), bd),
39
+ (c) => ca(c).flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
40
40
  ),
41
41
  ),
42
42
  );
@@ -54,43 +54,41 @@ export class Derived<EA, EB, A, B> extends RefInternal<never, never, EA, EB, A,
54
54
  new DerivedAll<EC, ED, C, D>((f) =>
55
55
  f(
56
56
  value,
57
- (s) => getEither(s).match({ Left: (e) => Either.left(eb(e)), Right: bd }),
57
+ (s) => getEither(s).match((e) => Either.left(eb(e)), bd),
58
58
  (c) => (s) =>
59
59
  getEither(s)
60
- .match({
61
- Left: (eb) => Either.left(ec(eb)),
62
- Right: (b) => ca(c)(b),
63
- })
64
- .flatMap((a) => setEither(a).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
60
+ .match(
61
+ (eb) => Either.left(ec(eb)),
62
+ (b) => ca(c)(b),
63
+ )
64
+ .flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
65
65
  ),
66
66
  ),
67
67
  );
68
68
  }
69
69
 
70
70
  get get(): FIO<EB, B> {
71
- return this.use((value, getEither) =>
72
- value.get.flatMap((s) => getEither(s).match({ Left: IO.failNow, Right: IO.succeedNow })),
73
- );
71
+ return this.use((value, getEither) => value.get.flatMap((s) => getEither(s).match(IO.failNow, IO.succeedNow)));
74
72
  }
75
73
 
76
74
  set(a: A): FIO<EA, void> {
77
- return this.use((value, _, setEither) => setEither(a).match({ Left: IO.failNow, Right: (s) => value.set(s) }));
75
+ return this.use((value, _, setEither) => setEither(a).match(IO.failNow, (s) => value.set(s)));
78
76
  }
79
77
 
80
78
  modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): IO<never, EA | EB, C> {
81
79
  return this.use(
82
80
  (value, getEither, setEither) =>
83
81
  value.modify((s) =>
84
- getEither(s).match({
85
- Left: (e) => tuple(Either.left(e), s),
86
- Right: (a1) => {
82
+ getEither(s).match(
83
+ (e) => tuple(Either.left(e), s),
84
+ (a1) => {
87
85
  const [b, a2] = f(a1);
88
- return setEither(a2).match({
89
- Left: (e) => tuple(Either.left(e), s),
90
- Right: (s) => tuple(Either.right<EA | EB, C>(b), s),
91
- });
86
+ return setEither(a2).match(
87
+ (e) => tuple(Either.left(e), s),
88
+ (s) => tuple(Either.right<EA | EB, C>(b), s),
89
+ );
92
90
  },
93
- }),
91
+ ),
94
92
  ).absolve,
95
93
  );
96
94
  }
@@ -34,9 +34,8 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
34
34
  new DerivedAll((f) =>
35
35
  f(
36
36
  value,
37
- (s) => getEither(s).match({ Left: (e) => Either.left(eb(e)), Right: bd }),
38
- (c) => (s) =>
39
- ca(c).flatMap((a) => setEither(a)(s).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
37
+ (s) => getEither(s).match((e) => Either.left(eb(e)), bd),
38
+ (c) => (s) => ca(c).flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
40
39
  ),
41
40
  ),
42
41
  );
@@ -54,30 +53,28 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
54
53
  new DerivedAll((f) =>
55
54
  f(
56
55
  value,
57
- (s) => getEither(s).match({ Left: (e) => Either.left(eb(e)), Right: bd }),
56
+ (s) => getEither(s).match((e) => Either.left(eb(e)), bd),
58
57
  (c) => (s) =>
59
58
  getEither(s)
60
- .match({ Left: (e) => Either.left(ec(e)), Right: ca(c) })
61
- .flatMap((a) => setEither(a)(s).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
59
+ .match((e) => Either.left(ec(e)), ca(c))
60
+ .flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
62
61
  ),
63
62
  ),
64
63
  );
65
64
  }
66
65
 
67
66
  get get(): FIO<EB, B> {
68
- return this.use((value, getEither) =>
69
- value.get.flatMap((s) => getEither(s).match({ Left: IO.failNow, Right: IO.succeedNow })),
70
- );
67
+ return this.use((value, getEither) => value.get.flatMap((s) => getEither(s).match(IO.failNow, IO.succeedNow)));
71
68
  }
72
69
 
73
70
  set(a: A): FIO<EA, void> {
74
71
  return this.use(
75
72
  (value, _, setEither) =>
76
73
  value.modify((s) =>
77
- setEither(a)(s).match({
78
- Left: (e) => [Either.left(e), s] as [Either<EA, void>, typeof s],
79
- Right: (s) => [Either.right(undefined), s],
80
- }),
74
+ setEither(a)(s).match(
75
+ (e) => [Either.left(e), s] as [Either<EA, void>, typeof s],
76
+ (s) => [Either.right(undefined), s],
77
+ ),
81
78
  ).absolve,
82
79
  );
83
80
  }
@@ -86,16 +83,16 @@ export class DerivedAll<EA, EB, A, B> extends RefInternal<never, never, EA, EB,
86
83
  return this.use(
87
84
  (value, getEither, setEither) =>
88
85
  value.modify((s) =>
89
- getEither(s).match({
90
- Left: (e) => tuple(Either.left(e), s),
91
- Right: (a1) => {
86
+ getEither(s).match(
87
+ (e) => tuple(Either.left(e), s),
88
+ (a1) => {
92
89
  const [b, a2] = f(a1);
93
- return setEither(a2)(s).match({
94
- Left: (e) => tuple(Either.left(e), s),
95
- Right: (s) => tuple(Either.right<EA | EB, C>(b), s),
96
- });
90
+ return setEither(a2)(s).match(
91
+ (e) => tuple(Either.left(e), s),
92
+ (s) => tuple(Either.right<EA | EB, C>(b), s),
93
+ );
97
94
  },
98
- }),
95
+ ),
99
96
  ).absolve,
100
97
  );
101
98
  }
@@ -65,6 +65,6 @@ export function matchSTM<E, A, R1, E1, B, R2, E2, C>(
65
65
  return self
66
66
  .map(Either.right)
67
67
  .catchAll((e) => g(e).map(Either.left))
68
- .flatMap((ca) => ca.match({ Left: STM.succeedNow, Right: f }));
68
+ .flatMap((ca) => ca.match(STM.succeedNow, f));
69
69
  };
70
70
  }
package/_src/STM/api.ts CHANGED
@@ -429,7 +429,7 @@ export function foreach<A, R, E, B>(
429
429
  * @tsplus static fncts.io.STMOps fromEither
430
430
  */
431
431
  export function fromEither<E, A>(e: Lazy<Either<E, A>>, __tsplusTrace?: string): STM<never, E, A> {
432
- return STM.defer(e().match({ Left: STM.failNow, Right: STM.succeedNow }));
432
+ return STM.defer(e().match(STM.failNow, STM.succeedNow));
433
433
  }
434
434
 
435
435
  /**
@@ -438,7 +438,7 @@ export function fromEither<E, A>(e: Lazy<Either<E, A>>, __tsplusTrace?: string):
438
438
  * @tsplus static fncts.io.STMOps fromEitherNow
439
439
  */
440
440
  export function fromEitherNow<E, A>(e: Either<E, A>, __tsplusTrace?: string): STM<never, E, A> {
441
- return e.match({ Left: STM.failNow, Right: STM.succeedNow });
441
+ return e.match(STM.failNow, STM.succeedNow);
442
442
  }
443
443
 
444
444
  /**
@@ -553,7 +553,7 @@ export function isSuccess<R, E, A>(stm: STM<R, E, A>, __tsplusTrace?: string) {
553
553
  export function left<R, E, B, C>(stm: STM<R, E, Either<B, C>>, __tsplusTrace?: string): STM<R, Maybe<E>, B> {
554
554
  return stm.matchSTM(
555
555
  (e) => STM.fail(Just(e)),
556
- (bc) => bc.match({ Left: STM.succeedNow, Right: () => STM.failNow(Nothing()) }),
556
+ (bc) => bc.match(STM.succeedNow, () => STM.failNow(Nothing())),
557
557
  );
558
558
  }
559
559
 
@@ -564,7 +564,7 @@ export function left<R, E, B, C>(stm: STM<R, E, Either<B, C>>, __tsplusTrace?: s
564
564
  */
565
565
  export function leftOrFail<C, E1>(orFail: (c: C) => E1, __tsplusTrace?: string) {
566
566
  return <R, E, B>(stm: STM<R, E, Either<B, C>>): STM<R, E | E1, B> => {
567
- return stm.flatMap((bc) => bc.match({ Left: STM.succeedNow, Right: (c) => STM.fail(orFail(c)) }));
567
+ return stm.flatMap((bc) => bc.match(STM.succeedNow, (c) => STM.fail(orFail(c))));
568
568
  };
569
569
  }
570
570
 
@@ -618,17 +618,17 @@ export function reconsiderIO<S, O, R1, O1>(
618
618
  decision.match(
619
619
  () =>
620
620
  f(state, out, decision).map((r) =>
621
- r.match({
622
- Left: (out1) => [state, out1, Decision.Done],
623
- Right: ([out1, _]) => [state, out1, Decision.Done],
624
- }),
621
+ r.match(
622
+ (out1) => [state, out1, Decision.Done],
623
+ ([out1, _]) => [state, out1, Decision.Done],
624
+ ),
625
625
  ),
626
626
  () =>
627
627
  f(state, out, decision).map((r) =>
628
- r.match({
629
- Left: (out1) => [state, out1, Decision.Done],
630
- Right: ([out1, interval]) => [state, out1, Decision.continueWith(interval)],
631
- }),
628
+ r.match(
629
+ (out1) => [state, out1, Decision.Done],
630
+ ([out1, interval]) => [state, out1, Decision.continueWith(interval)],
631
+ ),
632
632
  ),
633
633
  ),
634
634
  ),
package/_src/Sink/api.ts CHANGED
@@ -567,20 +567,20 @@ function fromPushPull<R, E, In, L, Z>(
567
567
  (inp: Conc<In>) =>
568
568
  Channel.fromIO(push(Just(inp))).matchChannel(
569
569
  ([r, leftovers]) =>
570
- r.match({
571
- Left: (e) => Channel.writeNow(leftovers) > Channel.failNow(e),
572
- Right: (z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
573
- }),
570
+ r.match(
571
+ (e) => Channel.writeNow(leftovers) > Channel.failNow(e),
572
+ (z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
573
+ ),
574
574
  () => fromPushPull(push),
575
575
  ),
576
576
  Channel.failNow,
577
577
  () =>
578
578
  Channel.fromIO(push(Nothing())).matchChannel(
579
579
  ([r, leftovers]) =>
580
- r.match({
581
- Left: (e) => Channel.writeNow(leftovers) > Channel.failNow(e),
582
- Right: (z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
583
- }),
580
+ r.match(
581
+ (e) => Channel.writeNow(leftovers) > Channel.failNow(e),
582
+ (z) => Channel.writeNow(leftovers) > Channel.succeedNow(z),
583
+ ),
584
584
  () => Channel.fromIO(IO.halt(new Error("empty sink"))),
585
585
  ),
586
586
  );
@@ -132,8 +132,8 @@ function zipWithChunks<A, B, C>(
132
132
  __tsplusTrace?: string,
133
133
  ): readonly [Conc<C>, State<A, B>] {
134
134
  const [out, r] = zipChunks(leftChunk, rightChunk, f);
135
- return r.match({
136
- Left: (leftChunk) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
137
- Right: (rightChunk) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
138
- });
135
+ return r.match(
136
+ (leftChunk) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
137
+ (rightChunk) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
138
+ );
139
139
  }
@@ -73,10 +73,10 @@ function handleSuccess<A1, A2, A3>(
73
73
  __tsplusTrace?: string,
74
74
  ): readonly [Conc<A3>, State<A1, A2>] {
75
75
  const [out, remaining] = f(leftChunk, rightChunk);
76
- return remaining.match({
77
- Left: (l) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
78
- Right: (r) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
79
- });
76
+ return remaining.match(
77
+ (l) => (leftChunk.isEmpty ? [out, new PullBoth()] : [out, new PullRight(leftChunk)]),
78
+ (r) => (rightChunk.isEmpty ? [out, new PullBoth()] : [out, new PullLeft(rightChunk)]),
79
+ );
80
80
  }
81
81
 
82
82
  /**