@nlozgachev/pipelined 0.6.4

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 (144) hide show
  1. package/README.md +85 -0
  2. package/esm/mod.js +3 -0
  3. package/esm/package.json +3 -0
  4. package/esm/src/Composition/compose.js +3 -0
  5. package/esm/src/Composition/converge.js +3 -0
  6. package/esm/src/Composition/curry.js +42 -0
  7. package/esm/src/Composition/flip.js +20 -0
  8. package/esm/src/Composition/flow.js +8 -0
  9. package/esm/src/Composition/fn.js +85 -0
  10. package/esm/src/Composition/index.js +13 -0
  11. package/esm/src/Composition/juxt.js +3 -0
  12. package/esm/src/Composition/memoize.js +66 -0
  13. package/esm/src/Composition/not.js +25 -0
  14. package/esm/src/Composition/on.js +12 -0
  15. package/esm/src/Composition/pipe.js +3 -0
  16. package/esm/src/Composition/tap.js +33 -0
  17. package/esm/src/Composition/uncurry.js +32 -0
  18. package/esm/src/Core/Arr.js +463 -0
  19. package/esm/src/Core/Deferred.js +26 -0
  20. package/esm/src/Core/InternalTypes.js +1 -0
  21. package/esm/src/Core/Lens.js +98 -0
  22. package/esm/src/Core/Option.js +186 -0
  23. package/esm/src/Core/Optional.js +160 -0
  24. package/esm/src/Core/Reader.js +134 -0
  25. package/esm/src/Core/Rec.js +167 -0
  26. package/esm/src/Core/RemoteData.js +206 -0
  27. package/esm/src/Core/Result.js +164 -0
  28. package/esm/src/Core/Task.js +187 -0
  29. package/esm/src/Core/TaskOption.js +105 -0
  30. package/esm/src/Core/TaskResult.js +125 -0
  31. package/esm/src/Core/TaskValidation.js +101 -0
  32. package/esm/src/Core/These.js +241 -0
  33. package/esm/src/Core/Validation.js +214 -0
  34. package/esm/src/Core/index.js +15 -0
  35. package/esm/src/Types/Brand.js +28 -0
  36. package/esm/src/Types/NonEmptyList.js +14 -0
  37. package/esm/src/Types/index.js +2 -0
  38. package/package.json +61 -0
  39. package/script/mod.js +19 -0
  40. package/script/package.json +3 -0
  41. package/script/src/Composition/compose.js +6 -0
  42. package/script/src/Composition/converge.js +6 -0
  43. package/script/src/Composition/curry.js +48 -0
  44. package/script/src/Composition/flip.js +24 -0
  45. package/script/src/Composition/flow.js +11 -0
  46. package/script/src/Composition/fn.js +98 -0
  47. package/script/src/Composition/index.js +29 -0
  48. package/script/src/Composition/juxt.js +6 -0
  49. package/script/src/Composition/memoize.js +71 -0
  50. package/script/src/Composition/not.js +29 -0
  51. package/script/src/Composition/on.js +16 -0
  52. package/script/src/Composition/pipe.js +6 -0
  53. package/script/src/Composition/tap.js +37 -0
  54. package/script/src/Composition/uncurry.js +38 -0
  55. package/script/src/Core/Arr.js +466 -0
  56. package/script/src/Core/Deferred.js +29 -0
  57. package/script/src/Core/InternalTypes.js +2 -0
  58. package/script/src/Core/Lens.js +101 -0
  59. package/script/src/Core/Option.js +189 -0
  60. package/script/src/Core/Optional.js +163 -0
  61. package/script/src/Core/Reader.js +137 -0
  62. package/script/src/Core/Rec.js +170 -0
  63. package/script/src/Core/RemoteData.js +209 -0
  64. package/script/src/Core/Result.js +167 -0
  65. package/script/src/Core/Task.js +190 -0
  66. package/script/src/Core/TaskOption.js +108 -0
  67. package/script/src/Core/TaskResult.js +128 -0
  68. package/script/src/Core/TaskValidation.js +104 -0
  69. package/script/src/Core/These.js +244 -0
  70. package/script/src/Core/Validation.js +217 -0
  71. package/script/src/Core/index.js +31 -0
  72. package/script/src/Types/Brand.js +31 -0
  73. package/script/src/Types/NonEmptyList.js +18 -0
  74. package/script/src/Types/index.js +18 -0
  75. package/types/mod.d.ts +4 -0
  76. package/types/mod.d.ts.map +1 -0
  77. package/types/src/Composition/compose.d.ts +33 -0
  78. package/types/src/Composition/compose.d.ts.map +1 -0
  79. package/types/src/Composition/converge.d.ts +21 -0
  80. package/types/src/Composition/converge.d.ts.map +1 -0
  81. package/types/src/Composition/curry.d.ts +43 -0
  82. package/types/src/Composition/curry.d.ts.map +1 -0
  83. package/types/src/Composition/flip.d.ts +21 -0
  84. package/types/src/Composition/flip.d.ts.map +1 -0
  85. package/types/src/Composition/flow.d.ts +56 -0
  86. package/types/src/Composition/flow.d.ts.map +1 -0
  87. package/types/src/Composition/fn.d.ts +76 -0
  88. package/types/src/Composition/fn.d.ts.map +1 -0
  89. package/types/src/Composition/index.d.ts +14 -0
  90. package/types/src/Composition/index.d.ts.map +1 -0
  91. package/types/src/Composition/juxt.d.ts +18 -0
  92. package/types/src/Composition/juxt.d.ts.map +1 -0
  93. package/types/src/Composition/memoize.d.ts +46 -0
  94. package/types/src/Composition/memoize.d.ts.map +1 -0
  95. package/types/src/Composition/not.d.ts +26 -0
  96. package/types/src/Composition/not.d.ts.map +1 -0
  97. package/types/src/Composition/on.d.ts +13 -0
  98. package/types/src/Composition/on.d.ts.map +1 -0
  99. package/types/src/Composition/pipe.d.ts +56 -0
  100. package/types/src/Composition/pipe.d.ts.map +1 -0
  101. package/types/src/Composition/tap.d.ts +31 -0
  102. package/types/src/Composition/tap.d.ts.map +1 -0
  103. package/types/src/Composition/uncurry.d.ts +54 -0
  104. package/types/src/Composition/uncurry.d.ts.map +1 -0
  105. package/types/src/Core/Arr.d.ts +355 -0
  106. package/types/src/Core/Arr.d.ts.map +1 -0
  107. package/types/src/Core/Deferred.d.ts +49 -0
  108. package/types/src/Core/Deferred.d.ts.map +1 -0
  109. package/types/src/Core/InternalTypes.d.ts +20 -0
  110. package/types/src/Core/InternalTypes.d.ts.map +1 -0
  111. package/types/src/Core/Lens.d.ts +118 -0
  112. package/types/src/Core/Lens.d.ts.map +1 -0
  113. package/types/src/Core/Option.d.ts +205 -0
  114. package/types/src/Core/Option.d.ts.map +1 -0
  115. package/types/src/Core/Optional.d.ts +158 -0
  116. package/types/src/Core/Optional.d.ts.map +1 -0
  117. package/types/src/Core/Reader.d.ts +156 -0
  118. package/types/src/Core/Reader.d.ts.map +1 -0
  119. package/types/src/Core/Rec.d.ts +121 -0
  120. package/types/src/Core/Rec.d.ts.map +1 -0
  121. package/types/src/Core/RemoteData.d.ts +192 -0
  122. package/types/src/Core/RemoteData.d.ts.map +1 -0
  123. package/types/src/Core/Result.d.ts +176 -0
  124. package/types/src/Core/Result.d.ts.map +1 -0
  125. package/types/src/Core/Task.d.ts +189 -0
  126. package/types/src/Core/Task.d.ts.map +1 -0
  127. package/types/src/Core/TaskOption.d.ts +120 -0
  128. package/types/src/Core/TaskOption.d.ts.map +1 -0
  129. package/types/src/Core/TaskResult.d.ts +117 -0
  130. package/types/src/Core/TaskResult.d.ts.map +1 -0
  131. package/types/src/Core/TaskValidation.d.ts +119 -0
  132. package/types/src/Core/TaskValidation.d.ts.map +1 -0
  133. package/types/src/Core/These.d.ts +221 -0
  134. package/types/src/Core/These.d.ts.map +1 -0
  135. package/types/src/Core/Validation.d.ts +213 -0
  136. package/types/src/Core/Validation.d.ts.map +1 -0
  137. package/types/src/Core/index.d.ts +16 -0
  138. package/types/src/Core/index.d.ts.map +1 -0
  139. package/types/src/Types/Brand.d.ts +52 -0
  140. package/types/src/Types/Brand.d.ts.map +1 -0
  141. package/types/src/Types/NonEmptyList.d.ts +29 -0
  142. package/types/src/Types/NonEmptyList.d.ts.map +1 -0
  143. package/types/src/Types/index.d.ts +3 -0
  144. package/types/src/Types/index.d.ts.map +1 -0
@@ -0,0 +1,221 @@
1
+ import { WithFirst, WithKind, WithSecond } from "./InternalTypes.js";
2
+ /**
3
+ * These<A, B> is an inclusive-OR type: it holds a first value (A), a second
4
+ * value (B), or both simultaneously. Neither side carries a success/failure
5
+ * connotation — it is a neutral pair where any combination is valid.
6
+ *
7
+ * - First(a) — only a first value
8
+ * - Second(b) — only a second value
9
+ * - Both(a, b) — first and second values simultaneously
10
+ *
11
+ * A common use: lenient parsers or processors that carry a diagnostic note
12
+ * alongside a result, without losing either piece of information.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const parse = (s: string): These<number, string> => {
17
+ * const trimmed = s.trim();
18
+ * const n = parseFloat(trimmed);
19
+ * if (isNaN(n)) return These.second("Not a number");
20
+ * if (s !== trimmed) return These.both(n, "Leading/trailing whitespace trimmed");
21
+ * return These.first(n);
22
+ * };
23
+ * ```
24
+ */
25
+ export type These<A, B> = TheseFirst<A> | TheseSecond<B> | TheseBoth<A, B>;
26
+ export type TheseFirst<T> = WithKind<"First"> & WithFirst<T>;
27
+ export type TheseSecond<T> = WithKind<"Second"> & WithSecond<T>;
28
+ export type TheseBoth<First, Second> = WithKind<"Both"> & WithFirst<First> & WithSecond<Second>;
29
+ export declare namespace These {
30
+ /**
31
+ * Creates a These holding only a first value.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * These.first(42); // { kind: "First", first: 42 }
36
+ * ```
37
+ */
38
+ const first: <A>(value: A) => TheseFirst<A>;
39
+ /**
40
+ * Creates a These holding only a second value.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * These.second("warning"); // { kind: "Second", second: "warning" }
45
+ * ```
46
+ */
47
+ const second: <B>(value: B) => TheseSecond<B>;
48
+ /**
49
+ * Creates a These holding both a first and a second value simultaneously.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * These.both(42, "Deprecated API used"); // { kind: "Both", first: 42, second: "Deprecated API used" }
54
+ * ```
55
+ */
56
+ const both: <A, B>(first: A, second: B) => TheseBoth<A, B>;
57
+ /**
58
+ * Type guard — checks if a These holds only a first value.
59
+ */
60
+ const isFirst: <A, B>(data: These<A, B>) => data is TheseFirst<A>;
61
+ /**
62
+ * Type guard — checks if a These holds only a second value.
63
+ */
64
+ const isSecond: <A, B>(data: These<A, B>) => data is TheseSecond<B>;
65
+ /**
66
+ * Type guard — checks if a These holds both values simultaneously.
67
+ */
68
+ const isBoth: <A, B>(data: These<A, B>) => data is TheseBoth<A, B>;
69
+ /**
70
+ * Returns true if the These contains a first value (First or Both).
71
+ */
72
+ const hasFirst: <A, B>(data: These<A, B>) => data is TheseFirst<A> | TheseBoth<A, B>;
73
+ /**
74
+ * Returns true if the These contains a second value (Second or Both).
75
+ */
76
+ const hasSecond: <A, B>(data: These<A, B>) => data is TheseSecond<B> | TheseBoth<A, B>;
77
+ /**
78
+ * Transforms the first value, leaving the second unchanged.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * pipe(These.first(5), These.mapFirst(n => n * 2)); // First(10)
83
+ * pipe(These.both(5, "warn"), These.mapFirst(n => n * 2)); // Both(10, "warn")
84
+ * pipe(These.second("warn"), These.mapFirst(n => n * 2)); // Second("warn")
85
+ * ```
86
+ */
87
+ const mapFirst: <A, C>(f: (a: A) => C) => <B>(data: These<A, B>) => These<C, B>;
88
+ /**
89
+ * Transforms the second value, leaving the first unchanged.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * pipe(These.second("warn"), These.mapSecond(e => e.toUpperCase())); // Second("WARN")
94
+ * pipe(These.both(5, "warn"), These.mapSecond(e => e.toUpperCase())); // Both(5, "WARN")
95
+ * ```
96
+ */
97
+ const mapSecond: <B, D>(f: (b: B) => D) => <A>(data: These<A, B>) => These<A, D>;
98
+ /**
99
+ * Transforms both the first and second values independently.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * pipe(
104
+ * These.both(5, "warn"),
105
+ * These.mapBoth(n => n * 2, e => e.toUpperCase())
106
+ * ); // Both(10, "WARN")
107
+ * ```
108
+ */
109
+ const mapBoth: <A, C, B, D>(onFirst: (a: A) => C, onSecond: (b: B) => D) => (data: These<A, B>) => These<C, D>;
110
+ /**
111
+ * Chains These computations by passing the first value to f.
112
+ * Second propagates unchanged; First and Both apply f to the first value.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const double = (n: number): These<number, string> => These.first(n * 2);
117
+ *
118
+ * pipe(These.first(5), These.chainFirst(double)); // First(10)
119
+ * pipe(These.both(5, "warn"), These.chainFirst(double)); // First(10)
120
+ * pipe(These.second("warn"), These.chainFirst(double)); // Second("warn")
121
+ * ```
122
+ */
123
+ const chainFirst: <A, B, C>(f: (a: A) => These<C, B>) => (data: These<A, B>) => These<C, B>;
124
+ /**
125
+ * Chains These computations by passing the second value to f.
126
+ * First propagates unchanged; Second and Both apply f to the second value.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const shout = (s: string): These<number, string> => These.second(s.toUpperCase());
131
+ *
132
+ * pipe(These.second("warn"), These.chainSecond(shout)); // Second("WARN")
133
+ * pipe(These.both(5, "warn"), These.chainSecond(shout)); // Second("WARN")
134
+ * pipe(These.first(5), These.chainSecond(shout)); // First(5)
135
+ * ```
136
+ */
137
+ const chainSecond: <A, B, D>(f: (b: B) => These<A, D>) => (data: These<A, B>) => These<A, D>;
138
+ /**
139
+ * Extracts a value from a These by providing handlers for all three cases.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * pipe(
144
+ * these,
145
+ * These.fold(
146
+ * a => `First: ${a}`,
147
+ * b => `Second: ${b}`,
148
+ * (a, b) => `Both: ${a} / ${b}`
149
+ * )
150
+ * );
151
+ * ```
152
+ */
153
+ const fold: <A, B, C>(onFirst: (a: A) => C, onSecond: (b: B) => C, onBoth: (a: A, b: B) => C) => (data: These<A, B>) => C;
154
+ /**
155
+ * Pattern matches on a These, returning the result of the matching case.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * pipe(
160
+ * these,
161
+ * These.match({
162
+ * first: a => `First: ${a}`,
163
+ * second: b => `Second: ${b}`,
164
+ * both: (a, b) => `Both: ${a} / ${b}`
165
+ * })
166
+ * );
167
+ * ```
168
+ */
169
+ const match: <A, B, C>(cases: {
170
+ first: (a: A) => C;
171
+ second: (b: B) => C;
172
+ both: (a: A, b: B) => C;
173
+ }) => (data: These<A, B>) => C;
174
+ /**
175
+ * Returns the first value, or a default if the These has no first value.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * pipe(These.first(5), These.getFirstOrElse(0)); // 5
180
+ * pipe(These.both(5, "warn"), These.getFirstOrElse(0)); // 5
181
+ * pipe(These.second("warn"), These.getFirstOrElse(0)); // 0
182
+ * ```
183
+ */
184
+ const getFirstOrElse: <A>(defaultValue: A) => <B>(data: These<A, B>) => A;
185
+ /**
186
+ * Returns the second value, or a default if the These has no second value.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * pipe(These.second("warn"), These.getSecondOrElse("none")); // "warn"
191
+ * pipe(These.both(5, "warn"), These.getSecondOrElse("none")); // "warn"
192
+ * pipe(These.first(5), These.getSecondOrElse("none")); // "none"
193
+ * ```
194
+ */
195
+ const getSecondOrElse: <B>(defaultValue: B) => <A>(data: These<A, B>) => B;
196
+ /**
197
+ * Executes a side effect on the first value without changing the These.
198
+ * Useful for logging or debugging.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * pipe(These.first(5), These.tap(console.log)); // logs 5, returns First(5)
203
+ * ```
204
+ */
205
+ const tap: <A>(f: (a: A) => void) => <B>(data: These<A, B>) => These<A, B>;
206
+ /**
207
+ * Swaps the roles of first and second values.
208
+ * - First(a) → Second(a)
209
+ * - Second(b) → First(b)
210
+ * - Both(a, b) → Both(b, a)
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * These.swap(These.first(5)); // Second(5)
215
+ * These.swap(These.second("warn")); // First("warn")
216
+ * These.swap(These.both(5, "warn")); // Both("warn", 5)
217
+ * ```
218
+ */
219
+ const swap: <A, B>(data: These<A, B>) => These<B, A>;
220
+ }
221
+ //# sourceMappingURL=These.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"These.d.ts","sourceRoot":"","sources":["../../../src/src/Core/These.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC7D,MAA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AAC;IAE/C;;;;;;;;OAQG;IACI,MAAM,GAAG,GAAI,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAG9E,CAAC;IAEF;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAIxD,CAAC;CACH"}
@@ -0,0 +1,213 @@
1
+ import { NonEmptyList } from "../Types/NonEmptyList.js";
2
+ import { WithErrors, WithKind, WithValue } from "./InternalTypes.js";
3
+ /**
4
+ * Validation represents a value that is either valid with a success value,
5
+ * or invalid with accumulated errors.
6
+ * Unlike Result, Validation can accumulate multiple errors instead of short-circuiting.
7
+ *
8
+ * Use Validation when you need to collect all errors (e.g., form validation).
9
+ * Use Result when you want to fail fast on the first error.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const validateName = (name: string): Validation<string, string> =>
14
+ * name.length > 0 ? Validation.valid(name) : Validation.invalid("Name is required");
15
+ *
16
+ * const validateAge = (age: number): Validation<string, number> =>
17
+ * age >= 0 ? Validation.valid(age) : Validation.invalid("Age must be positive");
18
+ *
19
+ * // Accumulates all errors using ap
20
+ * pipe(
21
+ * Validation.valid((name: string) => (age: number) => ({ name, age })),
22
+ * Validation.ap(validateName("")),
23
+ * Validation.ap(validateAge(-1))
24
+ * );
25
+ * // Invalid(["Name is required", "Age must be positive"])
26
+ * ```
27
+ */
28
+ export type Validation<E, A> = Valid<A> | Invalid<E>;
29
+ export type Valid<A> = WithKind<"Valid"> & WithValue<A>;
30
+ export type Invalid<E> = WithKind<"Invalid"> & WithErrors<E>;
31
+ export declare namespace Validation {
32
+ /**
33
+ * Wraps a value in a valid Validation.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * Validation.valid(42); // Valid(42)
38
+ * ```
39
+ */
40
+ const valid: <E, A>(value: A) => Validation<E, A>;
41
+ /**
42
+ * Creates an invalid Validation from a single error.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * Validation.invalid("Invalid input");
47
+ * ```
48
+ */
49
+ const invalid: <E>(error: E) => Invalid<E>;
50
+ /**
51
+ * Creates an invalid Validation from multiple errors.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * Validation.invalidAll(["Invalid input"]);
56
+ * ```
57
+ */
58
+ const invalidAll: <E>(errors: NonEmptyList<E>) => Invalid<E>;
59
+ /**
60
+ * Type guard that checks if a Validation is valid.
61
+ */
62
+ const isValid: <E, A>(data: Validation<E, A>) => data is Valid<A>;
63
+ /**
64
+ * Type guard that checks if a Validation is invalid.
65
+ */
66
+ const isInvalid: <E, A>(data: Validation<E, A>) => data is Invalid<E>;
67
+ /**
68
+ * Transforms the success value inside a Validation.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * pipe(Validation.valid(5), Validation.map(n => n * 2)); // Valid(10)
73
+ * pipe(Validation.invalid("oops"), Validation.map(n => n * 2)); // Invalid(["oops"])
74
+ * ```
75
+ */
76
+ const map: <A, B>(f: (a: A) => B) => <E>(data: Validation<E, A>) => Validation<E, B>;
77
+ /**
78
+ * Chains Validation computations. If the first is Valid, passes the value to f.
79
+ * If the first is Invalid, propagates the errors.
80
+ *
81
+ * Note: chain short-circuits on first error. Use `ap` to accumulate errors.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const validatePositive = (n: number): Validation<string, number> =>
86
+ * n > 0 ? Validation.valid(n) : Validation.invalid("Must be positive");
87
+ *
88
+ * pipe(Validation.valid(5), Validation.chain(validatePositive)); // Valid(5)
89
+ * pipe(Validation.valid(-1), Validation.chain(validatePositive)); // Invalid(["Must be positive"])
90
+ * ```
91
+ */
92
+ const chain: <E, A, B>(f: (a: A) => Validation<E, B>) => (data: Validation<E, A>) => Validation<E, B>;
93
+ /**
94
+ * Applies a function wrapped in a Validation to a value wrapped in a Validation.
95
+ * Accumulates errors from both sides.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const add = (a: number) => (b: number) => a + b;
100
+ * pipe(
101
+ * Validation.valid(add),
102
+ * Validation.ap(Validation.valid(5)),
103
+ * Validation.ap(Validation.valid(3))
104
+ * ); // Valid(8)
105
+ *
106
+ * pipe(
107
+ * Validation.valid(add),
108
+ * Validation.ap(Validation.invalid<string, number>("bad a")),
109
+ * Validation.ap(Validation.invalid<string, number>("bad b"))
110
+ * ); // Invalid(["bad a", "bad b"])
111
+ * ```
112
+ */
113
+ const ap: <E, A>(arg: Validation<E, A>) => <B>(data: Validation<E, (a: A) => B>) => Validation<E, B>;
114
+ /**
115
+ * Extracts the value from a Validation by providing handlers for both cases.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * pipe(
120
+ * Validation.valid(42),
121
+ * Validation.fold(
122
+ * errors => `Errors: ${errors.join(", ")}`,
123
+ * value => `Value: ${value}`
124
+ * )
125
+ * );
126
+ * ```
127
+ */
128
+ const fold: <E, A, B>(onInvalid: (errors: NonEmptyList<E>) => B, onValid: (a: A) => B) => (data: Validation<E, A>) => B;
129
+ /**
130
+ * Pattern matches on a Validation, returning the result of the matching case.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * pipe(
135
+ * validation,
136
+ * Validation.match({
137
+ * valid: value => `Got ${value}`,
138
+ * invalid: errors => `Failed: ${errors.join(", ")}`
139
+ * })
140
+ * );
141
+ * ```
142
+ */
143
+ const match: <E, A, B>(cases: {
144
+ valid: (a: A) => B;
145
+ invalid: (errors: NonEmptyList<E>) => B;
146
+ }) => (data: Validation<E, A>) => B;
147
+ /**
148
+ * Returns the success value or a default value if the Validation is invalid.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * pipe(Validation.valid(5), Validation.getOrElse(0)); // 5
153
+ * pipe(Validation.invalid("oops"), Validation.getOrElse(0)); // 0
154
+ * ```
155
+ */
156
+ const getOrElse: <E, A>(defaultValue: A) => (data: Validation<E, A>) => A;
157
+ /**
158
+ * Executes a side effect on the success value without changing the Validation.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * pipe(
163
+ * Validation.valid(5),
164
+ * Validation.tap(n => console.log("Value:", n)),
165
+ * Validation.map(n => n * 2)
166
+ * );
167
+ * ```
168
+ */
169
+ const tap: <E, A>(f: (a: A) => void) => (data: Validation<E, A>) => Validation<E, A>;
170
+ /**
171
+ * Recovers from an Invalid state by providing a fallback Validation.
172
+ */
173
+ const recover: <E, A>(fallback: () => Validation<E, A>) => (data: Validation<E, A>) => Validation<E, A>;
174
+ /**
175
+ * Recovers from an Invalid state unless the errors contain any of the blocked errors.
176
+ */
177
+ const recoverUnless: <E, A>(blockedErrors: readonly E[], fallback: () => Validation<E, A>) => (data: Validation<E, A>) => Validation<E, A>;
178
+ /**
179
+ * Combines two Validation instances, accumulating errors from both.
180
+ * If both are Valid, returns the second valid value.
181
+ * If either is Invalid, combines their errors into a single Invalid.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * Validation.combine(
186
+ * Validation.invalid("Error 1"),
187
+ * Validation.invalid("Error 2")
188
+ * ); // Invalid(["Error 1", "Error 2"])
189
+ *
190
+ * Validation.combine(
191
+ * Validation.valid("a"),
192
+ * Validation.valid("b")
193
+ * ); // Valid("b")
194
+ * ```
195
+ */
196
+ const combine: <E, A>(first: Validation<E, A>, second: Validation<E, A>) => Validation<E, A>;
197
+ /**
198
+ * Combines multiple Validation instances, accumulating all errors.
199
+ * If all are Valid, returns the last valid value.
200
+ * Returns undefined for an empty array.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * Validation.combineAll([
205
+ * validateName(name),
206
+ * validateEmail(email),
207
+ * validateAge(age)
208
+ * ]);
209
+ * ```
210
+ */
211
+ const combineAll: <E, A>(data: Validation<E, A>[]) => Validation<E, A> | undefined;
212
+ }
213
+ //# sourceMappingURL=Validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validation.d.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,CAAC,EAAE,CAAC,CAAC,GAAG,SACoD,CAAC;CAC5E"}
@@ -0,0 +1,16 @@
1
+ export * from "./Arr.js";
2
+ export * from "./Deferred.js";
3
+ export * from "./Lens.js";
4
+ export * from "./Option.js";
5
+ export * from "./Reader.js";
6
+ export * from "./Optional.js";
7
+ export * from "./Rec.js";
8
+ export * from "./RemoteData.js";
9
+ export * from "./Result.js";
10
+ export * from "./Task.js";
11
+ export * from "./TaskOption.js";
12
+ export * from "./TaskResult.js";
13
+ export * from "./TaskValidation.js";
14
+ export * from "./These.js";
15
+ export * from "./Validation.js";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,52 @@
1
+ declare const _brand: unique symbol;
2
+ /**
3
+ * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
4
+ * Prevents accidentally mixing up values that share the same underlying type.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * type UserId = Brand<"UserId", string>;
9
+ * type ProductId = Brand<"ProductId", string>;
10
+ *
11
+ * const toUserId = Brand.wrap<"UserId", string>();
12
+ * const toProductId = Brand.wrap<"ProductId", string>();
13
+ *
14
+ * const userId: UserId = toUserId("user-123");
15
+ * const productId: ProductId = toProductId("prod-456");
16
+ *
17
+ * // Type error: ProductId is not assignable to UserId
18
+ * // const wrong: UserId = productId;
19
+ * ```
20
+ */
21
+ export type Brand<K extends string, T> = T & {
22
+ readonly [_brand]: K;
23
+ };
24
+ export declare namespace Brand {
25
+ /**
26
+ * Returns a constructor that wraps a value of type T in brand K.
27
+ * The resulting function performs an unchecked cast — only use when the raw
28
+ * value is known to satisfy the brand's invariants.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * type PositiveNumber = Brand<"PositiveNumber", number>;
33
+ * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
34
+ *
35
+ * const n: PositiveNumber = toPositiveNumber(42);
36
+ * ```
37
+ */
38
+ const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
+ /**
40
+ * Strips the brand and returns the underlying value.
41
+ * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const userId: UserId = toUserId("user-123");
46
+ * const raw: string = Brand.unwrap(userId); // "user-123"
47
+ * ```
48
+ */
49
+ const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=Brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../../src/src/Types/Brand.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEtE,yBAAiB,KAAK,CAAC;IACrB;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,QAAQ,OAAO,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAyB,CAAC;IAE/F;;;;;;;;;OASG;IACI,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAiB,CAAC;CACtF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A list that is guaranteed to have at least one element.
3
+ * Useful for ensuring functions receive non-empty input and for
4
+ * accumulating errors in Validation.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const errors: NonEmptyList<string> = ["First error", "Second error"];
9
+ *
10
+ * // TypeScript ensures at least one element:
11
+ * const invalid: NonEmptyList<string> = []; // Error!
12
+ * ```
13
+ */
14
+ export type NonEmptyList<A> = readonly [A, ...A[]];
15
+ /**
16
+ * Type guard that checks if an array is non-empty.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const items: string[] = getItems();
21
+ *
22
+ * if (isNonEmptyList(items)) {
23
+ * // TypeScript knows items has at least one element
24
+ * const first = items[0]; // string, not string | undefined
25
+ * }
26
+ * ```
27
+ */
28
+ export declare const isNonEmptyList: <A>(list: readonly A[]) => list is NonEmptyList<A>;
29
+ //# sourceMappingURL=NonEmptyList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonEmptyList.d.ts","sourceRoot":"","sources":["../../../src/src/Types/NonEmptyList.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,MAAM,SAAS,CAAC,EAAE,KACjB,IAAI,IAAI,YAAY,CAAC,CAAC,CAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./Brand.js";
2
+ export * from "./NonEmptyList.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}