@fncts/base 0.0.33 → 0.0.35

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 (239) hide show
  1. package/_cjs/collection/immutable/Conc/api.cjs +1 -4
  2. package/_cjs/collection/immutable/Conc/api.cjs.map +1 -1
  3. package/_cjs/collection/immutable/HashMap/api.cjs +4 -7
  4. package/_cjs/collection/immutable/HashMap/api.cjs.map +1 -1
  5. package/_cjs/collection/immutable/HashSet/api.cjs +4 -7
  6. package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
  7. package/_cjs/collection/immutable/ImmutableArray/api.cjs +6 -9
  8. package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +1 -1
  9. package/_cjs/collection/immutable/ImmutableArray/instances.cjs.map +1 -1
  10. package/_cjs/control/Pure/api.cjs +8 -20
  11. package/_cjs/control/Pure/api.cjs.map +1 -1
  12. package/_cjs/data/Cause/api.cjs +2 -8
  13. package/_cjs/data/Cause/api.cjs.map +1 -1
  14. package/_cjs/data/Data.cjs +121 -0
  15. package/_cjs/data/Data.cjs.map +1 -0
  16. package/_cjs/data/Datum/api.cjs +2 -8
  17. package/_cjs/data/Datum/api.cjs.map +1 -1
  18. package/_cjs/data/DatumEither/api.cjs +2 -8
  19. package/_cjs/data/DatumEither/api.cjs.map +1 -1
  20. package/_cjs/data/Either/api.cjs +6 -24
  21. package/_cjs/data/Either/api.cjs.map +1 -1
  22. package/_cjs/data/Either/definition.cjs +1 -0
  23. package/_cjs/data/Either/definition.cjs.map +1 -1
  24. package/_cjs/data/Either/destructors.cjs +3 -3
  25. package/_cjs/data/Either/destructors.cjs.map +1 -1
  26. package/_cjs/data/Either/instances.cjs +7 -27
  27. package/_cjs/data/Either/instances.cjs.map +1 -1
  28. package/_cjs/data/EitherT/api.cjs +2 -8
  29. package/_cjs/data/EitherT/api.cjs.map +1 -1
  30. package/_cjs/data/Exit/api.cjs +3 -3
  31. package/_cjs/data/Exit/api.cjs.map +1 -1
  32. package/_cjs/data/Exit/constructors.cjs +1 -4
  33. package/_cjs/data/Exit/constructors.cjs.map +1 -1
  34. package/_cjs/data/Exit/definition.cjs +2 -0
  35. package/_cjs/data/Exit/definition.cjs.map +1 -1
  36. package/_cjs/data/Guard/api.cjs +4 -2
  37. package/_cjs/data/Guard/api.cjs.map +1 -1
  38. package/_cjs/data/Maybe/api.cjs +1 -4
  39. package/_cjs/data/Maybe/api.cjs.map +1 -1
  40. package/_cjs/data/Maybe/definition.cjs +1 -0
  41. package/_cjs/data/Maybe/definition.cjs.map +1 -1
  42. package/_cjs/data/Maybe/instances.cjs +13 -46
  43. package/_cjs/data/Maybe/instances.cjs.map +1 -1
  44. package/_cjs/data/Showable/show.cjs.map +1 -1
  45. package/_cjs/data/Tag/definition.cjs +8 -0
  46. package/_cjs/data/Tag/definition.cjs.map +1 -1
  47. package/_cjs/data/These/instances.cjs +0 -11
  48. package/_cjs/data/These/instances.cjs.map +1 -1
  49. package/_cjs/json/EitherJson.cjs +0 -18
  50. package/_cjs/json/EitherJson.cjs.map +1 -1
  51. package/_cjs/json/MaybeJson.cjs +0 -16
  52. package/_cjs/json/MaybeJson.cjs.map +1 -1
  53. package/_cjs/json/TheseJson.cjs +0 -22
  54. package/_cjs/json/TheseJson.cjs.map +1 -1
  55. package/_cjs/optics/Optional/definition.cjs +1 -4
  56. package/_cjs/optics/Optional/definition.cjs.map +1 -1
  57. package/_cjs/optics/Prism/definition.cjs +1 -4
  58. package/_cjs/optics/Prism/definition.cjs.map +1 -1
  59. package/_cjs/typeclass/MonadExcept.cjs +1 -4
  60. package/_cjs/typeclass/MonadExcept.cjs.map +1 -1
  61. package/_mjs/collection/immutable/Conc/api.mjs +1 -4
  62. package/_mjs/collection/immutable/Conc/api.mjs.map +1 -1
  63. package/_mjs/collection/immutable/HashMap/api.mjs +4 -7
  64. package/_mjs/collection/immutable/HashMap/api.mjs.map +1 -1
  65. package/_mjs/collection/immutable/HashSet/api.mjs +4 -7
  66. package/_mjs/collection/immutable/HashSet/api.mjs.map +1 -1
  67. package/_mjs/collection/immutable/ImmutableArray/api.mjs +6 -9
  68. package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +1 -1
  69. package/_mjs/collection/immutable/ImmutableArray/instances.mjs.map +1 -1
  70. package/_mjs/control/Pure/api.mjs +8 -20
  71. package/_mjs/control/Pure/api.mjs.map +1 -1
  72. package/_mjs/data/Cause/api.mjs +2 -8
  73. package/_mjs/data/Cause/api.mjs.map +1 -1
  74. package/_mjs/data/Data.mjs +110 -0
  75. package/_mjs/data/Data.mjs.map +1 -0
  76. package/_mjs/data/Datum/api.mjs +2 -8
  77. package/_mjs/data/Datum/api.mjs.map +1 -1
  78. package/_mjs/data/DatumEither/api.mjs +2 -8
  79. package/_mjs/data/DatumEither/api.mjs.map +1 -1
  80. package/_mjs/data/Either/api.mjs +6 -24
  81. package/_mjs/data/Either/api.mjs.map +1 -1
  82. package/_mjs/data/Either/definition.mjs +1 -0
  83. package/_mjs/data/Either/definition.mjs.map +1 -1
  84. package/_mjs/data/Either/destructors.mjs +3 -3
  85. package/_mjs/data/Either/destructors.mjs.map +1 -1
  86. package/_mjs/data/Either/instances.mjs +6 -25
  87. package/_mjs/data/Either/instances.mjs.map +1 -1
  88. package/_mjs/data/EitherT/api.mjs +2 -8
  89. package/_mjs/data/EitherT/api.mjs.map +1 -1
  90. package/_mjs/data/Exit/api.mjs +2 -2
  91. package/_mjs/data/Exit/api.mjs.map +1 -1
  92. package/_mjs/data/Exit/constructors.mjs +1 -4
  93. package/_mjs/data/Exit/constructors.mjs.map +1 -1
  94. package/_mjs/data/Exit/definition.mjs +2 -0
  95. package/_mjs/data/Exit/definition.mjs.map +1 -1
  96. package/_mjs/data/Guard/api.mjs +5 -3
  97. package/_mjs/data/Guard/api.mjs.map +1 -1
  98. package/_mjs/data/Maybe/api.mjs +1 -4
  99. package/_mjs/data/Maybe/api.mjs.map +1 -1
  100. package/_mjs/data/Maybe/definition.mjs +1 -0
  101. package/_mjs/data/Maybe/definition.mjs.map +1 -1
  102. package/_mjs/data/Maybe/instances.mjs +0 -31
  103. package/_mjs/data/Maybe/instances.mjs.map +1 -1
  104. package/_mjs/data/Showable/show.mjs.map +1 -1
  105. package/_mjs/data/Tag/definition.mjs +7 -0
  106. package/_mjs/data/Tag/definition.mjs.map +1 -1
  107. package/_mjs/data/These/instances.mjs +0 -10
  108. package/_mjs/data/These/instances.mjs.map +1 -1
  109. package/_mjs/json/EitherJson.mjs +0 -15
  110. package/_mjs/json/EitherJson.mjs.map +1 -1
  111. package/_mjs/json/MaybeJson.mjs +0 -13
  112. package/_mjs/json/MaybeJson.mjs.map +1 -1
  113. package/_mjs/json/TheseJson.mjs +0 -19
  114. package/_mjs/json/TheseJson.mjs.map +1 -1
  115. package/_mjs/optics/Optional/definition.mjs +1 -4
  116. package/_mjs/optics/Optional/definition.mjs.map +1 -1
  117. package/_mjs/optics/Prism/definition.mjs +1 -4
  118. package/_mjs/optics/Prism/definition.mjs.map +1 -1
  119. package/_mjs/typeclass/MonadExcept.mjs +1 -4
  120. package/_mjs/typeclass/MonadExcept.mjs.map +1 -1
  121. package/_src/collection/immutable/Conc/api.ts +4 -4
  122. package/_src/collection/immutable/HashMap/api.ts +4 -4
  123. package/_src/collection/immutable/HashSet/api.ts +4 -4
  124. package/_src/collection/immutable/ImmutableArray/api.ts +4 -4
  125. package/_src/collection/immutable/ImmutableArray/instances.ts +0 -2
  126. package/_src/control/Pure/api.ts +4 -7
  127. package/_src/control.ts +0 -2
  128. package/_src/data/Cause/api.ts +8 -8
  129. package/_src/data/Data.ts +144 -0
  130. package/_src/data/Datum/api.ts +8 -8
  131. package/_src/data/DatumEither/api.ts +8 -8
  132. package/_src/data/Either/api.ts +18 -18
  133. package/_src/data/Either/definition.ts +2 -1
  134. package/_src/data/Either/destructors.ts +3 -3
  135. package/_src/data/Either/instances.ts +12 -31
  136. package/_src/data/EitherT/api.ts +8 -8
  137. package/_src/data/Exit/api.ts +2 -2
  138. package/_src/data/Exit/constructors.ts +1 -1
  139. package/_src/data/Exit/definition.ts +2 -0
  140. package/_src/data/Guard/api.ts +6 -3
  141. package/_src/data/Maybe/api.ts +4 -4
  142. package/_src/data/Maybe/definition.ts +1 -0
  143. package/_src/data/Maybe/instances.ts +0 -39
  144. package/_src/data/Showable/show.ts +1 -1
  145. package/_src/data/Tag/definition.ts +8 -0
  146. package/_src/data/These/instances.ts +0 -22
  147. package/_src/data.ts +1 -0
  148. package/_src/global.ts +0 -8
  149. package/_src/json/EitherJson.ts +0 -7
  150. package/_src/json/MaybeJson.ts +0 -7
  151. package/_src/json/TheseJson.ts +0 -7
  152. package/_src/optics/Optional/definition.ts +4 -4
  153. package/_src/optics/Prism/definition.ts +1 -1
  154. package/_src/typeclass/MonadExcept.ts +1 -1
  155. package/control.d.ts +0 -2
  156. package/data/Data.d.ts +31 -0
  157. package/data/Either/definition.d.ts +2 -1
  158. package/data/Either/destructors.d.ts +1 -4
  159. package/data/Either/instances.d.ts +0 -6
  160. package/data/Exit/api.d.ts +2 -2
  161. package/data/Exit/definition.d.ts +2 -0
  162. package/data/Guard/api.d.ts +1 -2
  163. package/data/Maybe/definition.d.ts +1 -0
  164. package/data/Maybe/instances.d.ts +0 -12
  165. package/data/Showable/show.d.ts +1 -1
  166. package/data/Tag/definition.d.ts +5 -0
  167. package/data/These/instances.d.ts +0 -6
  168. package/data.d.ts +1 -0
  169. package/global.d.ts +0 -8
  170. package/json/EitherJson.d.ts +0 -6
  171. package/json/MaybeJson.d.ts +0 -6
  172. package/json/TheseJson.d.ts +0 -6
  173. package/package.json +2 -2
  174. package/_cjs/control/CompletablePromise.cjs +0 -21
  175. package/_cjs/control/CompletablePromise.cjs.map +0 -1
  176. package/_cjs/control/InterruptiblePromise.cjs +0 -23
  177. package/_cjs/control/InterruptiblePromise.cjs.map +0 -1
  178. package/_cjs/data/DecodeError/definition.cjs +0 -240
  179. package/_cjs/data/DecodeError/definition.cjs.map +0 -1
  180. package/_cjs/data/DecodeError/instances.cjs +0 -6
  181. package/_cjs/data/DecodeError/instances.cjs.map +0 -1
  182. package/_cjs/data/DecodeError.cjs +0 -28
  183. package/_cjs/data/DecodeError.cjs.map +0 -1
  184. package/_cjs/data/Decoder/api.cjs +0 -572
  185. package/_cjs/data/Decoder/api.cjs.map +0 -1
  186. package/_cjs/data/Decoder/definition.cjs +0 -30
  187. package/_cjs/data/Decoder/definition.cjs.map +0 -1
  188. package/_cjs/data/Decoder.cjs +0 -28
  189. package/_cjs/data/Decoder.cjs.map +0 -1
  190. package/_cjs/data/Encoder/api.cjs +0 -315
  191. package/_cjs/data/Encoder/api.cjs.map +0 -1
  192. package/_cjs/data/Encoder/definition.cjs +0 -22
  193. package/_cjs/data/Encoder/definition.cjs.map +0 -1
  194. package/_cjs/data/Encoder.cjs +0 -28
  195. package/_cjs/data/Encoder.cjs.map +0 -1
  196. package/_mjs/control/CompletablePromise.mjs +0 -15
  197. package/_mjs/control/CompletablePromise.mjs.map +0 -1
  198. package/_mjs/control/InterruptiblePromise.mjs +0 -15
  199. package/_mjs/control/InterruptiblePromise.mjs.map +0 -1
  200. package/_mjs/data/DecodeError/definition.mjs +0 -209
  201. package/_mjs/data/DecodeError/definition.mjs.map +0 -1
  202. package/_mjs/data/DecodeError/instances.mjs +0 -2
  203. package/_mjs/data/DecodeError/instances.mjs.map +0 -1
  204. package/_mjs/data/DecodeError.mjs +0 -5
  205. package/_mjs/data/DecodeError.mjs.map +0 -1
  206. package/_mjs/data/Decoder/api.mjs +0 -542
  207. package/_mjs/data/Decoder/api.mjs.map +0 -1
  208. package/_mjs/data/Decoder/definition.mjs +0 -22
  209. package/_mjs/data/Decoder/definition.mjs.map +0 -1
  210. package/_mjs/data/Decoder.mjs +0 -5
  211. package/_mjs/data/Decoder.mjs.map +0 -1
  212. package/_mjs/data/Encoder/api.mjs +0 -279
  213. package/_mjs/data/Encoder/api.mjs.map +0 -1
  214. package/_mjs/data/Encoder/definition.mjs +0 -15
  215. package/_mjs/data/Encoder/definition.mjs.map +0 -1
  216. package/_mjs/data/Encoder.mjs +0 -5
  217. package/_mjs/data/Encoder.mjs.map +0 -1
  218. package/_src/control/CompletablePromise.ts +0 -23
  219. package/_src/control/InterruptiblePromise.ts +0 -23
  220. package/_src/data/DecodeError/definition.ts +0 -267
  221. package/_src/data/DecodeError/instances.ts +0 -0
  222. package/_src/data/DecodeError.ts +0 -5
  223. package/_src/data/Decoder/api.ts +0 -696
  224. package/_src/data/Decoder/definition.ts +0 -31
  225. package/_src/data/Decoder.ts +0 -5
  226. package/_src/data/Encoder/api.ts +0 -381
  227. package/_src/data/Encoder/definition.ts +0 -16
  228. package/_src/data/Encoder.ts +0 -5
  229. package/control/CompletablePromise.d.ts +0 -13
  230. package/control/InterruptiblePromise.d.ts +0 -12
  231. package/data/DecodeError/definition.d.ts +0 -148
  232. package/data/DecodeError/instances.d.ts +0 -1
  233. package/data/DecodeError.d.ts +0 -2
  234. package/data/Decoder/api.d.ts +0 -214
  235. package/data/Decoder/definition.d.ts +0 -27
  236. package/data/Decoder.d.ts +0 -2
  237. package/data/Encoder/api.d.ts +0 -214
  238. package/data/Encoder/definition.d.ts +0 -16
  239. package/data/Encoder.d.ts +0 -2
@@ -12,10 +12,7 @@ function makePPrism_1(F) {
12
12
  reverseGet: F.reverseGet,
13
13
  ...tsplus_module_2.makePOptional({
14
14
  getOrModify: F.getOrModify,
15
- set: b => s => tsplus_module_1.match({
16
- Left: identity,
17
- Right: () => F.reverseGet(b)
18
- })(F.getOrModify(s))
15
+ set: b => s => tsplus_module_1.match(identity, () => F.reverseGet(b))(F.getOrModify(s))
19
16
  })
20
17
  };
21
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definition.mjs","names":["makePPrism","makePPrism_1","identity","POptional","PPrism","F","reverseGet","tsplus_module_2","makePOptional","getOrModify","set","b","s","tsplus_module_1","match","Left","Right","Prism","makePrism"],"sources":["../../../_src/optics/Prism/definition.ts"],"sourcesContent":[null],"mappings":";;aA+BgBA,UAAU,GAAAC,YAAA;AA7B1B,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,SAAS,QAAQ,6BAA6B;AAkBvD,OAAO,MAAMC,MAAM,GAAc,EAAE;AAOnC;;;AAGA,SAAAH,aAAuCI,CAAwB;EAC7D,OAAO;IACLC,UAAU,EAAED,CAAC,CAACC,UAAU;IACxB,GAAGC,eAAA,CAAAC,aAAA,CAAU;MACXC,WAAW,EAAEJ,CAAC,CAACI,WAAW;MAC1BC,GAAG,EAAGC,CAAC,IAAMC,CAAC,IAAKC,eAAA,CAAAC,KAAA,CAAuB;QAAEC,IAAI,EAAEb,QAAQ;QAAEc,KAAK,EAAEA,CAAA,KAAMX,CAAC,CAACC,UAAU,CAACK,CAAC;MAAC,CAAE,EAAvEN,CAAC,CAACI,WAAW,CAACG,CAAC,CAAC;KACpC;GACF;AACH;AAYA,OAAO,MAAMK,KAAK,GAAa,EAAE;AAEjC;;;AAGA,OAAM,SAAUC,SAASA,CAAOb,CAAwB;EACtD,OAAOJ,YAAA,CAAOI,CAAC,CAAC;AAClB"}
1
+ {"version":3,"file":"definition.mjs","names":["makePPrism","makePPrism_1","identity","POptional","PPrism","F","reverseGet","tsplus_module_2","makePOptional","getOrModify","set","b","s","tsplus_module_1","match","Prism","makePrism"],"sources":["../../../_src/optics/Prism/definition.ts"],"sourcesContent":[null],"mappings":";;aA+BgBA,UAAU,GAAAC,YAAA;AA7B1B,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,SAAS,QAAQ,6BAA6B;AAkBvD,OAAO,MAAMC,MAAM,GAAc,EAAE;AAOnC;;;AAGA,SAAAH,aAAuCI,CAAwB;EAC7D,OAAO;IACLC,UAAU,EAAED,CAAC,CAACC,UAAU;IACxB,GAAGC,eAAA,CAAAC,aAAA,CAAU;MACXC,WAAW,EAAEJ,CAAC,CAACI,WAAW;MAC1BC,GAAG,EAAGC,CAAC,IAAMC,CAAC,IAAKC,eAAA,CAAAC,KAAA,CAAuBZ,QAAQ,EAAE,MAAMG,CAAC,CAACC,UAAU,CAACK,CAAC,CAAC,EAAtDN,CAAC,CAACI,WAAW,CAACG,CAAC,CAAC;KACpC;GACF;AACH;AAYA,OAAO,MAAMG,KAAK,GAAa,EAAE;AAEjC;;;AAGA,OAAM,SAAUC,SAASA,CAAOX,CAAwB;EACtD,OAAOJ,YAAA,CAAOI,CAAC,CAAC;AAClB"}
@@ -1,9 +1,6 @@
1
1
  import * as tsplus_module_1 from "@fncts/base/data/Either/destructors";
2
2
  export const MonadExcept = {};
3
3
  export function absolve(F) {
4
- return F.flatMap(r => tsplus_module_1.match({
5
- Left: F.fail,
6
- Right: F.pure
7
- })(r));
4
+ return F.flatMap(r => tsplus_module_1.match(F.fail, F.pure)(r));
8
5
  }
9
6
  //# sourceMappingURL=MonadExcept.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MonadExcept.mjs","names":["MonadExcept","absolve","F","flatMap","r","tsplus_module_1","match","Left","fail","Right","pure"],"sources":["../../_src/typeclass/MonadExcept.ts"],"sourcesContent":[null],"mappings":";AAaA,OAAO,MAAMA,WAAW,GAAmB,EAAE;AAU7C,OAAM,SAAUC,OAAOA,CACrBC,CAAwB;EAExB,OAAOA,CAAC,CAACC,OAAO,CAAEC,CAAC,IAAKC,eAAA,CAAAC,KAAA,CAAQ;IAAEC,IAAI,EAAEL,CAAC,CAACM,IAAI;IAAEC,KAAK,EAAEP,CAAC,CAACQ;EAAI,CAAE,EAAvCN,CAAC,CAAuC,CAAC;AACnE"}
1
+ {"version":3,"file":"MonadExcept.mjs","names":["MonadExcept","absolve","F","flatMap","r","tsplus_module_1","match","fail","pure"],"sources":["../../_src/typeclass/MonadExcept.ts"],"sourcesContent":[null],"mappings":";AAaA,OAAO,MAAMA,WAAW,GAAmB,EAAE;AAU7C,OAAM,SAAUC,OAAOA,CACrBC,CAAwB;EAExB,OAAOA,CAAC,CAACC,OAAO,CAAEC,CAAC,IAAKC,eAAA,CAAAC,KAAA,CAAQJ,CAAC,CAACK,IAAI,EAAEL,CAAC,CAACM,IAAI,EAAtBJ,CAAC,CAAsB,CAAC;AAClD"}
@@ -874,10 +874,10 @@ export function partitionMapWithIndex<A, B, C>(f: (i: number, a: A) => Either<B,
874
874
  const array = result.value;
875
875
  for (let j = 0; j < array.length; j++) {
876
876
  const eab = f(i, array[j]!);
877
- eab.match({
878
- Left: (b) => left.append(b),
879
- Right: (c) => right.append(c),
880
- });
877
+ eab.match(
878
+ (b) => left.append(b),
879
+ (c) => right.append(c),
880
+ );
881
881
  i++;
882
882
  }
883
883
  }
@@ -476,14 +476,14 @@ export function partitionMapWithIndex<K, V, A, B>(f: (i: K, a: V) => Either<A, B
476
476
  const left = makeWith<K, A>(self.config).beginMutation;
477
477
  const right = makeWith<K, B>(self.config).beginMutation;
478
478
  self.forEachWithIndex((k, v) => {
479
- f(k, v).match({
480
- Left: (a) => {
479
+ f(k, v).match(
480
+ (a) => {
481
481
  left.set(k, a);
482
482
  },
483
- Right: (b) => {
483
+ (b) => {
484
484
  right.set(k, b);
485
485
  },
486
- });
486
+ );
487
487
  });
488
488
  return [left.endMutation, right.endMutation];
489
489
  };
@@ -300,14 +300,14 @@ export function partitionMapWith<B, C>(
300
300
  const right = beginMutation(emptyWith(C));
301
301
  const left = beginMutation(emptyWith(B));
302
302
  fa.forEach((v) => {
303
- f(v).match({
304
- Left: (b) => {
303
+ f(v).match(
304
+ (b) => {
305
305
  left.add(b);
306
306
  },
307
- Right: (c) => {
307
+ (c) => {
308
308
  right.add(c);
309
309
  },
310
- });
310
+ );
311
311
  });
312
312
  return [endMutation(left), endMutation(right)];
313
313
  };
@@ -1430,16 +1430,16 @@ export function _wiltWithIndex<A>(self: ImmutableArray<A>) {
1430
1430
  .foldLeftWithIndex(G.pure([[] as Array<B>, [] as Array<B2>] as const), (i, fbs, a) =>
1431
1431
  f(i, a).pipe(
1432
1432
  G.zipWith(fbs, (eb, r) =>
1433
- eb.match({
1434
- Left: (b1) => {
1433
+ eb.match(
1434
+ (b1) => {
1435
1435
  r[0].push(b1);
1436
1436
  return r;
1437
1437
  },
1438
- Right: (b2) => {
1438
+ (b2) => {
1439
1439
  r[1].push(b2);
1440
1440
  return r;
1441
1441
  },
1442
- }),
1442
+ ),
1443
1443
  ),
1444
1444
  ),
1445
1445
  )
@@ -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
  /**
package/_src/control.ts CHANGED
@@ -2,7 +2,5 @@
2
2
  // codegen:start { preset: type-barrel, include: ./control/*.ts }
3
3
  export type {} from "./control/Pure.js";
4
4
  export type {} from "./control/LazyValue.js";
5
- export type {} from "./control/InterruptiblePromise.js";
6
5
  export type {} from "./control/Eval.js";
7
- export type {} from "./control/CompletablePromise.js";
8
6
  // codegen:end
@@ -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: {
@@ -0,0 +1,144 @@
1
+ import type { Equals } from "@fncts/typelevel/Any";
2
+ import type { True } from "@fncts/typelevel/Boolean";
3
+
4
+ export interface Copy<T> {
5
+ copy(args: Equals<T, {}> extends True ? void : Partial<T>): this;
6
+ }
7
+
8
+ export interface DataClassConstructor {
9
+ new <T>(
10
+ args: Equals<T, {}> extends True
11
+ ? void
12
+ : { readonly [P in keyof T as P extends keyof Equatable ? never : P]: T[P] },
13
+ ): Readonly<T> & Copy<T>;
14
+ }
15
+
16
+ const keysSymbol = Symbol.for("fncts.Data.keys");
17
+
18
+ abstract class StructuralPrototype implements Equatable, Hashable {
19
+ abstract [keysSymbol]: ReadonlyArray<any>;
20
+
21
+ get [Symbol.hash](): number {
22
+ return Hashable.plainObject(this);
23
+ }
24
+ [Symbol.equals](that: unknown): boolean {
25
+ if (!isObject(that)) {
26
+ return false;
27
+ }
28
+ const selfKeys = Object.keys(this);
29
+ const thatKeys = Object.keys(that);
30
+ if (selfKeys.length !== thatKeys.length) {
31
+ return false;
32
+ }
33
+ for (const key of selfKeys) {
34
+ if (!(key in that) && Equatable.strictEquals((this as any)[key], that[key])) {
35
+ return false;
36
+ }
37
+ }
38
+ return true;
39
+ }
40
+ copy(args: void | object) {
41
+ if (!args) {
42
+ if (this[keysSymbol].length === 0) {
43
+ // @ts-expect-error
44
+ return new this.constructor();
45
+ }
46
+
47
+ const properties = {} as Record<any, any>;
48
+ for (const k of this[keysSymbol]) {
49
+ properties[k] = (this as any)[k];
50
+ }
51
+ // @ts-expect-error
52
+ return new this.constructor(properties);
53
+ }
54
+
55
+ const properties = {} as Record<any, any>;
56
+ for (const k of this[keysSymbol]) {
57
+ if (k in (args as any)) {
58
+ properties[k] = (args as any)[k];
59
+ } else {
60
+ properties[k] = (this as any)[k];
61
+ }
62
+ }
63
+
64
+ // @ts-expect-error
65
+ return new this.constructor(properties);
66
+ }
67
+ }
68
+
69
+ const Structural: new <A>(
70
+ args: Equals<Omit<A, keyof Equatable>, {}> extends True
71
+ ? void
72
+ : { readonly [P in keyof A as P extends keyof Equatable ? never : P]: A[P] },
73
+ ) => {} = (function () {
74
+ return class Structural extends StructuralPrototype {
75
+ readonly [keysSymbol]: ReadonlyArray<any> = [];
76
+
77
+ constructor(args: any) {
78
+ super();
79
+ if (args) {
80
+ this[keysSymbol] = Object.keys(args);
81
+ Object.assign(this, args);
82
+ }
83
+ }
84
+ };
85
+ })();
86
+
87
+ export const DataClass: DataClassConstructor = Structural as any;
88
+
89
+ export interface TaggedDataClassConstructor<Tag extends string | symbol, K extends string | symbol> {
90
+ new <T extends Record<string, any> = {}>(
91
+ args: Equals<T, {}> extends True ? void : T,
92
+ ): {
93
+ readonly [P in keyof T as P extends Tag ? never : P]: T[P];
94
+ } & Copy<T> & {
95
+ readonly [k in K]: Tag;
96
+ };
97
+ }
98
+
99
+ export const TaggedClass = <Tag extends string | symbol, Key extends string | symbol = "_tag">(
100
+ tag: Tag,
101
+ key?: Key,
102
+ ): TaggedDataClassConstructor<Tag, Key> => {
103
+ if (key) {
104
+ class Base extends Structural<any> {
105
+ // @ts-expect-error
106
+ readonly [key] = tag;
107
+ }
108
+ return Base as any;
109
+ }
110
+
111
+ class Base extends Structural<any> {
112
+ readonly _tag = tag;
113
+ }
114
+ return Base as any;
115
+ };
116
+
117
+ export function struct<As extends Readonly<Record<string, any>>>(as: As): As {
118
+ return Object.assign(Object.create(StructuralPrototype.prototype), as);
119
+ }
120
+
121
+ export const Error: new <A extends Record<string, any> = {}>(
122
+ args: Equals<A, {}> extends True ? void : { readonly [P in keyof A]: A[P] },
123
+ ) => Error & Readonly<A> = (function () {
124
+ return class Base extends globalThis.Error {
125
+ constructor(args: any) {
126
+ super();
127
+ if (args) {
128
+ Object.assign(this, args);
129
+ }
130
+ }
131
+ } as any;
132
+ })();
133
+
134
+ export function TaggedError<Tag extends string>(
135
+ tag: Tag,
136
+ ): new <A extends Record<string, any> = {}>(
137
+ args: Equals<A, {}> extends True ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] },
138
+ ) => Error & { readonly _tag: Tag } & Readonly<A> {
139
+ class Base extends Error<{}> {
140
+ readonly _tag = tag;
141
+ }
142
+ Base.prototype.name = tag;
143
+ return Base as any;
144
+ }
@@ -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 */
@@ -26,10 +26,11 @@ type IOTypeId = typeof IOTypeId;
26
26
  * @tsplus type fncts.Either
27
27
  * @tsplus companion fncts.EitherOps
28
28
  */
29
- export class Either<E, A> {
29
+ export abstract class Either<E, A> {
30
30
  readonly [EitherTypeId]: EitherTypeId = EitherTypeId;
31
31
  readonly [IOTypeId]: IOTypeId = IOTypeId;
32
32
  readonly trace?: string | undefined = undefined;
33
+ readonly _ioOpCode = null;
33
34
  declare [EitherVariance]: {
34
35
  readonly _E: (_: never) => E;
35
36
  readonly _A: (_: never) => A;
@@ -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
  }
@@ -223,9 +223,9 @@ export function value<E, A>(self: Exit<E, A>): A | undefined {
223
223
  /**
224
224
  * Returns the Exit's Success value if it exists, or throws the pretty-printed Cause if it doesn't
225
225
  *
226
- * @tsplus getter fncts.Exit valueOrThrow
226
+ * @tsplus getter fncts.Exit getOrThrow
227
227
  */
228
- export function valueOrThrow<E, A>(self: Exit<E, A>): A {
228
+ export function getOrThrow<E, A>(self: Exit<E, A>): A {
229
229
  if (self.isFailure()) {
230
230
  throw new IOError(self.cause);
231
231
  }
@@ -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
  /**
@@ -35,6 +35,7 @@ const _successHash = Hashable.string("fncts.Exit.Success");
35
35
  */
36
36
  export class Failure<E> {
37
37
  readonly [ExitTypeId]: ExitTypeId = ExitTypeId;
38
+ readonly _ioOpCode = null;
38
39
  declare [ExitVariance]: {
39
40
  readonly _E: (_: never) => E;
40
41
  readonly _A: (_: never) => never;
@@ -60,6 +61,7 @@ export class Failure<E> {
60
61
  */
61
62
  export class Success<A> implements P.Hashable, P.Equatable {
62
63
  readonly [ExitTypeId]: ExitTypeId = ExitTypeId;
64
+ readonly _ioOpCode = null;
63
65
  declare [ExitVariance]: {
64
66
  readonly _E: (_: never) => never;
65
67
  readonly _A: (_: never) => A;
@@ -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;