@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
@@ -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
  }
@@ -32,6 +32,7 @@ export abstract class Maybe<A> {
32
32
  declare [MaybeVariance]: {
33
33
  readonly _A: (_: never) => A;
34
34
  };
35
+ readonly _ioOpCode = null;
35
36
  readonly [MaybeTypeId]: MaybeTypeId = MaybeTypeId;
36
37
  readonly [IOTypeId]: IOTypeId = IOTypeId;
37
38
  readonly trace?: string | undefined = undefined;
@@ -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
- }
@@ -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
 
@@ -16,6 +16,7 @@ type IOTypeId = typeof IOTypeId;
16
16
  * @tsplus companion fncts.TagOps
17
17
  */
18
18
  export class Tag<in out T, in out Identifier = T> implements Hashable, Equatable {
19
+ readonly _ioOpCode = null;
19
20
  readonly _tag = "Tag";
20
21
  readonly [TagTypeId]: TagTypeId = TagTypeId;
21
22
  readonly [IOTypeId]: IOTypeId = IOTypeId;
@@ -44,3 +45,10 @@ export declare namespace Tag {
44
45
  export function isTag(u: unknown): u is Tag<unknown> {
45
46
  return isObject(u) && TagTypeId in u;
46
47
  }
48
+
49
+ /**
50
+ * @tsplus unify fncts.Tag
51
+ */
52
+ export function unifyIO<X extends Tag<any, any>>(self: X): X {
53
+ return self;
54
+ }
@@ -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/data.ts CHANGED
@@ -42,6 +42,7 @@ export type {} from "./data/Decoder.js";
42
42
  export type {} from "./data/DecodeError.js";
43
43
  export type {} from "./data/DatumEither.js";
44
44
  export type {} from "./data/Date.js";
45
+ export type {} from "./data/Data.js";
45
46
  export type {} from "./data/Const.js";
46
47
  export type {} from "./data/Cause.js";
47
48
  export type {} from "./data/CaseClass.js";
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
  }
package/control.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  export type {} from "./control/Pure.js";
2
2
  export type {} from "./control/LazyValue.js";
3
- export type {} from "./control/InterruptiblePromise.js";
4
3
  export type {} from "./control/Eval.js";
5
- export type {} from "./control/CompletablePromise.js";
package/data/Data.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { Equatable } from "@fncts/base/data/Equatable";
2
+ import { Hashable } from "@fncts/base/data/Hashable";
3
+ import { isObject } from "@fncts/base/util/predicates";
4
+ import type { Equals } from "@fncts/typelevel/Any";
5
+ import type { True } from "@fncts/typelevel/Boolean";
6
+ export interface Copy<T> {
7
+ copy(args: Equals<T, {}> extends True ? void : Partial<T>): this;
8
+ }
9
+ export interface DataClassConstructor {
10
+ new <T>(args: Equals<T, {}> extends True ? void : {
11
+ readonly [P in keyof T as P extends keyof Equatable ? never : P]: T[P];
12
+ }): Readonly<T> & Copy<T>;
13
+ }
14
+ export declare const DataClass: DataClassConstructor;
15
+ export interface TaggedDataClassConstructor<Tag extends string | symbol, K extends string | symbol> {
16
+ new <T extends Record<string, any> = {}>(args: Equals<T, {}> extends True ? void : T): {
17
+ readonly [P in keyof T as P extends Tag ? never : P]: T[P];
18
+ } & Copy<T> & {
19
+ readonly [k in K]: Tag;
20
+ };
21
+ }
22
+ export declare const TaggedClass: <Tag extends string | symbol, Key extends string | symbol = "_tag">(tag: Tag, key?: Key) => TaggedDataClassConstructor<Tag, Key>;
23
+ export declare function struct<As extends Readonly<Record<string, any>>>(as: As): As;
24
+ export declare const Error: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends True ? void : {
25
+ readonly [P in keyof A]: A[P];
26
+ }) => Error & Readonly<A>;
27
+ export declare function TaggedError<Tag extends string>(tag: Tag): new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends True ? void : {
28
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
29
+ }) => Error & {
30
+ readonly _tag: Tag;
31
+ } & Readonly<A>;
@@ -22,10 +22,11 @@ type IOTypeId = typeof IOTypeId;
22
22
  * @tsplus type fncts.Either
23
23
  * @tsplus companion fncts.EitherOps
24
24
  */
25
- export declare class Either<E, A> {
25
+ export declare abstract class Either<E, A> {
26
26
  readonly [EitherTypeId]: EitherTypeId;
27
27
  readonly [IOTypeId]: IOTypeId;
28
28
  readonly trace?: string | undefined;
29
+ readonly _ioOpCode: null;
29
30
  [EitherVariance]: {
30
31
  readonly _E: (_: never) => E;
31
32
  readonly _A: (_: never) => A;
@@ -3,7 +3,4 @@ import { Either } from "@fncts/base/data/Either/definition";
3
3
  * @tsplus pipeable fncts.Either match
4
4
  * @tsplus location "@fncts/base/data/Either/destructors"
5
5
  */
6
- export declare function match<E, A, B, C>(cases: {
7
- Left: (e: E) => B;
8
- Right: (a: A) => C;
9
- }): (self: Either<E, A>) => B | C;
6
+ export declare function match<E, A, B, C>(onLeft: (e: E) => B, onRight: (a: A) => C): (self: Either<E, A>) => B | C;
@@ -1,7 +1,6 @@
1
1
  import { HKT } from "@fncts/typelevel/HKT";
2
2
  import { Predicate } from "@fncts/base/data/Predicate/definition";
3
3
  import { Guard } from "@fncts/base/data/Guard";
4
- import { Decoder } from "@fncts/base/data/Decoder/definition";
5
4
  import type { EitherF } from "@fncts/base/data/Either/definition.js";
6
5
  import { Either } from "@fncts/base/data/Either/definition";
7
6
  import * as P from "../../typeclass.js";
@@ -30,8 +29,3 @@ export declare function getFilerable<E>(/** @tsplus auto */ ME: P.Monoid<E>): P.
30
29
  * @tsplus location "@fncts/base/data/Either/instances"
31
30
  */
32
31
  export declare function deriveGuard<A extends Either<any, any>>(...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Guard<E>, right: Guard<A>] : never): Guard<A>;
33
- /**
34
- * @tsplus derive fncts.Decoder[fncts.Either]<_> 10
35
- * @tsplus location "@fncts/base/data/Either/instances"
36
- */
37
- export declare function deriveDecoder<A extends Either<any, any>>(...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never): Decoder<A>;
@@ -105,7 +105,7 @@ export declare function zipWithCause<E, A, G, B, C>(fb: Exit<G, B>, f: (a: A, b:
105
105
  export declare function value<E, A>(self: Exit<E, A>): A | undefined;
106
106
  /**
107
107
  * Returns the Exit's Success value if it exists, or throws the pretty-printed Cause if it doesn't
108
- * @tsplus getter fncts.Exit valueOrThrow
108
+ * @tsplus getter fncts.Exit getOrThrow
109
109
  * @tsplus location "@fncts/base/data/Exit/api"
110
110
  */
111
- export declare function valueOrThrow<E, A>(self: Exit<E, A>): A;
111
+ export declare function getOrThrow<E, A>(self: Exit<E, A>): A;
@@ -29,6 +29,7 @@ export declare class Failure<E> {
29
29
  readonly cause: Cause<E>;
30
30
  readonly trace?: string | undefined;
31
31
  readonly [ExitTypeId]: ExitTypeId;
32
+ readonly _ioOpCode: null;
32
33
  [ExitVariance]: {
33
34
  readonly _E: (_: never) => E;
34
35
  readonly _A: (_: never) => never;
@@ -47,6 +48,7 @@ export declare class Success<A> implements P.Hashable, P.Equatable {
47
48
  readonly value: A;
48
49
  readonly trace?: string | undefined;
49
50
  readonly [ExitTypeId]: ExitTypeId;
51
+ readonly _ioOpCode: null;
50
52
  [ExitVariance]: {
51
53
  readonly _E: (_: never) => never;
52
54
  readonly _A: (_: never) => A;
@@ -3,7 +3,6 @@ import { Predicate } from "@fncts/base/data/Predicate/definition";
3
3
  import { ImmutableArray } from "@fncts/base/collection/immutable/ImmutableArray/definition";
4
4
  import { ImmutableNonEmptyArray } from "@fncts/base/collection/immutable/ImmutableNonEmptyArray/definition";
5
5
  import { Conc } from "@fncts/base/collection/immutable/Conc";
6
- import { Encoder } from "@fncts/base/data/Encoder/definition";
7
6
  import type { Brand, Validation } from "@fncts/base/data/Branded";
8
7
  import type { Check } from "@fncts/typelevel";
9
8
  import type { Literal } from "@fncts/typelevel/Any";
@@ -232,7 +231,7 @@ export declare function validation<A, B extends ReadonlyArray<Validation<A, any>
232
231
  */
233
232
  export declare function deriveTuple<A extends ReadonlyArray<unknown>>(...[components]: Check<Check.IsTuple<A>> extends Check.True ? [components: {
234
233
  [K in keyof A]: Guard<A[K]>;
235
- }] : never): Encoder<A>;
234
+ }] : never): Guard<A>;
236
235
  /**
237
236
  * @tsplus static fncts.GuardOps tuple
238
237
  * @tsplus location "@fncts/base/data/Guard/api"
@@ -25,6 +25,7 @@ export declare abstract class Maybe<A> {
25
25
  [MaybeVariance]: {
26
26
  readonly _A: (_: never) => A;
27
27
  };
28
+ readonly _ioOpCode: null;
28
29
  readonly [MaybeTypeId]: MaybeTypeId;
29
30
  readonly [IOTypeId]: IOTypeId;
30
31
  readonly trace?: string | undefined;
@@ -1,7 +1,5 @@
1
1
  import { Maybe } from "@fncts/base/data/Maybe/definition";
2
2
  import { Guard } from "@fncts/base/data/Guard";
3
- import { Decoder } from "@fncts/base/data/Decoder/definition";
4
- import { Encoder } from "@fncts/base/data/Encoder/definition";
5
3
  import type * as P from "../../typeclass.js";
6
4
  import type { MaybeF } from "@fncts/base/data/Maybe/definition";
7
5
  /**
@@ -39,13 +37,3 @@ export declare const Filterable: P.Filterable<MaybeF, import("@fncts/typelevel/H
39
37
  * @tsplus location "@fncts/base/data/Maybe/instances"
40
38
  */
41
39
  export declare function deriveGuard<A extends Maybe<any>>(...[guard]: [A] extends [Maybe<infer A>] ? [guard: Guard<A>] : never): Guard<A>;
42
- /**
43
- * @tsplus derive fncts.Decoder[fncts.Maybe]<_> 10
44
- * @tsplus location "@fncts/base/data/Maybe/instances"
45
- */
46
- export declare function deriveDecoder<A extends Maybe<any>>(...[value]: [A] extends [Maybe<infer A>] ? [value: Decoder<A>] : never): Decoder<A>;
47
- /**
48
- * @tsplus derive fncts.Encoder[fncts.Maybe]<_> 10
49
- * @tsplus location "@fncts/base/data/Maybe/instances"
50
- */
51
- export declare function deriveEncoder<A extends Maybe<any>>(...[value]: [A] extends [Maybe<infer A>] ? [value: Encoder<A>] : never): Encoder<A>;
@@ -50,6 +50,6 @@ export interface ShowComputationComplex {
50
50
  export declare function showComputationComplex(args: Omit<ShowComputationComplex, "_tag">): ShowComputationComplex;
51
51
  export type ShowComputationExternal = ShowComputationPrimitive | ShowComputationComplex;
52
52
  export declare function show(value: unknown): string;
53
- export declare function showWithOptions(value: unknown, options: Partial<ShowOptions>): string;
53
+ export declare function showWithOptions(value: unknown, options?: Partial<ShowOptions>): string;
54
54
  export declare function _show(value: unknown): ShowComputation;
55
55
  export declare function showProperty(value: object, key: PropertyKey, type: number, desc?: PropertyDescriptor): ShowComputation;
@@ -14,6 +14,7 @@ type IOTypeId = typeof IOTypeId;
14
14
  */
15
15
  export declare class Tag<in out T, in out Identifier = T> implements Hashable, Equatable {
16
16
  readonly id: string;
17
+ readonly _ioOpCode: null;
17
18
  readonly _tag = "Tag";
18
19
  readonly [TagTypeId]: TagTypeId;
19
20
  readonly [IOTypeId]: IOTypeId;
@@ -31,4 +32,8 @@ export declare namespace Tag {
31
32
  type Identifier<T> = T extends Tag<any, infer A> ? A : never;
32
33
  }
33
34
  export declare function isTag(u: unknown): u is Tag<unknown>;
35
+ /**
36
+ * @tsplus unify fncts.Tag
37
+ */
38
+ export declare function unifyIO<X extends Tag<any, any>>(self: X): X;
34
39
  export {};
@@ -1,13 +1,7 @@
1
1
  import { These } from "@fncts/base/data/These";
2
2
  import { Guard } from "@fncts/base/data/Guard";
3
- import { Decoder } from "@fncts/base/data/Decoder/definition";
4
3
  /**
5
4
  * @tsplus derive fncts.Guard[fncts.These]<_> 10
6
5
  * @tsplus location "@fncts/base/data/These/instances"
7
6
  */
8
7
  export declare function deriveGuard<A extends These<any, any>>(...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Guard<E>, right: Guard<A>] : never): Guard<A>;
9
- /**
10
- * @tsplus derive fncts.Decoder[fncts.These]<_> 10
11
- * @tsplus location "@fncts/base/data/These/instances"
12
- */
13
- export declare function deriveDecoder<A extends These<any, any>>(...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never): Decoder<A>;
package/data.d.ts CHANGED
@@ -40,6 +40,7 @@ export type {} from "./data/Decoder.js";
40
40
  export type {} from "./data/DecodeError.js";
41
41
  export type {} from "./data/DatumEither.js";
42
42
  export type {} from "./data/Date.js";
43
+ export type {} from "./data/Data.js";
43
44
  export type {} from "./data/Const.js";
44
45
  export type {} from "./data/Cause.js";
45
46
  export type {} from "./data/CaseClass.js";
package/global.d.ts CHANGED
@@ -102,10 +102,6 @@ import { Datum } from "@fncts/base/data/Datum/definition";
102
102
  * @tsplus global
103
103
  */
104
104
  import { DatumEither } from "@fncts/base/data/DatumEither/definition";
105
- /**
106
- * @tsplus global
107
- */
108
- import { Decoder } from "@fncts/base/data/Decoder/definition";
109
105
  /**
110
106
  * @tsplus global
111
107
  */
@@ -114,10 +110,6 @@ import { Duration } from "@fncts/base/data/Duration/definition";
114
110
  * @tsplus global
115
111
  */
116
112
  import { Either } from "@fncts/base/data/Either/definition";
117
- /**
118
- * @tsplus global
119
- */
120
- import { Encoder } from "@fncts/base/data/Encoder/definition";
121
113
  /**
122
114
  * @tsplus global
123
115
  */
@@ -1,4 +1,3 @@
1
- import { Decoder } from "@fncts/base/data/Decoder/definition";
2
1
  export interface RightJson<A> {
3
2
  readonly _tag: "Right";
4
3
  readonly right: A;
@@ -17,8 +16,3 @@ export type EitherJson<E, A> = LeftJson<E> | RightJson<A>;
17
16
  export interface EitherJsonOps {
18
17
  }
19
18
  export declare const EitherJson: EitherJsonOps;
20
- /**
21
- * @tsplus static fncts.EitherJsonOps getDecoder
22
- * @tsplus location "@fncts/base/json/EitherJson"
23
- */
24
- export declare function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<EitherJson<E, A>>;
@@ -1,4 +1,3 @@
1
- import { Decoder } from "@fncts/base/data/Decoder/definition";
2
1
  export interface NothingJson {
3
2
  readonly _tag: "Nothing";
4
3
  }
@@ -16,8 +15,3 @@ export type MaybeJson<A> = NothingJson | JustJson<A>;
16
15
  export interface MaybeJsonOps {
17
16
  }
18
17
  export declare const MaybeJson: MaybeJsonOps;
19
- /**
20
- * @tsplus static fncts.MaybeJsonOps getDecoder
21
- * @tsplus location "@fncts/base/json/MaybeJson"
22
- */
23
- export declare function getDecoder<A>(value: Decoder<A>): Decoder<MaybeJson<A>>;
@@ -1,4 +1,3 @@
1
- import { Decoder } from "@fncts/base/data/Decoder/definition";
2
1
  export interface LeftJson<E> {
3
2
  readonly _tag: "Left";
4
3
  readonly left: E;
@@ -19,8 +18,3 @@ export type TheseJson<E, A> = LeftJson<E> | RightJson<A> | BothJson<E, A>;
19
18
  export interface TheseJsonOps {
20
19
  }
21
20
  export declare const TheseJson: TheseJsonOps;
22
- /**
23
- * @tsplus static fncts.TheseJsonOps getDecoder
24
- * @tsplus location "@fncts/base/json/TheseJson"
25
- */
26
- export declare function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<TheseJson<E, A>>;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@fncts/base",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "dependencies": {
5
- "@fncts/typelevel": "0.0.16",
5
+ "@fncts/typelevel": "0.0.18",
6
6
  "uuid": "^9.0.1"
7
7
  },
8
8
  "exports": {
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.make = make;
7
- /**
8
- * @tsplus static fncts.CompletablePromiseOps __call
9
- */
10
- function make() {
11
- let outerResolve = () => {};
12
- let outerReject = () => {};
13
- const promise = new Promise((resolve, reject) => {
14
- outerResolve = resolve;
15
- outerReject = reject;
16
- });
17
- promise.resolve = outerResolve;
18
- promise.reject = outerReject;
19
- return promise;
20
- }
21
- //# sourceMappingURL=CompletablePromise.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CompletablePromise.cjs","names":["make","outerResolve","outerReject","promise","Promise","resolve","reject"],"sources":["../../_src/control/CompletablePromise.ts"],"sourcesContent":[null],"mappings":";;;;;;AASA;;;AAGM,SAAUA,IAAIA,CAAA;EAClB,IAAIC,YAAY,GAA6BA,CAAA,KAAK,CAAE,CAAC;EACrD,IAAIC,WAAW,GAA8BA,CAAA,KAAK,CAAE,CAAC;EACrD,MAAMC,OAAO,GAAgC,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAI;IAC3EL,YAAY,GAAGI,OAAO;IACtBH,WAAW,GAAII,MAAM;EACvB,CAAC,CAAQ;EACTH,OAAO,CAACE,OAAO,GAAGJ,YAAY;EAC9BE,OAAO,CAACG,MAAM,GAAIJ,WAAW;EAC7B,OAAOC,OAAO;AAChB"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.make = make;
7
- var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/exceptions"));
8
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- /**
11
- * @tsplus static fncts.InterruptiblePromiseOps __call
12
- */
13
- function make(executor) {
14
- const promise = new Promise((resolve, reject) => {
15
- const canceller = executor(resolve, reject);
16
- promise.interrupt = () => {
17
- canceller?.();
18
- reject(new tsplus_module_1.InterruptedException());
19
- };
20
- });
21
- return promise;
22
- }
23
- //# sourceMappingURL=InterruptiblePromise.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InterruptiblePromise.cjs","names":["make","executor","promise","Promise","resolve","reject","canceller","interrupt","tsplus_module_1","InterruptedException"],"sources":["../../_src/control/InterruptiblePromise.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AAQA;;;AAGM,SAAUA,IAAIA,CAClBC,QAAmH;EAEnH,MAAMC,OAAO,GAA4B,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAI;IACvE,MAAMC,SAAS,GAAKL,QAAQ,CAACG,OAAO,EAAEC,MAAM,CAAC;IAC7CH,OAAO,CAACK,SAAS,GAAG,MAAK;MACvBD,SAAS,GAAE,CAAE;MACbD,MAAM,CAAC,IAAAG,eAAA,CAAIC,oBAAoB,EAAE,CAAC;IACpC,CAAC;EACH,CAAC,CAA4B;EAC7B,OAAOP,OAAO;AAChB"}