@nlozgachev/pipelined 0.13.0 → 0.15.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.
@@ -674,4 +674,4 @@ declare namespace Task {
674
674
  const timeout: <E>(ms: number, onTimeout: () => E) => <A>(task: Task<A>) => Task<Result<E, A>>;
675
675
  }
676
676
 
677
- export { Deferred as D, type Err as E, type None as N, Option as O, Result as R, type Some as S, Task as T, type WithValue as W, type WithLog as a, type WithKind as b, type WithError as c, type WithErrors as d, type WithFirst as e, type WithSecond as f, type Ok as g };
677
+ export { Deferred as D, type Err as E, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, Option as a, type WithLog as b, type WithKind as c, type WithError as d, type WithErrors as e, type WithFirst as f, type WithSecond as g };
@@ -674,4 +674,4 @@ declare namespace Task {
674
674
  const timeout: <E>(ms: number, onTimeout: () => E) => <A>(task: Task<A>) => Task<Result<E, A>>;
675
675
  }
676
676
 
677
- export { Deferred as D, type Err as E, type None as N, Option as O, Result as R, type Some as S, Task as T, type WithValue as W, type WithLog as a, type WithKind as b, type WithError as c, type WithErrors as d, type WithFirst as e, type WithSecond as f, type Ok as g };
677
+ export { Deferred as D, type Err as E, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, Option as a, type WithLog as b, type WithKind as c, type WithError as d, type WithErrors as e, type WithFirst as f, type WithSecond as g };
@@ -0,0 +1,549 @@
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/Resource.ts
224
+ var Resource;
225
+ ((Resource2) => {
226
+ Resource2.make = (acquire, release) => ({ acquire, release });
227
+ Resource2.fromTask = (acquire, release) => ({
228
+ acquire: Task.map((a) => Result.ok(a))(acquire),
229
+ release
230
+ });
231
+ Resource2.use = (f) => (resource) => Task.from(
232
+ () => Deferred.toPromise(resource.acquire()).then(async (acquired) => {
233
+ if (Result.isErr(acquired)) return acquired;
234
+ const a = acquired.value;
235
+ const usageResult = await Deferred.toPromise(f(a)());
236
+ await Deferred.toPromise(resource.release(a)());
237
+ return usageResult;
238
+ })
239
+ );
240
+ Resource2.combine = (resourceA, resourceB) => ({
241
+ acquire: Task.from(
242
+ () => Deferred.toPromise(resourceA.acquire()).then(async (acquiredA) => {
243
+ if (Result.isErr(acquiredA)) return acquiredA;
244
+ const a = acquiredA.value;
245
+ const acquiredB = await Deferred.toPromise(resourceB.acquire());
246
+ if (Result.isErr(acquiredB)) {
247
+ await Deferred.toPromise(resourceA.release(a)());
248
+ return acquiredB;
249
+ }
250
+ return Result.ok([a, acquiredB.value]);
251
+ })
252
+ ),
253
+ release: ([a, b]) => Task.from(() => Deferred.toPromise(resourceB.release(b)()).then(() => Deferred.toPromise(resourceA.release(a)())))
254
+ });
255
+ })(Resource || (Resource = {}));
256
+
257
+ // src/Core/State.ts
258
+ var State;
259
+ ((State2) => {
260
+ State2.resolve = (value) => (s) => [value, s];
261
+ State2.get = () => (s) => [s, s];
262
+ State2.gets = (f) => (s) => [f(s), s];
263
+ State2.put = (newState) => (_s) => [void 0, newState];
264
+ State2.modify = (f) => (s) => [void 0, f(s)];
265
+ State2.map = (f) => (st) => (s) => {
266
+ const [a, s1] = st(s);
267
+ return [f(a), s1];
268
+ };
269
+ State2.chain = (f) => (st) => (s) => {
270
+ const [a, s1] = st(s);
271
+ return f(a)(s1);
272
+ };
273
+ State2.ap = (arg) => (fn) => (s) => {
274
+ const [f, s1] = fn(s);
275
+ const [a, s2] = arg(s1);
276
+ return [f(a), s2];
277
+ };
278
+ State2.tap = (f) => (st) => (s) => {
279
+ const [a, s1] = st(s);
280
+ f(a);
281
+ return [a, s1];
282
+ };
283
+ State2.run = (initialState) => (st) => st(initialState);
284
+ State2.evaluate = (initialState) => (st) => st(initialState)[0];
285
+ State2.execute = (initialState) => (st) => st(initialState)[1];
286
+ })(State || (State = {}));
287
+
288
+ // src/Core/TaskOption.ts
289
+ var TaskOption;
290
+ ((TaskOption2) => {
291
+ TaskOption2.some = (value) => Task.resolve(Option.some(value));
292
+ TaskOption2.none = () => Task.resolve(Option.none());
293
+ TaskOption2.fromOption = (option) => Task.resolve(option);
294
+ TaskOption2.fromTask = (task) => Task.map(Option.some)(task);
295
+ TaskOption2.tryCatch = (f) => Task.from(
296
+ () => f().then(Option.some).catch(() => Option.none())
297
+ );
298
+ TaskOption2.map = (f) => (data) => Task.map(Option.map(f))(data);
299
+ TaskOption2.chain = (f) => (data) => Task.chain((option) => Option.isSome(option) ? f(option.value) : Task.resolve(Option.none()))(data);
300
+ TaskOption2.ap = (arg) => (data) => Task.from(
301
+ () => Promise.all([
302
+ Deferred.toPromise(data()),
303
+ Deferred.toPromise(arg())
304
+ ]).then(([of_, oa]) => Option.ap(oa)(of_))
305
+ );
306
+ TaskOption2.fold = (onNone, onSome) => (data) => Task.map(Option.fold(onNone, onSome))(data);
307
+ TaskOption2.match = (cases) => (data) => Task.map(Option.match(cases))(data);
308
+ TaskOption2.getOrElse = (defaultValue) => (data) => Task.map(Option.getOrElse(defaultValue))(data);
309
+ TaskOption2.tap = (f) => (data) => Task.map(Option.tap(f))(data);
310
+ TaskOption2.filter = (predicate) => (data) => Task.map(Option.filter(predicate))(data);
311
+ TaskOption2.toTaskResult = (onNone) => (data) => Task.map(Option.toResult(onNone))(data);
312
+ })(TaskOption || (TaskOption = {}));
313
+
314
+ // src/Core/TaskResult.ts
315
+ var TaskResult;
316
+ ((TaskResult2) => {
317
+ TaskResult2.ok = (value) => Task.resolve(Result.ok(value));
318
+ TaskResult2.err = (error) => Task.resolve(Result.err(error));
319
+ TaskResult2.tryCatch = (f, onError) => Task.from(
320
+ () => f().then(Result.ok).catch((e) => Result.err(onError(e)))
321
+ );
322
+ TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
323
+ TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
324
+ TaskResult2.chain = (f) => (data) => Task.chain((result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.err(result.error)))(
325
+ data
326
+ );
327
+ TaskResult2.fold = (onErr, onOk) => (data) => Task.map(Result.fold(onErr, onOk))(data);
328
+ TaskResult2.match = (cases) => (data) => Task.map(Result.match(cases))(data);
329
+ TaskResult2.recover = (fallback) => (data) => Task.chain(
330
+ (result) => Result.isErr(result) ? fallback(result.error) : Task.resolve(result)
331
+ )(data);
332
+ TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
333
+ TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
334
+ TaskResult2.retry = (options) => (data) => Task.from(() => {
335
+ const { attempts, backoff, when: shouldRetry } = options;
336
+ const getDelay = (n) => backoff === void 0 ? 0 : typeof backoff === "function" ? backoff(n) : backoff;
337
+ const run = (left) => Deferred.toPromise(data()).then((result) => {
338
+ if (Result.isOk(result)) return result;
339
+ if (left <= 1) return result;
340
+ if (shouldRetry !== void 0 && !shouldRetry(result.error)) {
341
+ return result;
342
+ }
343
+ const ms = getDelay(attempts - left + 1);
344
+ return (ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve()).then(() => run(left - 1));
345
+ });
346
+ return run(attempts);
347
+ });
348
+ TaskResult2.timeout = (ms, onTimeout) => (data) => Task.from(() => {
349
+ let timerId;
350
+ return Promise.race([
351
+ Deferred.toPromise(data()).then((result) => {
352
+ clearTimeout(timerId);
353
+ return result;
354
+ }),
355
+ new Promise((resolve) => {
356
+ timerId = setTimeout(() => resolve(Result.err(onTimeout())), ms);
357
+ })
358
+ ]);
359
+ });
360
+ })(TaskResult || (TaskResult = {}));
361
+
362
+ // src/Core/Validation.ts
363
+ var Validation;
364
+ ((Validation2) => {
365
+ Validation2.valid = (value) => ({
366
+ kind: "Valid",
367
+ value
368
+ });
369
+ Validation2.invalid = (error) => ({
370
+ kind: "Invalid",
371
+ errors: [error]
372
+ });
373
+ Validation2.invalidAll = (errors) => ({
374
+ kind: "Invalid",
375
+ errors
376
+ });
377
+ Validation2.isValid = (data) => data.kind === "Valid";
378
+ Validation2.isInvalid = (data) => data.kind === "Invalid";
379
+ Validation2.map = (f) => (data) => (0, Validation2.isValid)(data) ? (0, Validation2.valid)(f(data.value)) : data;
380
+ Validation2.ap = (arg) => (data) => {
381
+ if ((0, Validation2.isValid)(data) && (0, Validation2.isValid)(arg)) return (0, Validation2.valid)(data.value(arg.value));
382
+ const errors = [
383
+ ...(0, Validation2.isInvalid)(data) ? data.errors : [],
384
+ ...(0, Validation2.isInvalid)(arg) ? arg.errors : []
385
+ ];
386
+ return (0, Validation2.invalidAll)(errors);
387
+ };
388
+ Validation2.fold = (onInvalid, onValid) => (data) => (0, Validation2.isValid)(data) ? onValid(data.value) : onInvalid(data.errors);
389
+ Validation2.match = (cases) => (data) => (0, Validation2.isValid)(data) ? cases.valid(data.value) : cases.invalid(data.errors);
390
+ Validation2.getOrElse = (defaultValue) => (data) => (0, Validation2.isValid)(data) ? data.value : defaultValue();
391
+ Validation2.tap = (f) => (data) => {
392
+ if ((0, Validation2.isValid)(data)) f(data.value);
393
+ return data;
394
+ };
395
+ Validation2.recover = (fallback) => (data) => (0, Validation2.isValid)(data) ? data : fallback(data.errors);
396
+ Validation2.recoverUnless = (blockedErrors, fallback) => (data) => (0, Validation2.isInvalid)(data) && !data.errors.some((err) => blockedErrors.includes(err)) ? fallback() : data;
397
+ Validation2.product = (first, second) => {
398
+ if ((0, Validation2.isValid)(first) && (0, Validation2.isValid)(second)) return (0, Validation2.valid)([first.value, second.value]);
399
+ const errors = [
400
+ ...(0, Validation2.isInvalid)(first) ? first.errors : [],
401
+ ...(0, Validation2.isInvalid)(second) ? second.errors : []
402
+ ];
403
+ return (0, Validation2.invalidAll)(errors);
404
+ };
405
+ Validation2.productAll = (data) => {
406
+ const values = [];
407
+ const errors = [];
408
+ for (const v of data) {
409
+ if ((0, Validation2.isValid)(v)) values.push(v.value);
410
+ else errors.push(...v.errors);
411
+ }
412
+ return errors.length > 0 ? (0, Validation2.invalidAll)(errors) : (0, Validation2.valid)(values);
413
+ };
414
+ })(Validation || (Validation = {}));
415
+
416
+ // src/Core/TaskValidation.ts
417
+ var TaskValidation;
418
+ ((TaskValidation2) => {
419
+ TaskValidation2.valid = (value) => Task.resolve(Validation.valid(value));
420
+ TaskValidation2.invalid = (error) => Task.resolve(Validation.invalid(error));
421
+ TaskValidation2.invalidAll = (errors) => Task.resolve(Validation.invalidAll(errors));
422
+ TaskValidation2.fromValidation = (validation) => Task.resolve(validation);
423
+ TaskValidation2.tryCatch = (f, onError) => Task.from(
424
+ () => f().then(Validation.valid).catch((e) => Validation.invalid(onError(e)))
425
+ );
426
+ TaskValidation2.map = (f) => (data) => Task.map(Validation.map(f))(data);
427
+ TaskValidation2.ap = (arg) => (data) => Task.from(
428
+ () => Promise.all([
429
+ Deferred.toPromise(data()),
430
+ Deferred.toPromise(arg())
431
+ ]).then(([vf, va]) => Validation.ap(va)(vf))
432
+ );
433
+ TaskValidation2.fold = (onInvalid, onValid) => (data) => Task.map(Validation.fold(onInvalid, onValid))(data);
434
+ TaskValidation2.match = (cases) => (data) => Task.map(Validation.match(cases))(data);
435
+ TaskValidation2.getOrElse = (defaultValue) => (data) => Task.map(Validation.getOrElse(defaultValue))(data);
436
+ TaskValidation2.tap = (f) => (data) => Task.map(Validation.tap(f))(data);
437
+ TaskValidation2.recover = (fallback) => (data) => Task.chain(
438
+ (validation) => Validation.isValid(validation) ? Task.resolve(validation) : fallback(validation.errors)
439
+ )(data);
440
+ TaskValidation2.product = (first, second) => Task.from(
441
+ () => Promise.all([
442
+ Deferred.toPromise(first()),
443
+ Deferred.toPromise(second())
444
+ ]).then(([va, vb]) => Validation.product(va, vb))
445
+ );
446
+ TaskValidation2.productAll = (data) => Task.from(
447
+ () => Promise.all(data.map((t) => Deferred.toPromise(t()))).then((results) => Validation.productAll(results))
448
+ );
449
+ })(TaskValidation || (TaskValidation = {}));
450
+
451
+ // src/Core/These.ts
452
+ var These;
453
+ ((These2) => {
454
+ These2.first = (value) => ({ kind: "First", first: value });
455
+ These2.second = (value) => ({ kind: "Second", second: value });
456
+ These2.both = (first2, second2) => ({
457
+ kind: "Both",
458
+ first: first2,
459
+ second: second2
460
+ });
461
+ These2.isFirst = (data) => data.kind === "First";
462
+ These2.isSecond = (data) => data.kind === "Second";
463
+ These2.isBoth = (data) => data.kind === "Both";
464
+ These2.hasFirst = (data) => data.kind === "First" || data.kind === "Both";
465
+ These2.hasSecond = (data) => data.kind === "Second" || data.kind === "Both";
466
+ These2.mapFirst = (f) => (data) => {
467
+ if ((0, These2.isSecond)(data)) return data;
468
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(f(data.first));
469
+ return (0, These2.both)(f(data.first), data.second);
470
+ };
471
+ These2.mapSecond = (f) => (data) => {
472
+ if ((0, These2.isFirst)(data)) return data;
473
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(f(data.second));
474
+ return (0, These2.both)(data.first, f(data.second));
475
+ };
476
+ These2.mapBoth = (onFirst, onSecond) => (data) => {
477
+ if ((0, These2.isSecond)(data)) return (0, These2.second)(onSecond(data.second));
478
+ if ((0, These2.isFirst)(data)) return (0, These2.first)(onFirst(data.first));
479
+ return (0, These2.both)(onFirst(data.first), onSecond(data.second));
480
+ };
481
+ These2.chainFirst = (f) => (data) => {
482
+ if ((0, These2.isSecond)(data)) return data;
483
+ return f(data.first);
484
+ };
485
+ These2.chainSecond = (f) => (data) => {
486
+ if ((0, These2.isFirst)(data)) return data;
487
+ return f(data.second);
488
+ };
489
+ These2.fold = (onFirst, onSecond, onBoth) => (data) => {
490
+ if ((0, These2.isSecond)(data)) return onSecond(data.second);
491
+ if ((0, These2.isFirst)(data)) return onFirst(data.first);
492
+ return onBoth(data.first, data.second);
493
+ };
494
+ These2.match = (cases) => (data) => {
495
+ if ((0, These2.isSecond)(data)) return cases.second(data.second);
496
+ if ((0, These2.isFirst)(data)) return cases.first(data.first);
497
+ return cases.both(data.first, data.second);
498
+ };
499
+ These2.getFirstOrElse = (defaultValue) => (data) => (0, These2.hasFirst)(data) ? data.first : defaultValue();
500
+ These2.getSecondOrElse = (defaultValue) => (data) => (0, These2.hasSecond)(data) ? data.second : defaultValue();
501
+ These2.tap = (f) => (data) => {
502
+ if ((0, These2.hasFirst)(data)) f(data.first);
503
+ return data;
504
+ };
505
+ These2.swap = (data) => {
506
+ if ((0, These2.isSecond)(data)) return (0, These2.first)(data.second);
507
+ if ((0, These2.isFirst)(data)) return (0, These2.second)(data.first);
508
+ return (0, These2.both)(data.second, data.first);
509
+ };
510
+ })(These || (These = {}));
511
+
512
+ // src/Core/Tuple.ts
513
+ var Tuple;
514
+ ((Tuple2) => {
515
+ Tuple2.make = (first2, second2) => [first2, second2];
516
+ Tuple2.first = (tuple) => tuple[0];
517
+ Tuple2.second = (tuple) => tuple[1];
518
+ Tuple2.mapFirst = (f) => (tuple) => [f(tuple[0]), tuple[1]];
519
+ Tuple2.mapSecond = (f) => (tuple) => [tuple[0], f(tuple[1])];
520
+ Tuple2.mapBoth = (onFirst, onSecond) => (tuple) => [
521
+ onFirst(tuple[0]),
522
+ onSecond(tuple[1])
523
+ ];
524
+ Tuple2.fold = (f) => (tuple) => f(tuple[0], tuple[1]);
525
+ Tuple2.swap = (tuple) => [tuple[1], tuple[0]];
526
+ Tuple2.toArray = (tuple) => [...tuple];
527
+ Tuple2.tap = (f) => (tuple) => {
528
+ f(tuple[0], tuple[1]);
529
+ return tuple;
530
+ };
531
+ })(Tuple || (Tuple = {}));
532
+
533
+ export {
534
+ Lens,
535
+ Logged,
536
+ Optional,
537
+ Predicate,
538
+ Reader,
539
+ Refinement,
540
+ RemoteData,
541
+ Resource,
542
+ State,
543
+ TaskOption,
544
+ TaskResult,
545
+ Validation,
546
+ TaskValidation,
547
+ These,
548
+ Tuple
549
+ };
@@ -0,0 +1,10 @@
1
+ // src/Types/Brand.ts
2
+ var Brand;
3
+ ((Brand2) => {
4
+ Brand2.wrap = () => (value) => value;
5
+ Brand2.unwrap = (branded) => branded;
6
+ })(Brand || (Brand = {}));
7
+
8
+ export {
9
+ Brand
10
+ };