@nlozgachev/pipelined 0.13.0 → 0.14.0

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.
@@ -0,0 +1,514 @@
1
+ import {
2
+ Deferred,
3
+ Option,
4
+ Result,
5
+ Task
6
+ } from "./chunk-QPTGO5AS.mjs";
7
+
8
+ // src/Core/Lens.ts
9
+ var Lens;
10
+ ((Lens2) => {
11
+ Lens2.make = (get2, set2) => ({ get: get2, set: set2 });
12
+ Lens2.prop = () => (key) => (0, Lens2.make)(
13
+ (s) => s[key],
14
+ (a) => (s) => ({ ...s, [key]: a })
15
+ );
16
+ Lens2.get = (lens) => (s) => lens.get(s);
17
+ Lens2.set = (lens) => (a) => (s) => lens.set(a)(s);
18
+ Lens2.modify = (lens) => (f) => (s) => lens.set(f(lens.get(s)))(s);
19
+ Lens2.andThen = (inner) => (outer) => (0, Lens2.make)(
20
+ (s) => inner.get(outer.get(s)),
21
+ (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s)
22
+ );
23
+ Lens2.andThenOptional = (inner) => (outer) => ({
24
+ get: (s) => inner.get(outer.get(s)),
25
+ set: (b) => (s) => outer.set(inner.set(b)(outer.get(s)))(s)
26
+ });
27
+ Lens2.toOptional = (lens) => ({
28
+ get: (s) => ({ kind: "Some", value: lens.get(s) }),
29
+ set: lens.set
30
+ });
31
+ })(Lens || (Lens = {}));
32
+
33
+ // src/Core/Logged.ts
34
+ var Logged;
35
+ ((Logged2) => {
36
+ Logged2.make = (value) => ({ value, log: [] });
37
+ Logged2.tell = (entry) => ({ value: void 0, log: [entry] });
38
+ Logged2.map = (f) => (data) => ({
39
+ value: f(data.value),
40
+ log: data.log
41
+ });
42
+ Logged2.chain = (f) => (data) => {
43
+ const next = f(data.value);
44
+ return { value: next.value, log: [...data.log, ...next.log] };
45
+ };
46
+ Logged2.ap = (arg) => (data) => ({
47
+ value: data.value(arg.value),
48
+ log: [...data.log, ...arg.log]
49
+ });
50
+ Logged2.tap = (f) => (data) => {
51
+ f(data.value);
52
+ return data;
53
+ };
54
+ Logged2.run = (data) => [data.value, data.log];
55
+ })(Logged || (Logged = {}));
56
+
57
+ // src/Core/Optional.ts
58
+ var Optional;
59
+ ((Optional2) => {
60
+ Optional2.make = (get2, set2) => ({ get: get2, set: set2 });
61
+ Optional2.prop = () => (key) => (0, Optional2.make)(
62
+ (s) => {
63
+ const val = s[key];
64
+ return val !== null && val !== void 0 ? Option.some(val) : Option.none();
65
+ },
66
+ (a) => (s) => ({ ...s, [key]: a })
67
+ );
68
+ Optional2.index = (i) => (0, Optional2.make)(
69
+ (arr) => i >= 0 && i < arr.length ? Option.some(arr[i]) : Option.none(),
70
+ (a) => (arr) => {
71
+ if (i < 0 || i >= arr.length) return arr;
72
+ const copy = [...arr];
73
+ copy[i] = a;
74
+ return copy;
75
+ }
76
+ );
77
+ Optional2.get = (opt) => (s) => opt.get(s);
78
+ Optional2.set = (opt) => (a) => (s) => opt.set(a)(s);
79
+ Optional2.modify = (opt) => (f) => (s) => {
80
+ const val = opt.get(s);
81
+ return val.kind === "None" ? s : opt.set(f(val.value))(s);
82
+ };
83
+ Optional2.getOrElse = (opt) => (defaultValue) => (s) => {
84
+ const val = opt.get(s);
85
+ return val.kind === "Some" ? val.value : defaultValue();
86
+ };
87
+ Optional2.fold = (opt) => (onNone, onSome) => (s) => {
88
+ const val = opt.get(s);
89
+ return val.kind === "Some" ? onSome(val.value) : onNone();
90
+ };
91
+ Optional2.match = (opt) => (cases) => (s) => {
92
+ const val = opt.get(s);
93
+ return val.kind === "Some" ? cases.some(val.value) : cases.none();
94
+ };
95
+ Optional2.andThen = (inner) => (outer) => (0, Optional2.make)(
96
+ (s) => {
97
+ const mid = outer.get(s);
98
+ return mid.kind === "None" ? Option.none() : inner.get(mid.value);
99
+ },
100
+ (b) => (s) => {
101
+ const mid = outer.get(s);
102
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
103
+ }
104
+ );
105
+ Optional2.andThenLens = (inner) => (outer) => (0, Optional2.make)(
106
+ (s) => {
107
+ const mid = outer.get(s);
108
+ return mid.kind === "None" ? Option.none() : Option.some(inner.get(mid.value));
109
+ },
110
+ (b) => (s) => {
111
+ const mid = outer.get(s);
112
+ return mid.kind === "None" ? s : outer.set(inner.set(b)(mid.value))(s);
113
+ }
114
+ );
115
+ })(Optional || (Optional = {}));
116
+
117
+ // src/Core/Predicate.ts
118
+ var Predicate;
119
+ ((Predicate2) => {
120
+ Predicate2.not = (p) => (a) => !p(a);
121
+ Predicate2.and = (second) => (first) => (a) => first(a) && second(a);
122
+ Predicate2.or = (second) => (first) => (a) => first(a) || second(a);
123
+ Predicate2.using = (f) => (p) => (b) => p(f(b));
124
+ Predicate2.all = (predicates) => (a) => predicates.every((p) => p(a));
125
+ Predicate2.any = (predicates) => (a) => predicates.some((p) => p(a));
126
+ Predicate2.fromRefinement = (r) => r;
127
+ })(Predicate || (Predicate = {}));
128
+
129
+ // src/Core/Reader.ts
130
+ var Reader;
131
+ ((Reader2) => {
132
+ Reader2.resolve = (value) => (_env) => value;
133
+ Reader2.ask = () => (env) => env;
134
+ Reader2.asks = (f) => (env) => f(env);
135
+ Reader2.map = (f) => (data) => (env) => f(data(env));
136
+ Reader2.chain = (f) => (data) => (env) => f(data(env))(env);
137
+ Reader2.ap = (arg) => (data) => (env) => data(env)(arg(env));
138
+ Reader2.tap = (f) => (data) => (env) => {
139
+ const a = data(env);
140
+ f(a);
141
+ return a;
142
+ };
143
+ Reader2.local = (f) => (data) => (env) => data(f(env));
144
+ Reader2.run = (env) => (data) => data(env);
145
+ })(Reader || (Reader = {}));
146
+
147
+ // src/Core/Refinement.ts
148
+ var Refinement;
149
+ ((Refinement2) => {
150
+ Refinement2.make = (f) => f;
151
+ Refinement2.compose = (bc) => (ab) => (a) => ab(a) && bc(a);
152
+ Refinement2.and = (second) => (first) => (a) => first(a) && second(a);
153
+ Refinement2.or = (second) => (first) => (a) => first(a) || second(a);
154
+ Refinement2.toFilter = (r) => (a) => r(a) ? Option.some(a) : Option.none();
155
+ Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.err(onFail(a));
156
+ })(Refinement || (Refinement = {}));
157
+
158
+ // src/Core/RemoteData.ts
159
+ var _notAsked = { kind: "NotAsked" };
160
+ var _loading = { kind: "Loading" };
161
+ var RemoteData;
162
+ ((RemoteData2) => {
163
+ RemoteData2.notAsked = () => _notAsked;
164
+ RemoteData2.loading = () => _loading;
165
+ RemoteData2.failure = (error) => ({
166
+ kind: "Failure",
167
+ error
168
+ });
169
+ RemoteData2.success = (value) => ({
170
+ kind: "Success",
171
+ value
172
+ });
173
+ RemoteData2.isNotAsked = (data) => data.kind === "NotAsked";
174
+ RemoteData2.isLoading = (data) => data.kind === "Loading";
175
+ RemoteData2.isFailure = (data) => data.kind === "Failure";
176
+ RemoteData2.isSuccess = (data) => data.kind === "Success";
177
+ RemoteData2.map = (f) => (data) => (0, RemoteData2.isSuccess)(data) ? (0, RemoteData2.success)(f(data.value)) : data;
178
+ RemoteData2.mapError = (f) => (data) => (0, RemoteData2.isFailure)(data) ? (0, RemoteData2.failure)(f(data.error)) : data;
179
+ RemoteData2.chain = (f) => (data) => (0, RemoteData2.isSuccess)(data) ? f(data.value) : data;
180
+ RemoteData2.ap = (arg) => (data) => {
181
+ if ((0, RemoteData2.isSuccess)(data) && (0, RemoteData2.isSuccess)(arg)) {
182
+ return (0, RemoteData2.success)(data.value(arg.value));
183
+ }
184
+ if ((0, RemoteData2.isFailure)(data)) return data;
185
+ if ((0, RemoteData2.isFailure)(arg)) return arg;
186
+ if ((0, RemoteData2.isLoading)(data) || (0, RemoteData2.isLoading)(arg)) return (0, RemoteData2.loading)();
187
+ return (0, RemoteData2.notAsked)();
188
+ };
189
+ RemoteData2.fold = (onNotAsked, onLoading, onFailure, onSuccess) => (data) => {
190
+ switch (data.kind) {
191
+ case "NotAsked":
192
+ return onNotAsked();
193
+ case "Loading":
194
+ return onLoading();
195
+ case "Failure":
196
+ return onFailure(data.error);
197
+ case "Success":
198
+ return onSuccess(data.value);
199
+ }
200
+ };
201
+ RemoteData2.match = (cases) => (data) => {
202
+ switch (data.kind) {
203
+ case "NotAsked":
204
+ return cases.notAsked();
205
+ case "Loading":
206
+ return cases.loading();
207
+ case "Failure":
208
+ return cases.failure(data.error);
209
+ case "Success":
210
+ return cases.success(data.value);
211
+ }
212
+ };
213
+ RemoteData2.getOrElse = (defaultValue) => (data) => (0, RemoteData2.isSuccess)(data) ? data.value : defaultValue();
214
+ RemoteData2.tap = (f) => (data) => {
215
+ if ((0, RemoteData2.isSuccess)(data)) f(data.value);
216
+ return data;
217
+ };
218
+ RemoteData2.recover = (fallback) => (data) => (0, RemoteData2.isFailure)(data) ? fallback(data.error) : data;
219
+ RemoteData2.toOption = (data) => (0, RemoteData2.isSuccess)(data) ? Option.some(data.value) : Option.none();
220
+ RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
221
+ })(RemoteData || (RemoteData = {}));
222
+
223
+ // src/Core/State.ts
224
+ var State;
225
+ ((State2) => {
226
+ State2.resolve = (value) => (s) => [value, s];
227
+ State2.get = () => (s) => [s, s];
228
+ State2.gets = (f) => (s) => [f(s), s];
229
+ State2.put = (newState) => (_s) => [void 0, newState];
230
+ State2.modify = (f) => (s) => [void 0, f(s)];
231
+ State2.map = (f) => (st) => (s) => {
232
+ const [a, s1] = st(s);
233
+ return [f(a), s1];
234
+ };
235
+ State2.chain = (f) => (st) => (s) => {
236
+ const [a, s1] = st(s);
237
+ return f(a)(s1);
238
+ };
239
+ State2.ap = (arg) => (fn) => (s) => {
240
+ const [f, s1] = fn(s);
241
+ const [a, s2] = arg(s1);
242
+ return [f(a), s2];
243
+ };
244
+ State2.tap = (f) => (st) => (s) => {
245
+ const [a, s1] = st(s);
246
+ f(a);
247
+ return [a, s1];
248
+ };
249
+ State2.run = (initialState) => (st) => st(initialState);
250
+ State2.evaluate = (initialState) => (st) => st(initialState)[0];
251
+ State2.execute = (initialState) => (st) => st(initialState)[1];
252
+ })(State || (State = {}));
253
+
254
+ // src/Core/TaskOption.ts
255
+ var TaskOption;
256
+ ((TaskOption2) => {
257
+ TaskOption2.some = (value) => Task.resolve(Option.some(value));
258
+ TaskOption2.none = () => Task.resolve(Option.none());
259
+ TaskOption2.fromOption = (option) => Task.resolve(option);
260
+ TaskOption2.fromTask = (task) => Task.map(Option.some)(task);
261
+ TaskOption2.tryCatch = (f) => Task.from(
262
+ () => f().then(Option.some).catch(() => Option.none())
263
+ );
264
+ TaskOption2.map = (f) => (data) => Task.map(Option.map(f))(data);
265
+ TaskOption2.chain = (f) => (data) => Task.chain((option) => Option.isSome(option) ? f(option.value) : Task.resolve(Option.none()))(data);
266
+ TaskOption2.ap = (arg) => (data) => Task.from(
267
+ () => Promise.all([
268
+ Deferred.toPromise(data()),
269
+ Deferred.toPromise(arg())
270
+ ]).then(([of_, oa]) => Option.ap(oa)(of_))
271
+ );
272
+ TaskOption2.fold = (onNone, onSome) => (data) => Task.map(Option.fold(onNone, onSome))(data);
273
+ TaskOption2.match = (cases) => (data) => Task.map(Option.match(cases))(data);
274
+ TaskOption2.getOrElse = (defaultValue) => (data) => Task.map(Option.getOrElse(defaultValue))(data);
275
+ TaskOption2.tap = (f) => (data) => Task.map(Option.tap(f))(data);
276
+ TaskOption2.filter = (predicate) => (data) => Task.map(Option.filter(predicate))(data);
277
+ TaskOption2.toTaskResult = (onNone) => (data) => Task.map(Option.toResult(onNone))(data);
278
+ })(TaskOption || (TaskOption = {}));
279
+
280
+ // src/Core/TaskResult.ts
281
+ var TaskResult;
282
+ ((TaskResult2) => {
283
+ TaskResult2.ok = (value) => Task.resolve(Result.ok(value));
284
+ TaskResult2.err = (error) => Task.resolve(Result.err(error));
285
+ TaskResult2.tryCatch = (f, onError) => Task.from(
286
+ () => f().then(Result.ok).catch((e) => Result.err(onError(e)))
287
+ );
288
+ TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
289
+ TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
290
+ TaskResult2.chain = (f) => (data) => Task.chain((result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.err(result.error)))(
291
+ data
292
+ );
293
+ TaskResult2.fold = (onErr, onOk) => (data) => Task.map(Result.fold(onErr, onOk))(data);
294
+ TaskResult2.match = (cases) => (data) => Task.map(Result.match(cases))(data);
295
+ TaskResult2.recover = (fallback) => (data) => Task.chain(
296
+ (result) => Result.isErr(result) ? fallback(result.error) : Task.resolve(result)
297
+ )(data);
298
+ TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
299
+ TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
300
+ TaskResult2.retry = (options) => (data) => Task.from(() => {
301
+ const { attempts, backoff, when: shouldRetry } = options;
302
+ const getDelay = (n) => backoff === void 0 ? 0 : typeof backoff === "function" ? backoff(n) : backoff;
303
+ const run = (left) => Deferred.toPromise(data()).then((result) => {
304
+ if (Result.isOk(result)) return result;
305
+ if (left <= 1) return result;
306
+ if (shouldRetry !== void 0 && !shouldRetry(result.error)) {
307
+ return result;
308
+ }
309
+ const ms = getDelay(attempts - left + 1);
310
+ return (ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve()).then(() => run(left - 1));
311
+ });
312
+ return run(attempts);
313
+ });
314
+ TaskResult2.timeout = (ms, onTimeout) => (data) => Task.from(() => {
315
+ let timerId;
316
+ return Promise.race([
317
+ Deferred.toPromise(data()).then((result) => {
318
+ clearTimeout(timerId);
319
+ return result;
320
+ }),
321
+ new Promise((resolve) => {
322
+ timerId = setTimeout(() => resolve(Result.err(onTimeout())), ms);
323
+ })
324
+ ]);
325
+ });
326
+ })(TaskResult || (TaskResult = {}));
327
+
328
+ // src/Core/Validation.ts
329
+ var Validation;
330
+ ((Validation2) => {
331
+ Validation2.valid = (value) => ({
332
+ kind: "Valid",
333
+ value
334
+ });
335
+ Validation2.invalid = (error) => ({
336
+ kind: "Invalid",
337
+ errors: [error]
338
+ });
339
+ Validation2.invalidAll = (errors) => ({
340
+ kind: "Invalid",
341
+ errors
342
+ });
343
+ Validation2.isValid = (data) => data.kind === "Valid";
344
+ Validation2.isInvalid = (data) => data.kind === "Invalid";
345
+ Validation2.map = (f) => (data) => (0, Validation2.isValid)(data) ? (0, Validation2.valid)(f(data.value)) : data;
346
+ Validation2.ap = (arg) => (data) => {
347
+ if ((0, Validation2.isValid)(data) && (0, Validation2.isValid)(arg)) return (0, Validation2.valid)(data.value(arg.value));
348
+ const errors = [
349
+ ...(0, Validation2.isInvalid)(data) ? data.errors : [],
350
+ ...(0, Validation2.isInvalid)(arg) ? arg.errors : []
351
+ ];
352
+ return (0, Validation2.invalidAll)(errors);
353
+ };
354
+ Validation2.fold = (onInvalid, onValid) => (data) => (0, Validation2.isValid)(data) ? onValid(data.value) : onInvalid(data.errors);
355
+ Validation2.match = (cases) => (data) => (0, Validation2.isValid)(data) ? cases.valid(data.value) : cases.invalid(data.errors);
356
+ Validation2.getOrElse = (defaultValue) => (data) => (0, Validation2.isValid)(data) ? data.value : defaultValue();
357
+ Validation2.tap = (f) => (data) => {
358
+ if ((0, Validation2.isValid)(data)) f(data.value);
359
+ return data;
360
+ };
361
+ Validation2.recover = (fallback) => (data) => (0, Validation2.isValid)(data) ? data : fallback(data.errors);
362
+ Validation2.recoverUnless = (blockedErrors, fallback) => (data) => (0, Validation2.isInvalid)(data) && !data.errors.some((err) => blockedErrors.includes(err)) ? fallback() : data;
363
+ Validation2.product = (first, second) => {
364
+ if ((0, Validation2.isValid)(first) && (0, Validation2.isValid)(second)) return (0, Validation2.valid)([first.value, second.value]);
365
+ const errors = [
366
+ ...(0, Validation2.isInvalid)(first) ? first.errors : [],
367
+ ...(0, Validation2.isInvalid)(second) ? second.errors : []
368
+ ];
369
+ return (0, Validation2.invalidAll)(errors);
370
+ };
371
+ Validation2.productAll = (data) => {
372
+ const values = [];
373
+ const errors = [];
374
+ for (const v of data) {
375
+ if ((0, Validation2.isValid)(v)) values.push(v.value);
376
+ else errors.push(...v.errors);
377
+ }
378
+ return errors.length > 0 ? (0, Validation2.invalidAll)(errors) : (0, Validation2.valid)(values);
379
+ };
380
+ })(Validation || (Validation = {}));
381
+
382
+ // src/Core/TaskValidation.ts
383
+ var TaskValidation;
384
+ ((TaskValidation2) => {
385
+ TaskValidation2.valid = (value) => Task.resolve(Validation.valid(value));
386
+ TaskValidation2.invalid = (error) => Task.resolve(Validation.invalid(error));
387
+ TaskValidation2.invalidAll = (errors) => Task.resolve(Validation.invalidAll(errors));
388
+ TaskValidation2.fromValidation = (validation) => Task.resolve(validation);
389
+ TaskValidation2.tryCatch = (f, onError) => Task.from(
390
+ () => f().then(Validation.valid).catch((e) => Validation.invalid(onError(e)))
391
+ );
392
+ TaskValidation2.map = (f) => (data) => Task.map(Validation.map(f))(data);
393
+ TaskValidation2.ap = (arg) => (data) => Task.from(
394
+ () => Promise.all([
395
+ Deferred.toPromise(data()),
396
+ Deferred.toPromise(arg())
397
+ ]).then(([vf, va]) => Validation.ap(va)(vf))
398
+ );
399
+ TaskValidation2.fold = (onInvalid, onValid) => (data) => Task.map(Validation.fold(onInvalid, onValid))(data);
400
+ TaskValidation2.match = (cases) => (data) => Task.map(Validation.match(cases))(data);
401
+ TaskValidation2.getOrElse = (defaultValue) => (data) => Task.map(Validation.getOrElse(defaultValue))(data);
402
+ TaskValidation2.tap = (f) => (data) => Task.map(Validation.tap(f))(data);
403
+ TaskValidation2.recover = (fallback) => (data) => Task.chain(
404
+ (validation) => Validation.isValid(validation) ? Task.resolve(validation) : fallback(validation.errors)
405
+ )(data);
406
+ TaskValidation2.product = (first, second) => Task.from(
407
+ () => Promise.all([
408
+ Deferred.toPromise(first()),
409
+ Deferred.toPromise(second())
410
+ ]).then(([va, vb]) => Validation.product(va, vb))
411
+ );
412
+ TaskValidation2.productAll = (data) => Task.from(
413
+ () => Promise.all(data.map((t) => Deferred.toPromise(t()))).then((results) => Validation.productAll(results))
414
+ );
415
+ })(TaskValidation || (TaskValidation = {}));
416
+
417
+ // src/Core/These.ts
418
+ var These;
419
+ ((These2) => {
420
+ These2.first = (value) => ({ kind: "First", first: value });
421
+ These2.second = (value) => ({ kind: "Second", second: value });
422
+ These2.both = (first2, second2) => ({
423
+ kind: "Both",
424
+ first: first2,
425
+ second: second2
426
+ });
427
+ These2.isFirst = (data) => data.kind === "First";
428
+ These2.isSecond = (data) => data.kind === "Second";
429
+ These2.isBoth = (data) => data.kind === "Both";
430
+ These2.hasFirst = (data) => data.kind === "First" || data.kind === "Both";
431
+ These2.hasSecond = (data) => data.kind === "Second" || data.kind === "Both";
432
+ These2.mapFirst = (f) => (data) => {
433
+ if ((0, These2.isSecond)(data)) return data;
434
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(f(data.first));
435
+ return (0, These2.both)(f(data.first), data.second);
436
+ };
437
+ These2.mapSecond = (f) => (data) => {
438
+ if ((0, These2.isFirst)(data)) return data;
439
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(f(data.second));
440
+ return (0, These2.both)(data.first, f(data.second));
441
+ };
442
+ These2.mapBoth = (onFirst, onSecond) => (data) => {
443
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(onSecond(data.second));
444
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(onFirst(data.first));
445
+ return (0, These2.both)(onFirst(data.first), onSecond(data.second));
446
+ };
447
+ These2.chainFirst = (f) => (data) => {
448
+ if ((0, These2.isSecond)(data)) return data;
449
+ return f(data.first);
450
+ };
451
+ These2.chainSecond = (f) => (data) => {
452
+ if ((0, These2.isFirst)(data)) return data;
453
+ return f(data.second);
454
+ };
455
+ These2.fold = (onFirst, onSecond, onBoth) => (data) => {
456
+ if ((0, These2.isSecond)(data)) return onSecond(data.second);
457
+ if ((0, These2.isFirst)(data)) return onFirst(data.first);
458
+ return onBoth(data.first, data.second);
459
+ };
460
+ These2.match = (cases) => (data) => {
461
+ if ((0, These2.isSecond)(data)) return cases.second(data.second);
462
+ if ((0, These2.isFirst)(data)) return cases.first(data.first);
463
+ return cases.both(data.first, data.second);
464
+ };
465
+ These2.getFirstOrElse = (defaultValue) => (data) => (0, These2.hasFirst)(data) ? data.first : defaultValue();
466
+ These2.getSecondOrElse = (defaultValue) => (data) => (0, These2.hasSecond)(data) ? data.second : defaultValue();
467
+ These2.tap = (f) => (data) => {
468
+ if ((0, These2.hasFirst)(data)) f(data.first);
469
+ return data;
470
+ };
471
+ These2.swap = (data) => {
472
+ if ((0, These2.isSecond)(data)) return (0, These2.first)(data.second);
473
+ if ((0, These2.isFirst)(data)) return (0, These2.second)(data.first);
474
+ return (0, These2.both)(data.second, data.first);
475
+ };
476
+ })(These || (These = {}));
477
+
478
+ // src/Core/Tuple.ts
479
+ var Tuple;
480
+ ((Tuple2) => {
481
+ Tuple2.make = (first2, second2) => [first2, second2];
482
+ Tuple2.first = (tuple) => tuple[0];
483
+ Tuple2.second = (tuple) => tuple[1];
484
+ Tuple2.mapFirst = (f) => (tuple) => [f(tuple[0]), tuple[1]];
485
+ Tuple2.mapSecond = (f) => (tuple) => [tuple[0], f(tuple[1])];
486
+ Tuple2.mapBoth = (onFirst, onSecond) => (tuple) => [
487
+ onFirst(tuple[0]),
488
+ onSecond(tuple[1])
489
+ ];
490
+ Tuple2.fold = (f) => (tuple) => f(tuple[0], tuple[1]);
491
+ Tuple2.swap = (tuple) => [tuple[1], tuple[0]];
492
+ Tuple2.toArray = (tuple) => [...tuple];
493
+ Tuple2.tap = (f) => (tuple) => {
494
+ f(tuple[0], tuple[1]);
495
+ return tuple;
496
+ };
497
+ })(Tuple || (Tuple = {}));
498
+
499
+ export {
500
+ Lens,
501
+ Logged,
502
+ Optional,
503
+ Predicate,
504
+ Reader,
505
+ Refinement,
506
+ RemoteData,
507
+ State,
508
+ TaskOption,
509
+ TaskResult,
510
+ Validation,
511
+ TaskValidation,
512
+ These,
513
+ Tuple
514
+ };
@@ -1,109 +1,32 @@
1
- // src/Composition/compose.ts
2
- function compose(...fns) {
3
- return (arg) => fns.reduceRight((acc, fn) => fn(acc), arg);
4
- }
5
-
6
- // src/Composition/converge.ts
7
- function converge(f, transformers) {
8
- return (a) => f(...transformers.map((t) => t(a)));
9
- }
10
-
11
- // src/Composition/curry.ts
12
- var curry = (f) => (a) => (b) => f(a, b);
13
- var curry3 = (f) => (a) => (b) => (c) => f(a, b, c);
14
- var curry4 = (f) => (a) => (b) => (c) => (d) => f(a, b, c, d);
15
-
16
- // src/Composition/flip.ts
17
- var flip = (f) => (b) => (a) => f(a)(b);
18
-
19
- // src/Composition/flow.ts
20
- function flow(...fns) {
21
- return (...args) => {
22
- if (fns.length === 0) return args[0];
23
- const [first, ...rest] = fns;
24
- return rest.reduce((acc, fn) => fn(acc), first(...args));
25
- };
26
- }
27
-
28
- // src/Composition/fn.ts
29
- var identity = (a) => a;
30
- var constant = (a) => () => a;
31
- var constTrue = () => true;
32
- var constFalse = () => false;
33
- var constNull = () => null;
34
- var constUndefined = () => void 0;
35
- var constVoid = () => {
36
- };
37
- var and = (p1, p2) => (...args) => p1(...args) && p2(...args);
38
- var or = (p1, p2) => (...args) => p1(...args) || p2(...args);
39
- var once = (f) => {
40
- let called = false;
41
- let result;
42
- return () => {
43
- if (!called) {
44
- result = f();
45
- called = true;
46
- }
47
- return result;
48
- };
49
- };
50
-
51
- // src/Composition/juxt.ts
52
- function juxt(fns) {
53
- return (a) => fns.map((f) => f(a));
54
- }
55
-
56
- // src/Composition/memoize.ts
57
- var memoize = (f, keyFn = (a) => a) => {
58
- const cache = /* @__PURE__ */ new Map();
59
- return (a) => {
60
- const key = keyFn(a);
61
- if (cache.has(key)) {
62
- return cache.get(key);
63
- }
64
- const result = f(a);
65
- cache.set(key, result);
66
- return result;
67
- };
68
- };
69
- var memoizeWeak = (f) => {
70
- const cache = /* @__PURE__ */ new WeakMap();
71
- return (a) => {
72
- if (cache.has(a)) {
73
- return cache.get(a);
74
- }
75
- const result = f(a);
76
- cache.set(a, result);
77
- return result;
78
- };
79
- };
80
-
81
- // src/Composition/not.ts
82
- var not = (predicate) => (...args) => !predicate(...args);
83
-
84
- // src/Composition/on.ts
85
- var on = (f, g) => (a, b) => f(g(a), g(b));
86
-
87
- // src/Composition/pipe.ts
88
- function pipe(a, ...fns) {
89
- return fns.reduce((acc, fn) => fn(acc), a);
90
- }
91
-
92
- // src/Composition/tap.ts
93
- var tap = (f) => (a) => {
94
- f(a);
95
- return a;
96
- };
97
-
98
- // src/Composition/uncurry.ts
99
- function uncurry(f) {
100
- return (...args) => {
101
- const inner = f(...args.slice(0, f.length));
102
- return inner.length === 0 ? inner() : inner(...args.slice(f.length));
103
- };
104
- }
105
- var uncurry3 = (f) => (a, b, c) => f(a)(b)(c);
106
- var uncurry4 = (f) => (a, b, c, d) => f(a)(b)(c)(d);
1
+ import {
2
+ and,
3
+ compose,
4
+ constFalse,
5
+ constNull,
6
+ constTrue,
7
+ constUndefined,
8
+ constVoid,
9
+ constant,
10
+ converge,
11
+ curry,
12
+ curry3,
13
+ curry4,
14
+ flip,
15
+ flow,
16
+ identity,
17
+ juxt,
18
+ memoize,
19
+ memoizeWeak,
20
+ not,
21
+ on,
22
+ once,
23
+ or,
24
+ pipe,
25
+ tap,
26
+ uncurry,
27
+ uncurry3,
28
+ uncurry4
29
+ } from "./chunk-4TXC322E.mjs";
107
30
  export {
108
31
  and,
109
32
  compose,
package/dist/core.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Option, W as WithValue, a as WithLog, R as Result, b as WithKind, c as WithError, T as Task, d as WithErrors, e as WithFirst, f as WithSecond } from './Task-ChKyH0pF.mjs';
2
- export { D as Deferred, E as Err, N as None, g as Ok, S as Some } from './Task-ChKyH0pF.mjs';
1
+ import { a as Option, W as WithValue, b as WithLog, R as Result, c as WithKind, d as WithError, T as Task, e as WithErrors, f as WithFirst, g as WithSecond } from './Task-Bd3gXPRQ.mjs';
2
+ export { D as Deferred, E as Err, N as None, O as Ok, S as Some } from './Task-Bd3gXPRQ.mjs';
3
3
  import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
4
4
 
5
5
  /** Keys of T for which undefined is assignable (i.e. optional fields). */
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Option, W as WithValue, a as WithLog, R as Result, b as WithKind, c as WithError, T as Task, d as WithErrors, e as WithFirst, f as WithSecond } from './Task-BB8Wmc1J.js';
2
- export { D as Deferred, E as Err, N as None, g as Ok, S as Some } from './Task-BB8Wmc1J.js';
1
+ import { a as Option, W as WithValue, b as WithLog, R as Result, c as WithKind, d as WithError, T as Task, e as WithErrors, f as WithFirst, g as WithSecond } from './Task-BjAkkD6t.js';
2
+ export { D as Deferred, E as Err, N as None, O as Ok, S as Some } from './Task-BjAkkD6t.js';
3
3
  import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
4
4
 
5
5
  /** Keys of T for which undefined is assignable (i.e. optional fields). */