@fncts/base 0.0.34 → 0.0.36

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 (236) hide show
  1. package/_cjs/collection/Iterable/api.cjs +9 -2
  2. package/_cjs/collection/Iterable/api.cjs.map +1 -1
  3. package/_cjs/{data/DecodeError/instances.cjs → collection/compat/Map/definition.cjs} +1 -1
  4. package/_cjs/collection/compat/Map/definition.cjs.map +1 -0
  5. package/_cjs/collection/compat/Map.cjs +17 -0
  6. package/_cjs/collection/compat/Map.cjs.map +1 -0
  7. package/_cjs/collection/compat/Set/definition.cjs +6 -0
  8. package/_cjs/collection/compat/Set/definition.cjs.map +1 -0
  9. package/_cjs/collection/compat/Set.cjs +17 -0
  10. package/_cjs/collection/compat/Set.cjs.map +1 -0
  11. package/_cjs/collection/immutable/Conc/api.cjs +1 -4
  12. package/_cjs/collection/immutable/Conc/api.cjs.map +1 -1
  13. package/_cjs/collection/immutable/HashMap/api.cjs +4 -7
  14. package/_cjs/collection/immutable/HashMap/api.cjs.map +1 -1
  15. package/_cjs/collection/immutable/HashSet/api.cjs +4 -7
  16. package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
  17. package/_cjs/collection/immutable/ImmutableArray/api.cjs +6 -9
  18. package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +1 -1
  19. package/_cjs/collection/immutable/ImmutableArray/instances.cjs.map +1 -1
  20. package/_cjs/control/Pure/api.cjs +8 -20
  21. package/_cjs/control/Pure/api.cjs.map +1 -1
  22. package/_cjs/data/Cause/api.cjs +2 -8
  23. package/_cjs/data/Cause/api.cjs.map +1 -1
  24. package/_cjs/data/Datum/api.cjs +2 -8
  25. package/_cjs/data/Datum/api.cjs.map +1 -1
  26. package/_cjs/data/DatumEither/api.cjs +2 -8
  27. package/_cjs/data/DatumEither/api.cjs.map +1 -1
  28. package/_cjs/data/Either/api.cjs +6 -24
  29. package/_cjs/data/Either/api.cjs.map +1 -1
  30. package/_cjs/data/Either/destructors.cjs +3 -3
  31. package/_cjs/data/Either/destructors.cjs.map +1 -1
  32. package/_cjs/data/Either/instances.cjs +7 -27
  33. package/_cjs/data/Either/instances.cjs.map +1 -1
  34. package/_cjs/data/EitherT/api.cjs +2 -8
  35. package/_cjs/data/EitherT/api.cjs.map +1 -1
  36. package/_cjs/data/Eq/api.cjs +22 -0
  37. package/_cjs/data/Eq/api.cjs.map +1 -1
  38. package/_cjs/data/Exit/constructors.cjs +1 -4
  39. package/_cjs/data/Exit/constructors.cjs.map +1 -1
  40. package/_cjs/data/Guard/api.cjs +4 -2
  41. package/_cjs/data/Guard/api.cjs.map +1 -1
  42. package/_cjs/data/Maybe/api.cjs +1 -4
  43. package/_cjs/data/Maybe/api.cjs.map +1 -1
  44. package/_cjs/data/Maybe/instances.cjs +13 -46
  45. package/_cjs/data/Maybe/instances.cjs.map +1 -1
  46. package/_cjs/data/Ord/api.cjs +46 -0
  47. package/_cjs/data/Ord/api.cjs.map +1 -1
  48. package/_cjs/data/Showable/show.cjs.map +1 -1
  49. package/_cjs/data/These/instances.cjs +0 -11
  50. package/_cjs/data/These/instances.cjs.map +1 -1
  51. package/_cjs/json/EitherJson.cjs +0 -18
  52. package/_cjs/json/EitherJson.cjs.map +1 -1
  53. package/_cjs/json/MaybeJson.cjs +0 -16
  54. package/_cjs/json/MaybeJson.cjs.map +1 -1
  55. package/_cjs/json/TheseJson.cjs +0 -22
  56. package/_cjs/json/TheseJson.cjs.map +1 -1
  57. package/_cjs/optics/Optional/definition.cjs +1 -4
  58. package/_cjs/optics/Optional/definition.cjs.map +1 -1
  59. package/_cjs/optics/Prism/definition.cjs +1 -4
  60. package/_cjs/optics/Prism/definition.cjs.map +1 -1
  61. package/_cjs/typeclass/MonadExcept.cjs +1 -4
  62. package/_cjs/typeclass/MonadExcept.cjs.map +1 -1
  63. package/_cjs/util/predicates.cjs +9 -0
  64. package/_cjs/util/predicates.cjs.map +1 -1
  65. package/_mjs/collection/Iterable/api.mjs +8 -2
  66. package/_mjs/collection/Iterable/api.mjs.map +1 -1
  67. package/_mjs/collection/compat/Map/definition.mjs +2 -0
  68. package/_mjs/collection/compat/Map/definition.mjs.map +1 -0
  69. package/_mjs/collection/compat/Map.mjs +3 -0
  70. package/_mjs/collection/compat/Map.mjs.map +1 -0
  71. package/_mjs/collection/compat/Set/definition.mjs +2 -0
  72. package/_mjs/collection/compat/Set/definition.mjs.map +1 -0
  73. package/_mjs/collection/compat/Set.mjs +3 -0
  74. package/_mjs/collection/compat/Set.mjs.map +1 -0
  75. package/_mjs/collection/immutable/Conc/api.mjs +1 -4
  76. package/_mjs/collection/immutable/Conc/api.mjs.map +1 -1
  77. package/_mjs/collection/immutable/HashMap/api.mjs +4 -7
  78. package/_mjs/collection/immutable/HashMap/api.mjs.map +1 -1
  79. package/_mjs/collection/immutable/HashSet/api.mjs +4 -7
  80. package/_mjs/collection/immutable/HashSet/api.mjs.map +1 -1
  81. package/_mjs/collection/immutable/ImmutableArray/api.mjs +6 -9
  82. package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +1 -1
  83. package/_mjs/collection/immutable/ImmutableArray/instances.mjs.map +1 -1
  84. package/_mjs/control/Pure/api.mjs +8 -20
  85. package/_mjs/control/Pure/api.mjs.map +1 -1
  86. package/_mjs/data/Cause/api.mjs +2 -8
  87. package/_mjs/data/Cause/api.mjs.map +1 -1
  88. package/_mjs/data/Datum/api.mjs +2 -8
  89. package/_mjs/data/Datum/api.mjs.map +1 -1
  90. package/_mjs/data/DatumEither/api.mjs +2 -8
  91. package/_mjs/data/DatumEither/api.mjs.map +1 -1
  92. package/_mjs/data/Either/api.mjs +6 -24
  93. package/_mjs/data/Either/api.mjs.map +1 -1
  94. package/_mjs/data/Either/destructors.mjs +3 -3
  95. package/_mjs/data/Either/destructors.mjs.map +1 -1
  96. package/_mjs/data/Either/instances.mjs +6 -25
  97. package/_mjs/data/Either/instances.mjs.map +1 -1
  98. package/_mjs/data/EitherT/api.mjs +2 -8
  99. package/_mjs/data/EitherT/api.mjs.map +1 -1
  100. package/_mjs/data/Eq/api.mjs +21 -0
  101. package/_mjs/data/Eq/api.mjs.map +1 -1
  102. package/_mjs/data/Exit/constructors.mjs +1 -4
  103. package/_mjs/data/Exit/constructors.mjs.map +1 -1
  104. package/_mjs/data/Guard/api.mjs +5 -3
  105. package/_mjs/data/Guard/api.mjs.map +1 -1
  106. package/_mjs/data/Maybe/api.mjs +1 -4
  107. package/_mjs/data/Maybe/api.mjs.map +1 -1
  108. package/_mjs/data/Maybe/instances.mjs +0 -31
  109. package/_mjs/data/Maybe/instances.mjs.map +1 -1
  110. package/_mjs/data/Ord/api.mjs +33 -0
  111. package/_mjs/data/Ord/api.mjs.map +1 -1
  112. package/_mjs/data/Showable/show.mjs.map +1 -1
  113. package/_mjs/data/These/instances.mjs +0 -10
  114. package/_mjs/data/These/instances.mjs.map +1 -1
  115. package/_mjs/json/EitherJson.mjs +0 -15
  116. package/_mjs/json/EitherJson.mjs.map +1 -1
  117. package/_mjs/json/MaybeJson.mjs +0 -13
  118. package/_mjs/json/MaybeJson.mjs.map +1 -1
  119. package/_mjs/json/TheseJson.mjs +0 -19
  120. package/_mjs/json/TheseJson.mjs.map +1 -1
  121. package/_mjs/optics/Optional/definition.mjs +1 -4
  122. package/_mjs/optics/Optional/definition.mjs.map +1 -1
  123. package/_mjs/optics/Prism/definition.mjs +1 -4
  124. package/_mjs/optics/Prism/definition.mjs.map +1 -1
  125. package/_mjs/typeclass/MonadExcept.mjs +1 -4
  126. package/_mjs/typeclass/MonadExcept.mjs.map +1 -1
  127. package/_mjs/util/predicates.mjs +8 -0
  128. package/_mjs/util/predicates.mjs.map +1 -1
  129. package/_src/collection/Iterable/api.ts +7 -0
  130. package/_src/collection/compat/Map/definition.ts +6 -0
  131. package/_src/collection/compat/Map.ts +3 -0
  132. package/_src/collection/compat/Set/definition.ts +6 -0
  133. package/_src/collection/compat/Set.ts +3 -0
  134. package/_src/collection/compat.ts +2 -0
  135. package/_src/collection/immutable/Conc/api.ts +4 -4
  136. package/_src/collection/immutable/HashMap/api.ts +4 -4
  137. package/_src/collection/immutable/HashSet/api.ts +4 -4
  138. package/_src/collection/immutable/ImmutableArray/api.ts +4 -4
  139. package/_src/collection/immutable/ImmutableArray/instances.ts +0 -2
  140. package/_src/control/Pure/api.ts +4 -7
  141. package/_src/data/Cause/api.ts +8 -8
  142. package/_src/data/Datum/api.ts +8 -8
  143. package/_src/data/DatumEither/api.ts +8 -8
  144. package/_src/data/Either/api.ts +18 -18
  145. package/_src/data/Either/destructors.ts +3 -3
  146. package/_src/data/Either/instances.ts +12 -31
  147. package/_src/data/EitherT/api.ts +8 -8
  148. package/_src/data/Eq/api.ts +23 -0
  149. package/_src/data/Exit/constructors.ts +1 -1
  150. package/_src/data/Guard/api.ts +6 -3
  151. package/_src/data/Maybe/api.ts +4 -4
  152. package/_src/data/Maybe/instances.ts +0 -39
  153. package/_src/data/Ord/api.ts +35 -0
  154. package/_src/data/Showable/show.ts +1 -1
  155. package/_src/data/These/instances.ts +0 -22
  156. package/_src/global.ts +0 -8
  157. package/_src/json/EitherJson.ts +0 -7
  158. package/_src/json/MaybeJson.ts +0 -7
  159. package/_src/json/TheseJson.ts +0 -7
  160. package/_src/optics/Optional/definition.ts +4 -4
  161. package/_src/optics/Prism/definition.ts +1 -1
  162. package/_src/typeclass/MonadExcept.ts +1 -1
  163. package/_src/util/predicates.ts +9 -0
  164. package/collection/Iterable/api.d.ts +5 -0
  165. package/collection/compat/Map/definition.d.ts +8 -0
  166. package/collection/compat/Map.d.ts +1 -0
  167. package/collection/compat/Set/definition.d.ts +8 -0
  168. package/collection/compat/Set.d.ts +1 -0
  169. package/collection/compat.d.ts +2 -0
  170. package/data/Either/destructors.d.ts +1 -4
  171. package/data/Either/instances.d.ts +0 -6
  172. package/data/Eq/api.d.ts +5 -0
  173. package/data/Guard/api.d.ts +1 -2
  174. package/data/Maybe/instances.d.ts +0 -12
  175. package/data/Ord/api.d.ts +13 -0
  176. package/data/Showable/show.d.ts +1 -1
  177. package/data/These/instances.d.ts +0 -6
  178. package/global.d.ts +0 -8
  179. package/json/EitherJson.d.ts +0 -6
  180. package/json/MaybeJson.d.ts +0 -6
  181. package/json/TheseJson.d.ts +0 -6
  182. package/package.json +2 -2
  183. package/util/predicates.d.ts +5 -0
  184. package/_cjs/data/DecodeError/definition.cjs +0 -240
  185. package/_cjs/data/DecodeError/definition.cjs.map +0 -1
  186. package/_cjs/data/DecodeError/instances.cjs.map +0 -1
  187. package/_cjs/data/DecodeError.cjs +0 -28
  188. package/_cjs/data/DecodeError.cjs.map +0 -1
  189. package/_cjs/data/Decoder/api.cjs +0 -572
  190. package/_cjs/data/Decoder/api.cjs.map +0 -1
  191. package/_cjs/data/Decoder/definition.cjs +0 -30
  192. package/_cjs/data/Decoder/definition.cjs.map +0 -1
  193. package/_cjs/data/Decoder.cjs +0 -28
  194. package/_cjs/data/Decoder.cjs.map +0 -1
  195. package/_cjs/data/Encoder/api.cjs +0 -315
  196. package/_cjs/data/Encoder/api.cjs.map +0 -1
  197. package/_cjs/data/Encoder/definition.cjs +0 -22
  198. package/_cjs/data/Encoder/definition.cjs.map +0 -1
  199. package/_cjs/data/Encoder.cjs +0 -28
  200. package/_cjs/data/Encoder.cjs.map +0 -1
  201. package/_mjs/data/DecodeError/definition.mjs +0 -209
  202. package/_mjs/data/DecodeError/definition.mjs.map +0 -1
  203. package/_mjs/data/DecodeError/instances.mjs +0 -2
  204. package/_mjs/data/DecodeError/instances.mjs.map +0 -1
  205. package/_mjs/data/DecodeError.mjs +0 -5
  206. package/_mjs/data/DecodeError.mjs.map +0 -1
  207. package/_mjs/data/Decoder/api.mjs +0 -542
  208. package/_mjs/data/Decoder/api.mjs.map +0 -1
  209. package/_mjs/data/Decoder/definition.mjs +0 -22
  210. package/_mjs/data/Decoder/definition.mjs.map +0 -1
  211. package/_mjs/data/Decoder.mjs +0 -5
  212. package/_mjs/data/Decoder.mjs.map +0 -1
  213. package/_mjs/data/Encoder/api.mjs +0 -279
  214. package/_mjs/data/Encoder/api.mjs.map +0 -1
  215. package/_mjs/data/Encoder/definition.mjs +0 -15
  216. package/_mjs/data/Encoder/definition.mjs.map +0 -1
  217. package/_mjs/data/Encoder.mjs +0 -5
  218. package/_mjs/data/Encoder.mjs.map +0 -1
  219. package/_src/data/DecodeError/definition.ts +0 -267
  220. package/_src/data/DecodeError/instances.ts +0 -0
  221. package/_src/data/DecodeError.ts +0 -5
  222. package/_src/data/Decoder/api.ts +0 -696
  223. package/_src/data/Decoder/definition.ts +0 -31
  224. package/_src/data/Decoder.ts +0 -5
  225. package/_src/data/Encoder/api.ts +0 -381
  226. package/_src/data/Encoder/definition.ts +0 -16
  227. package/_src/data/Encoder.ts +0 -5
  228. package/data/DecodeError/definition.d.ts +0 -148
  229. package/data/DecodeError/instances.d.ts +0 -1
  230. package/data/DecodeError.d.ts +0 -2
  231. package/data/Decoder/api.d.ts +0 -214
  232. package/data/Decoder/definition.d.ts +0 -27
  233. package/data/Decoder.d.ts +0 -2
  234. package/data/Encoder/api.d.ts +0 -214
  235. package/data/Encoder/definition.d.ts +0 -16
  236. package/data/Encoder.d.ts +0 -2
@@ -1,7 +1,5 @@
1
1
  import type { ImmutableArrayF } from "@fncts/base/collection/immutable/ImmutableArray/definition";
2
- import type { DecodeError } from "@fncts/base/data/DecodeError";
3
2
  import type * as P from "@fncts/base/typeclass";
4
- import type { Check } from "@fncts/typelevel/Check";
5
3
 
6
4
  import {
7
5
  alignWith,
@@ -8,7 +8,7 @@ import { identity, tuple } from "../../data/function.js";
8
8
  export function absolve<W, S1, S2, R, E, E1, A>(
9
9
  fa: Pure<W, S1, S2, R, E, Either<E1, A>>,
10
10
  ): Pure<W, S1, S2, R, E | E1, A> {
11
- return fa.flatMap((ea) => ea.match({ Left: Pure.failNow, Right: Pure.succeedNow }));
11
+ return fa.flatMap((ea) => ea.match(Pure.failNow, Pure.succeedNow));
12
12
  }
13
13
 
14
14
  /**
@@ -350,10 +350,7 @@ export function matchPure<S5, S2, E, A, W1, S3, R1, E1, B, W2, S4, R2, E2, C>(
350
350
  onSuccess: (a: A) => Pure<W2, S2, S4, R2, E2, C>,
351
351
  ) {
352
352
  return <W, S1, R>(fa: Pure<W, S1, S2, R, E, A>): Pure<W | W1 | W2, S1 & S5, S3 | S4, R | R1 | R2, E1 | E2, B | C> => {
353
- return fa.matchCausePure(
354
- (cause) => cause.failureOrCause.match({ Left: onFailure, Right: Pure.failCauseNow }),
355
- onSuccess,
356
- );
353
+ return fa.matchCausePure((cause) => cause.failureOrCause.match(onFailure, Pure.failCauseNow), onSuccess);
357
354
  };
358
355
  }
359
356
 
@@ -381,7 +378,7 @@ export function matchLogPure<W, S5, S2, E, A, W1, S3, R1, E1, B, W2, S4, R2, E2,
381
378
  ) {
382
379
  return <S1, R>(fa: Pure<W, S1, S2, R, E, A>): Pure<W | W1 | W2, S1 & S5, S3 | S4, R | R1 | R2, E1 | E2, B | C> => {
383
380
  return fa.matchLogCausePure(
384
- (ws, cause) => cause.failureOrCause.match({ Left: (e) => onFailure(ws, e), Right: Pure.failCauseNow }),
381
+ (ws, cause) => cause.failureOrCause.match((e) => onFailure(ws, e), Pure.failCauseNow),
385
382
  onSuccess,
386
383
  );
387
384
  };
@@ -431,7 +428,7 @@ export function modifyEither<S1, S2, E, A>(
431
428
  ): Pure<never, S1, S2, never, E, A> {
432
429
  return Pure.get<S1>()
433
430
  .map(f)
434
- .flatMap((r) => r.match({ Left: Pure.failNow, Right: ([a, s2]) => Pure.succeedNow(a).mapState(() => s2) }));
431
+ .flatMap((r) => r.match(Pure.failNow, ([a, s2]) => Pure.succeedNow(a).mapState(() => s2)));
435
432
  }
436
433
 
437
434
  /**
@@ -339,10 +339,10 @@ export function flipCauseEither<E, A>(self: Cause<Either<E, A>>): Either<Cause<E
339
339
  result = Either.left(c);
340
340
  break pushing;
341
341
  case CauseTag.Fail:
342
- result = c.value.match({
343
- Left: (l) => Either.left(Cause.fail(l, Trace.none)),
344
- Right: (r) => Either.right(r),
345
- });
342
+ result = c.value.match(
343
+ (l) => Either.left(Cause.fail(l, Trace.none)),
344
+ (r) => Either.right(r),
345
+ );
346
346
  break pushing;
347
347
  case CauseTag.Sequential:
348
348
  stack.push(new FCEStackFrameThenLeft(c));
@@ -898,10 +898,10 @@ function sequenceCauseEitherEval<E, A>(self: Cause<Either<E, A>>): Eval<Either<C
898
898
  }
899
899
  case CauseTag.Fail: {
900
900
  return Eval.now(
901
- self.value.match({
902
- Left: (e) => Either.left(Cause.fail(e, Trace.none)),
903
- Right: (a) => Either.right(a),
904
- }),
901
+ self.value.match(
902
+ (e) => Either.left(Cause.fail(e, Trace.none)),
903
+ (a) => Either.right(a),
904
+ ),
905
905
  );
906
906
  }
907
907
  case CauseTag.Halt: {
@@ -336,15 +336,15 @@ export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
336
336
  Initial: () => [Initial(), Initial()],
337
337
  Pending: () => [Pending(), Pending()],
338
338
  Refresh: (a) =>
339
- f(a).match({
340
- Left: (b) => [Refresh(b), Initial()],
341
- Right: (c) => [Initial(), Refresh(c)],
342
- }),
339
+ f(a).match(
340
+ (b) => [Refresh(b), Initial()],
341
+ (c) => [Initial(), Refresh(c)],
342
+ ),
343
343
  Replete: (a) =>
344
- f(a).match({
345
- Left: (b) => [Replete(b), Initial()],
346
- Right: (c) => [Initial(), Replete(c)],
347
- }),
344
+ f(a).match(
345
+ (b) => [Replete(b), Initial()],
346
+ (c) => [Initial(), Replete(c)],
347
+ ),
348
348
  });
349
349
  };
350
350
  }
@@ -303,16 +303,16 @@ export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
303
303
  Pending: () => [self.unsafeCoerce(), self.unsafeCoerce()],
304
304
  RefreshLeft: () => [self.unsafeCoerce(), self.unsafeCoerce()],
305
305
  RefreshRight: (a) =>
306
- f(a).match({
307
- Left: (b) => [DatumEither.refreshRight(b), DatumEither.initial()],
308
- Right: (c) => [DatumEither.initial(), DatumEither.refreshRight(c)],
309
- }),
306
+ f(a).match(
307
+ (b) => [DatumEither.refreshRight(b), DatumEither.initial()],
308
+ (c) => [DatumEither.initial(), DatumEither.refreshRight(c)],
309
+ ),
310
310
  RepleteLeft: () => [self.unsafeCoerce(), self.unsafeCoerce()],
311
311
  RepleteRight: (a) =>
312
- f(a).match({
313
- Left: (b) => [DatumEither.repleteRight(b), DatumEither.initial()],
314
- Right: (c) => [DatumEither.initial(), DatumEither.repleteRight(c)],
315
- }),
312
+ f(a).match(
313
+ (b) => [DatumEither.repleteRight(b), DatumEither.initial()],
314
+ (c) => [DatumEither.initial(), DatumEither.repleteRight(c)],
315
+ ),
316
316
  });
317
317
  };
318
318
  }
@@ -97,20 +97,20 @@ export function foldMap<A, M>(f: (a: A) => M, /** @tsplus auto */ M: P.Monoid<M>
97
97
  * @tsplus getter fncts.Either getLeft
98
98
  */
99
99
  export function getLeft<E, A>(self: Either<E, A>): Maybe<E> {
100
- return self.match({
101
- Left: (e) => Just(e),
102
- Right: (_a) => Nothing(),
103
- });
100
+ return self.match(
101
+ (e) => Just(e),
102
+ (_a) => Nothing(),
103
+ );
104
104
  }
105
105
 
106
106
  /**
107
107
  * @tsplus getter fncts.Either getRight
108
108
  */
109
109
  export function getRight<E, A>(self: Either<E, A>): Maybe<A> {
110
- return self.match({
111
- Left: (_e) => Nothing(),
112
- Right: (a) => Just(a),
113
- });
110
+ return self.match(
111
+ (_e) => Nothing(),
112
+ (a) => Just(a),
113
+ );
114
114
  }
115
115
 
116
116
  /**
@@ -118,7 +118,7 @@ export function getRight<E, A>(self: Either<E, A>): Maybe<A> {
118
118
  */
119
119
  export function getOrElse<E, B>(orElse: (e: E) => B) {
120
120
  return <A>(self: Either<E, A>): A | B => {
121
- return self.match({ Left: orElse, Right: identity });
121
+ return self.match(orElse, identity);
122
122
  };
123
123
  }
124
124
 
@@ -172,7 +172,7 @@ export function mapLeft<E1, E2>(f: (e: E1) => E2) {
172
172
  * @tsplus getter fncts.Either value
173
173
  */
174
174
  export function merge<E, A>(self: Either<E, A>): E | A {
175
- return self.match({ Left: identity, Right: identity });
175
+ return self.match(identity, identity);
176
176
  }
177
177
 
178
178
  /**
@@ -201,10 +201,10 @@ export function _traverse<E, A>(self: Either<E, A>) {
201
201
  <K, Q, W, X, I, S, R, E1, B>(
202
202
  f: (a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E1, B>,
203
203
  ): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E1, Either<E, B>> =>
204
- self.match({
205
- Left: (e) => G.pure(Left(e)),
206
- Right: (a) => f(a).pipe(G.map((b) => Right(b))),
207
- });
204
+ self.match(
205
+ (e) => G.pure(Left(e)),
206
+ (a) => f(a).pipe(G.map((b) => Right(b))),
207
+ );
208
208
  }
209
209
 
210
210
  export const traverse_: P.Traversable<EitherF>["traverse"] = (A) => (f) => (self) => self.traverse(A)(f);
@@ -288,10 +288,10 @@ export function partition<E, A>(p: Predicate<A>, /** @tsplus auto */ M: P.Monoid
288
288
  * @tsplus getter fncts.Either toMaybe
289
289
  */
290
290
  export function toMaybe<E, A>(self: Either<E, A>): Maybe<A> {
291
- return self.match({
292
- Left: () => Nothing(),
293
- Right: (a) => Just(a),
294
- });
291
+ return self.match(
292
+ () => Nothing(),
293
+ (a) => Just(a),
294
+ );
295
295
  }
296
296
 
297
297
  /* eslint-disable simple-import-sort/exports */
@@ -3,14 +3,14 @@ import { EitherTag } from "./definition.js";
3
3
  /**
4
4
  * @tsplus pipeable fncts.Either match
5
5
  */
6
- export function match<E, A, B, C>(cases: { Left: (e: E) => B; Right: (a: A) => C }) {
6
+ export function match<E, A, B, C>(onLeft: (e: E) => B, onRight: (a: A) => C) {
7
7
  return (self: Either<E, A>): B | C => {
8
8
  self.concrete();
9
9
  switch (self._tag) {
10
10
  case EitherTag.Left:
11
- return cases.Left(self.left);
11
+ return onLeft(self.left);
12
12
  case EitherTag.Right:
13
- return cases.Right(self.right);
13
+ return onRight(self.right);
14
14
  }
15
15
  };
16
16
  }
@@ -2,7 +2,6 @@ import type { EitherF } from "@fncts/base/data/Either/definition.js";
2
2
 
3
3
  import { map } from "@fncts/base/data/Either/api";
4
4
  import { concrete, Either, EitherTag, Right } from "@fncts/base/data/Either/definition";
5
- import { EitherJson } from "@fncts/base/json/EitherJson";
6
5
 
7
6
  import * as P from "../../typeclass.js";
8
7
 
@@ -20,18 +19,18 @@ export function getEq<E, A>(EE: P.Eq<E>, EA: P.Eq<A>): P.Eq<Either<E, A>> {
20
19
  return P.Eq({
21
20
  equals: (y) => (x) =>
22
21
  x === y ||
23
- x.match({
24
- Left: (e1) =>
25
- y.match({
26
- Left: (e2) => EE.equals(e2)(e1),
27
- Right: () => false,
28
- }),
29
- Right: (a1) =>
30
- y.match({
31
- Left: () => false,
32
- Right: (a2) => EA.equals(a2)(a1),
33
- }),
34
- }),
22
+ x.match(
23
+ (e1) =>
24
+ y.match(
25
+ (e2) => EE.equals(e2)(e1),
26
+ () => false,
27
+ ),
28
+ (a1) =>
29
+ y.match(
30
+ () => false,
31
+ (a2) => EA.equals(a2)(a1),
32
+ ),
33
+ ),
35
34
  });
36
35
  }
37
36
 
@@ -115,21 +114,3 @@ export function deriveGuard<A extends Either<any, any>>(
115
114
  return false;
116
115
  });
117
116
  }
118
-
119
- /**
120
- * @tsplus derive fncts.Decoder[fncts.Either]<_> 10
121
- */
122
- export function deriveDecoder<A extends Either<any, any>>(
123
- ...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never
124
- ): Decoder<A> {
125
- const jsonDecoder = EitherJson.getDecoder(left, right);
126
- return Decoder(
127
- (u) =>
128
- jsonDecoder
129
- .decode(u)
130
- .map((result) =>
131
- result._tag === "Left" ? (Either.left(result.left) as A) : (Either.right(result.right) as A),
132
- ),
133
- `Either<${left.label}, ${right.label}>`,
134
- );
135
- }
@@ -122,10 +122,10 @@ export function flatMap<F extends HKT, FC>(F: P.Monad<F, FC>) {
122
122
  >) =>
123
123
  F.flatMap(
124
124
  (either) =>
125
- either.match({
126
- Left: (e) => F.pure(Either.left(e)),
127
- Right: (a) => f(a),
128
- }) as HKT.Kind<
125
+ either.match(
126
+ (e) => F.pure(Either.left(e)),
127
+ (a) => f(a),
128
+ ) as HKT.Kind<
129
129
  F,
130
130
  FC,
131
131
  HKT.Intro<F, "K", K, K1>,
@@ -225,9 +225,9 @@ export function orElse<F>(F: P.Monad<HKT.F1<F>>) {
225
225
  that: Lazy<HKT.FK1<F, Either<E1, B>>>,
226
226
  ): ((self: HKT.FK1<F, Either<E, A>>) => HKT.FK1<F, Either<E | E1, A | B>>) =>
227
227
  F.flatMap((either) =>
228
- either.match({
229
- Left: () => that(),
230
- Right: () => F.pure(either),
231
- }),
228
+ either.match(
229
+ () => that(),
230
+ () => F.pure(either),
231
+ ),
232
232
  );
233
233
  }
@@ -6,3 +6,26 @@ export function contramap<A, B>(f: (b: B) => A) {
6
6
  return Eq({ equals: (b2) => (b1) => self.equals(f(b2))(f(b1)) });
7
7
  };
8
8
  }
9
+
10
+ /**
11
+ * @tsplus static fncts.EqOps all
12
+ */
13
+ export function all<A>(collection: Iterable<Eq<A>>): Eq<ReadonlyArray<A>> {
14
+ return Eq({
15
+ equals: (y) => (x) => {
16
+ const len = Math.min(x.length, y.length);
17
+
18
+ let collectionLength = 0;
19
+ for (const eq of collection) {
20
+ if (collectionLength >= len) {
21
+ break;
22
+ }
23
+ if (!eq.equals(y[collectionLength]!)(x[collectionLength]!)) {
24
+ return false;
25
+ }
26
+ collectionLength++;
27
+ }
28
+ return true;
29
+ },
30
+ });
31
+ }
@@ -18,7 +18,7 @@ export function fail<E = never, A = never>(e: E, __tsplusTrace?: string): Exit<E
18
18
  * @tsplus static fncts.ExitOps fromEither
19
19
  */
20
20
  export function fromEither<E = never, A = never>(e: Either<E, A>): Exit<E, A> {
21
- return e.match({ Left: fail, Right: succeed });
21
+ return e.match(fail, succeed);
22
22
  }
23
23
 
24
24
  /**
@@ -5,7 +5,7 @@ import type { OptionalKeys, RequiredKeys } from "@fncts/typelevel/Object";
5
5
 
6
6
  import { Guard } from "@fncts/base/data/Guard/definition";
7
7
  import { AssertionError } from "@fncts/base/util/assert";
8
- import { isNull, isUndefined } from "@fncts/base/util/predicates";
8
+ import { isArray, isNull, isUndefined } from "@fncts/base/util/predicates";
9
9
 
10
10
  /**
11
11
  * @tsplus pipeable fncts.Guard __call
@@ -441,8 +441,11 @@ export function validation<A, B extends ReadonlyArray<Validation<A, any>>>(...va
441
441
  */
442
442
  export function deriveTuple<A extends ReadonlyArray<unknown>>(
443
443
  ...[components]: Check<Check.IsTuple<A>> extends Check.True ? [components: { [K in keyof A]: Guard<A[K]> }] : never
444
- ): Encoder<A> {
445
- return Encoder((inp) => {
444
+ ): Guard<A> {
445
+ return Guard((inp): inp is A => {
446
+ if (!isArray(inp)) {
447
+ return false;
448
+ }
446
449
  for (let i = 0; i < inp.length; i++) {
447
450
  if (!components[i]!.is(inp[i])) {
448
451
  return false;
@@ -95,10 +95,10 @@ export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
95
95
  return (self: Maybe<A>): readonly [Maybe<B>, Maybe<C>] => {
96
96
  self.concrete();
97
97
  if (self._tag === MaybeTag.Just) {
98
- return f(self.value).match({
99
- Left: (b) => [Just(b), Nothing()],
100
- Right: (c) => [Nothing(), Just(c)],
101
- });
98
+ return f(self.value).match(
99
+ (b) => [Just(b), Nothing()],
100
+ (c) => [Nothing(), Just(c)],
101
+ );
102
102
  } else {
103
103
  return [Nothing(), Nothing()];
104
104
  }
@@ -1,8 +1,6 @@
1
1
  import type * as P from "../../typeclass.js";
2
2
  import type { MaybeF } from "@fncts/base/data/Maybe/definition";
3
3
 
4
- import { MaybeJson } from "@fncts/base/json/MaybeJson";
5
-
6
4
  import { filter, filterMap, flatMap, foldLeft, foldRight, map, partition, partitionMap, zip, zipWith } from "./api.js";
7
5
  import { just } from "./constructors.js";
8
6
 
@@ -69,40 +67,3 @@ export function deriveGuard<A extends Maybe<any>>(
69
67
  return false;
70
68
  });
71
69
  }
72
-
73
- /**
74
- * @tsplus derive fncts.Decoder[fncts.Maybe]<_> 10
75
- */
76
- export function deriveDecoder<A extends Maybe<any>>(
77
- ...[value]: [A] extends [Maybe<infer A>] ? [value: Decoder<A>] : never
78
- ): Decoder<A> {
79
- const label = `Maybe<${value.label}>`;
80
- return Decoder(
81
- (input) =>
82
- MaybeJson.getDecoder(value)
83
- .decode(input)
84
- .map((decoded) => (decoded._tag === "Nothing" ? (Nothing() as A) : (Just(decoded.value) as A))),
85
- label,
86
- );
87
- }
88
-
89
- /**
90
- * @tsplus derive fncts.Encoder[fncts.Maybe]<_> 10
91
- */
92
- export function deriveEncoder<A extends Maybe<any>>(
93
- ...[value]: [A] extends [Maybe<infer A>] ? [value: Encoder<A>] : never
94
- ): Encoder<A> {
95
- return Encoder((input) => {
96
- Maybe.concrete(input);
97
- if (input.isJust()) {
98
- return {
99
- _tag: "Just",
100
- value: value.encode(input.value),
101
- };
102
- } else {
103
- return {
104
- _tag: "Nothing",
105
- };
106
- }
107
- });
108
- }
@@ -1,3 +1,38 @@
1
+ /**
2
+ * @tsplus static fncts.OrdOps all
3
+ */
4
+ export function all<A>(collection: Iterable<Ord<A>>): Ord<ReadonlyArray<A>> {
5
+ return Ord<ReadonlyArray<A>>({
6
+ ...Eq.all(collection),
7
+ compare: (y) => (x) => {
8
+ const len = Math.min(x.length, y.length);
9
+ let collectionLength = 0;
10
+ for (const O of collection) {
11
+ if (collectionLength >= len) {
12
+ break;
13
+ }
14
+
15
+ const o = O.compare(y[collectionLength]!)(x[collectionLength]!);
16
+
17
+ if (o !== Ordering.EQ) {
18
+ return o;
19
+ }
20
+ collectionLength++;
21
+ }
22
+ return Ordering.EQ;
23
+ },
24
+ });
25
+ }
26
+
27
+ /**
28
+ * @tsplus static fncts.OrdOps tuple
29
+ */
30
+ export function tuple<T extends ReadonlyArray<Ord<any>>>(
31
+ ...elements: T
32
+ ): Ord<Readonly<{ [I in keyof T]: [T[I]] extends [Ord<infer A>] ? A : never }>> {
33
+ return Ord.all(elements) as any;
34
+ }
35
+
1
36
  /* eslint-disable simple-import-sort/exports */
2
37
  // codegen:start { preset: barrel, include: api/*.ts }
3
38
  export * from "./api/min.js";
@@ -129,7 +129,7 @@ export function show(value: unknown): string {
129
129
  return _show(value).unsafeRunStateResult(getShowContext());
130
130
  }
131
131
 
132
- export function showWithOptions(value: unknown, options: Partial<ShowOptions>): string {
132
+ export function showWithOptions(value: unknown, options?: Partial<ShowOptions>): string {
133
133
  return _show(value).unsafeRunStateResult(getShowContext(options));
134
134
  }
135
135
 
@@ -19,25 +19,3 @@ export function deriveGuard<A extends These<any, any>>(
19
19
  return false;
20
20
  });
21
21
  }
22
-
23
- /**
24
- * @tsplus derive fncts.Decoder[fncts.These]<_> 10
25
- */
26
- export function deriveDecoder<A extends These<any, any>>(
27
- ...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never
28
- ): Decoder<A> {
29
- const label = `These<${left.label}, ${right.label}>`;
30
- return Decoder(
31
- (input) =>
32
- TheseJson.getDecoder(left, right)
33
- .decode(input)
34
- .map((result) =>
35
- result._tag === "Left"
36
- ? (These.left(result.left) as A)
37
- : result._tag === "Right"
38
- ? (These.right(result.right) as A)
39
- : (These.both(result.left, result.right) as A),
40
- ),
41
- label,
42
- );
43
- }
package/_src/global.ts CHANGED
@@ -107,10 +107,6 @@ import { Datum } from "@fncts/base/data/Datum/definition";
107
107
  * @tsplus global
108
108
  */
109
109
  import { DatumEither } from "@fncts/base/data/DatumEither/definition";
110
- /**
111
- * @tsplus global
112
- */
113
- import { Decoder } from "@fncts/base/data/Decoder/definition";
114
110
  /**
115
111
  * @tsplus global
116
112
  */
@@ -119,10 +115,6 @@ import { Duration } from "@fncts/base/data/Duration/definition";
119
115
  * @tsplus global
120
116
  */
121
117
  import { Either } from "@fncts/base/data/Either/definition";
122
- /**
123
- * @tsplus global
124
- */
125
- import { Encoder } from "@fncts/base/data/Encoder/definition";
126
118
  /**
127
119
  * @tsplus global
128
120
  */
@@ -19,10 +19,3 @@ export type EitherJson<E, A> = LeftJson<E> | RightJson<A>;
19
19
  export interface EitherJsonOps {}
20
20
 
21
21
  export const EitherJson: EitherJsonOps = {};
22
-
23
- /**
24
- * @tsplus static fncts.EitherJsonOps getDecoder
25
- */
26
- export function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<EitherJson<E, A>> {
27
- return Derive();
28
- }
@@ -18,10 +18,3 @@ export type MaybeJson<A> = NothingJson | JustJson<A>;
18
18
  export interface MaybeJsonOps {}
19
19
 
20
20
  export const MaybeJson: MaybeJsonOps = {};
21
-
22
- /**
23
- * @tsplus static fncts.MaybeJsonOps getDecoder
24
- */
25
- export function getDecoder<A>(value: Decoder<A>): Decoder<MaybeJson<A>> {
26
- return Derive();
27
- }
@@ -22,10 +22,3 @@ export type TheseJson<E, A> = LeftJson<E> | RightJson<A> | BothJson<E, A>;
22
22
  export interface TheseJsonOps {}
23
23
 
24
24
  export const TheseJson: TheseJsonOps = {};
25
-
26
- /**
27
- * @tsplus static fncts.TheseJsonOps getDecoder
28
- */
29
- export function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<TheseJson<E, A>> {
30
- return Derive();
31
- }
@@ -42,10 +42,10 @@ export function makePOptional<S, T, A, B>(F: POptionalMin<S, T, A, B>): POptiona
42
42
  modifyMaybe: (f) => (s) => getMaybe(s).map((a) => pipe(s, F.set(f(a)))),
43
43
  ...PTraversal<S, T, A, B>({
44
44
  modifyA: (A) => (f) => (s) =>
45
- F.getOrModify(s).match({
46
- Left: (t) => A.pure(t),
47
- Right: (a) => f(a).pipe(A.map((b) => s.pipe(F.set(b)))),
48
- }),
45
+ F.getOrModify(s).match(
46
+ (t) => A.pure(t),
47
+ (a) => f(a).pipe(A.map((b) => s.pipe(F.set(b)))),
48
+ ),
49
49
  }),
50
50
  };
51
51
  }
@@ -34,7 +34,7 @@ export function makePPrism<S, T, A, B>(F: PPrismMin<S, T, A, B>): PPrism<S, T, A
34
34
  reverseGet: F.reverseGet,
35
35
  ...POptional({
36
36
  getOrModify: F.getOrModify,
37
- set: (b) => (s) => F.getOrModify(s).match({ Left: identity, Right: () => F.reverseGet(b) }),
37
+ set: (b) => (s) => F.getOrModify(s).match(identity, () => F.reverseGet(b)),
38
38
  }),
39
39
  };
40
40
  }
@@ -24,5 +24,5 @@ export function absolve<F extends HKT, FC = HKT.None>(
24
24
  export function absolve<F>(
25
25
  F: MonadExcept<HKT.F<F>>,
26
26
  ): <E, A, E1>(fa: HKT.FK2<F, E, Either<E1, A>>) => HKT.FK2<F, HKT.Mix<HKT.F<F>, "E", [E, E1]>, A> {
27
- return F.flatMap((r) => r.match({ Left: F.fail, Right: F.pure }));
27
+ return F.flatMap((r) => r.match(F.fail, F.pure));
28
28
  }
@@ -86,6 +86,15 @@ export function isPlain(value: unknown): value is object {
86
86
  return isObject(value) && value.constructor === Object;
87
87
  }
88
88
 
89
+ /**
90
+ * @tsplus pipeable global hasProperty
91
+ */
92
+ export function hasProperty<P extends PropertyKey>(property: P) {
93
+ return (self: unknown): self is { [K in P]: unknown } => {
94
+ return isObject(self) && property in self;
95
+ };
96
+ }
97
+
89
98
  export function isInstanceOf<C extends Constructor<A>, A>(type: C): (value: unknown) => value is A {
90
99
  return (value): value is A => value instanceof type;
91
100
  }
@@ -20,6 +20,11 @@ export declare function append<B>(b: B): <A>(self: Iterable<A>) => Iterable<A |
20
20
  * @tsplus location "@fncts/base/collection/Iterable/api"
21
21
  */
22
22
  export declare function toIterable<A>(self: Iterable<A>): Iterable<A>;
23
+ /**
24
+ * @tsplus getter fncts.Iterable toArray
25
+ * @tsplus location "@fncts/base/collection/Iterable/api"
26
+ */
27
+ export declare function toArray<A>(self: Iterable<A>): Array<A>;
23
28
  /**
24
29
  * @tsplus pipeable fncts.Iterable flatMap
25
30
  * @tsplus location "@fncts/base/collection/Iterable/api"
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ /**
3
+ * @tsplus type fncts.Map
4
+ */
5
+ interface Map<K, V> {
6
+ }
7
+ }
8
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./Map/definition.js";
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ /**
3
+ * @tsplus type fncts.Set
4
+ */
5
+ interface Set<T> {
6
+ }
7
+ }
8
+ export {};