@nlozgachev/pipelined 0.31.0 → 0.33.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.
package/dist/core.d.mts CHANGED
@@ -1,6 +1,170 @@
1
- import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-BDcKwFAj.mjs';
2
- export { E as Error, N as None, O as Ok, S as Some } from './Task-BDcKwFAj.mjs';
3
- import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
1
+ import { M as Maybe, W as WithValue, c as WithLog, D as Deferred, R as Result, d as WithKind, e as WithError, f as RetryOptions, g as TimeoutOptions, h as WithTimeout, i as WithMinInterval, j as WithCooldown, k as WithConcurrency, l as WithSize, m as WithMs, n as WithN, T as Task, o as WithErrors, p as WithFirst, q as WithSecond } from './Task-5na0QzS4.mjs';
2
+ export { E as Equality, a as Error, N as None, O as Ok, b as Ordering, S as Some } from './Task-5na0QzS4.mjs';
3
+ import { NonEmptyList } from './types.mjs';
4
+
5
+ /**
6
+ * A type that can combine two values of type `A` into one, with a neutral starting value.
7
+ * `empty` is the identity: `combine(empty)(a) === a` and `combine(a)(empty) === a`.
8
+ * `combine(b)(a)` appends `b` onto `a` — `a` is the accumulated value, `b` is the new element.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * pipe(["hello", ", ", "world"], Combinable.fold(Combinable.string)); // "hello, world"
13
+ * pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
14
+ * ```
15
+ */
16
+ type Combinable<A> = {
17
+ readonly empty: A;
18
+ readonly combine: (b: A) => (a: A) => A;
19
+ };
20
+ declare namespace Combinable {
21
+ /**
22
+ * Combines strings by concatenation. Empty string is the neutral element.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * pipe(["a", "b", "c"], Combinable.fold(Combinable.string)); // "abc"
27
+ * ```
28
+ */
29
+ const string: Combinable<string>;
30
+ /**
31
+ * Combines numbers by addition. `0` is the neutral element.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * pipe([1, 2, 3], Combinable.fold(Combinable.sum)); // 6
36
+ * ```
37
+ */
38
+ const sum: Combinable<number>;
39
+ /**
40
+ * Combines numbers by multiplication. `1` is the neutral element.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * pipe([2, 3, 4], Combinable.fold(Combinable.product)); // 24
45
+ * ```
46
+ */
47
+ const product: Combinable<number>;
48
+ /**
49
+ * Combines booleans with logical AND. `true` is the neutral element.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * pipe([true, true, false], Combinable.fold(Combinable.all)); // false
54
+ * ```
55
+ */
56
+ const all: Combinable<boolean>;
57
+ /**
58
+ * Combines booleans with logical OR. `false` is the neutral element.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * pipe([false, false, true], Combinable.fold(Combinable.any)); // true
63
+ * ```
64
+ */
65
+ const any: Combinable<boolean>;
66
+ /**
67
+ * Combines arrays by concatenation. Empty array is the neutral element.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * pipe([[1, 2], [3], [4, 5]], Combinable.fold(Combinable.array<number>())); // [1, 2, 3, 4, 5]
72
+ * ```
73
+ */
74
+ const array: <A>() => Combinable<readonly A[]>;
75
+ /**
76
+ * Lifts a `Combinable<A>` to `Combinable<Maybe<A>>`. `None` is the neutral element —
77
+ * combining with `None` on either side returns the other value unchanged.
78
+ * Two `Some` values combine their inner values using the inner `Combinable`.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const c = Combinable.maybe(Combinable.sum);
83
+ * c.combine(Maybe.some(3))(Maybe.some(2)); // Some(5)
84
+ * c.combine(Maybe.none())(Maybe.some(5)); // Some(5)
85
+ * ```
86
+ */
87
+ const maybe: <A>(inner: Combinable<A>) => Combinable<Maybe<A>>;
88
+ /**
89
+ * Folds an array into a single value using the `Combinable`'s `empty` as the starting point.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
94
+ * pipe([], Combinable.fold(Combinable.sum)); // 0
95
+ * ```
96
+ */
97
+ const fold: <A>(c: Combinable<A>) => (data: readonly A[]) => A;
98
+ }
99
+
100
+ /**
101
+ * A synchronous memoized computation. The factory function runs exactly once —
102
+ * on the first call to `Lazy.evaluate` — and the result is cached for all subsequent calls.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const config = Lazy.from(() => parseConfig(rawInput));
107
+ *
108
+ * pipe(
109
+ * config,
110
+ * Lazy.map(cfg => cfg.port),
111
+ * Lazy.evaluate,
112
+ * ); // parseConfig ran once; cfg.port returned
113
+ * ```
114
+ */
115
+ type Lazy<A> = {
116
+ readonly get: () => A;
117
+ };
118
+ declare namespace Lazy {
119
+ /**
120
+ * Wraps a thunk in a `Lazy`. The thunk runs exactly once, on first `evaluate`.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const expensive = Lazy.from(() => computeExpensiveValue(input));
125
+ * ```
126
+ */
127
+ const from: <A>(f: () => A) => Lazy<A>;
128
+ /**
129
+ * Forces evaluation and returns the cached result. Safe to call multiple times.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const value = Lazy.evaluate(Lazy.from(() => 42)); // 42
134
+ * ```
135
+ */
136
+ const evaluate: <A>(lazy: Lazy<A>) => A;
137
+ /**
138
+ * Transforms the result of a `Lazy` without triggering evaluation.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * pipe(Lazy.from(() => loadConfig()), Lazy.map(cfg => cfg.port));
143
+ * ```
144
+ */
145
+ const map: <A, B>(f: (a: A) => B) => (lazy: Lazy<A>) => Lazy<B>;
146
+ /**
147
+ * Chains a `Lazy`-returning transformation without triggering evaluation.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * pipe(
152
+ * Lazy.from(() => loadConfig()),
153
+ * Lazy.chain(cfg => Lazy.from(() => openConnection(cfg.dbUrl))),
154
+ * );
155
+ * ```
156
+ */
157
+ const chain: <A, B>(f: (a: A) => Lazy<B>) => (lazy: Lazy<A>) => Lazy<B>;
158
+ /**
159
+ * Runs a side effect on the value without changing it. Fires once, on first `evaluate`.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * pipe(Lazy.from(() => compute()), Lazy.tap(v => console.log("computed:", v)));
164
+ * ```
165
+ */
166
+ const tap: <A>(f: (a: A) => void) => (lazy: Lazy<A>) => Lazy<A>;
167
+ }
4
168
 
5
169
  /** Keys of T for which undefined is assignable (i.e. optional fields). */
6
170
  type OptionalKeys<T> = {
@@ -1820,6 +1984,25 @@ declare namespace TaskResult {
1820
1984
  * Creates a failed TaskResult with the given error.
1821
1985
  */
1822
1986
  const err: <E, A>(error: E) => TaskResult<E, A>;
1987
+ /**
1988
+ * Creates a TaskResult from a nullable value.
1989
+ * Returns Ok if the value is not null or undefined, error from onNull otherwise.
1990
+ */
1991
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => TaskResult<E, A>;
1992
+ /**
1993
+ * Creates a TaskResult from a Maybe.
1994
+ * Some becomes Ok, None becomes error from onNone.
1995
+ */
1996
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => TaskResult<E, A>;
1997
+ /**
1998
+ * Lifts a Result into a TaskResult.
1999
+ */
2000
+ const fromResult: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
2001
+ /**
2002
+ * Wraps a Promise-returning function of any arguments, returning a new function
2003
+ * that catches rejections and returns a TaskResult.
2004
+ */
2005
+ const fromThrowable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => Promise<A>, onError: (e: unknown) => E) => (...args: Args) => TaskResult<E, A>;
1823
2006
  /**
1824
2007
  * Creates a TaskResult from a function that may throw.
1825
2008
  * Catches any errors and transforms them using the onError function.
@@ -1888,6 +2071,11 @@ declare namespace TaskResult {
1888
2071
  * ```
1889
2072
  */
1890
2073
  const tapError: <E, A>(f: (e: E) => void) => (data: TaskResult<E, A>) => TaskResult<E, A>;
2074
+ /**
2075
+ * Applies a function wrapped in a TaskResult to a value wrapped in a TaskResult.
2076
+ * Both Tasks run in parallel.
2077
+ */
2078
+ const ap: <E, A>(arg: TaskResult<E, A>) => <B>(data: TaskResult<E, (a: A) => B>) => TaskResult<E, B>;
1891
2079
  /**
1892
2080
  * Executes a `TaskResult` with an optional signal, returning `Promise<Result<E, A>>`.
1893
2081
  * Use as a terminal step in a `pipe` chain.
@@ -2223,6 +2411,16 @@ declare namespace TaskMaybe {
2223
2411
  * Lifts an Option into a TaskMaybe.
2224
2412
  */
2225
2413
  const fromMaybe: <A>(option: Maybe<A>) => TaskMaybe<A>;
2414
+ /**
2415
+ * Creates a TaskMaybe from a nullable value.
2416
+ * Returns Some if the value is not null or undefined, None otherwise.
2417
+ */
2418
+ const fromNullable: <A>(value: A | null | undefined) => TaskMaybe<A>;
2419
+ /**
2420
+ * Creates a TaskMaybe from a Result.
2421
+ * Ok becomes Some, Error becomes None (the error value is discarded).
2422
+ */
2423
+ const fromResult: <E, A>(result: Result<E, A>) => TaskMaybe<A>;
2226
2424
  /**
2227
2425
  * Lifts a Task into a TaskMaybe by wrapping its result in Some.
2228
2426
  */
@@ -2230,15 +2428,16 @@ declare namespace TaskMaybe {
2230
2428
  /**
2231
2429
  * Creates a TaskMaybe from a Promise-returning function.
2232
2430
  * Returns Some if the promise resolves, None if it rejects.
2431
+ * The factory optionally receives an `AbortSignal` forwarded from the call site.
2233
2432
  *
2234
2433
  * @example
2235
2434
  * ```ts
2236
- * const fetchUser = TaskMaybe.tryCatch(() =>
2237
- * fetch("/user/1").then(r => r.json())
2435
+ * const fetchUser = TaskMaybe.tryCatch((signal) =>
2436
+ * fetch("/user/1", { signal }).then(r => r.json())
2238
2437
  * );
2239
2438
  * ```
2240
2439
  */
2241
- const tryCatch: <A>(f: () => Promise<A>) => TaskMaybe<A>;
2440
+ const tryCatch: <A>(f: (signal?: AbortSignal) => Promise<A>) => TaskMaybe<A>;
2242
2441
  /**
2243
2442
  * Transforms the value inside a TaskMaybe.
2244
2443
  */
@@ -2391,6 +2590,30 @@ declare namespace Validation {
2391
2590
  * ```
2392
2591
  */
2393
2592
  const fromPredicate: <E, A>(pred: (a: A) => boolean, onFalse: (a: A) => E) => (a: A) => Validation<E, A>;
2593
+ /**
2594
+ * Creates a Validation from a nullable value.
2595
+ * If the value is null or undefined, returns Invalid with the error from onNull.
2596
+ * Otherwise, returns Valid.
2597
+ *
2598
+ * @example
2599
+ * ```ts
2600
+ * pipe(null, Validation.fromNullable(() => "is null")); // Invalid(["is null"])
2601
+ * pipe(42, Validation.fromNullable(() => "is null")); // Valid(42)
2602
+ * ```
2603
+ */
2604
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => Validation<E, A>;
2605
+ /**
2606
+ * Creates a Validation from a Maybe.
2607
+ * If the Maybe is None, returns Invalid with the error from onNone.
2608
+ * Otherwise, returns Valid.
2609
+ *
2610
+ * @example
2611
+ * ```ts
2612
+ * pipe(Maybe.none(), Validation.fromMaybe(() => "is none")); // Invalid(["is none"])
2613
+ * pipe(Maybe.some(42), Validation.fromMaybe(() => "is none")); // Valid(42)
2614
+ * ```
2615
+ */
2616
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => Validation<E, A>;
2394
2617
  /**
2395
2618
  * Transforms the success value inside a Validation.
2396
2619
  *
@@ -2624,20 +2847,37 @@ declare namespace TaskValidation {
2624
2847
  * Lifts a Validation into a TaskValidation.
2625
2848
  */
2626
2849
  const fromValidation: <E, A>(validation: Validation<E, A>) => TaskValidation<E, A>;
2850
+ /**
2851
+ * Creates a TaskValidation from a nullable value.
2852
+ * If the value is null or undefined, returns Invalid with the error from onNull.
2853
+ * Otherwise, returns Valid.
2854
+ */
2855
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => TaskValidation<E, A>;
2856
+ /**
2857
+ * Creates a TaskValidation from a Maybe.
2858
+ * Some becomes Valid, None becomes Invalid with the error from onNone.
2859
+ */
2860
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => TaskValidation<E, A>;
2861
+ /**
2862
+ * Creates a TaskValidation from a Result.
2863
+ * Ok becomes Valid, Error(e) becomes Invalid([e]).
2864
+ */
2865
+ const fromResult: <E, A>(result: Result<E, A>) => TaskValidation<E, A>;
2627
2866
  /**
2628
2867
  * Creates a TaskValidation from a Promise-returning function.
2629
2868
  * Catches any errors and transforms them using the onError function.
2869
+ * The factory optionally receives an `AbortSignal` forwarded from the call site.
2630
2870
  *
2631
2871
  * @example
2632
2872
  * ```ts
2633
2873
  * const fetchUser = (id: string): TaskValidation<string, User> =>
2634
2874
  * TaskValidation.tryCatch(
2635
- * () => fetch(`/users/${id}`).then(r => r.json()),
2875
+ * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
2636
2876
  * e => `Failed to fetch user: ${e}`
2637
2877
  * );
2638
2878
  * ```
2639
2879
  */
2640
- const tryCatch: <E, A>(f: () => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
2880
+ const tryCatch: <E, A>(f: (signal?: AbortSignal) => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
2641
2881
  /**
2642
2882
  * Transforms the success value inside a TaskValidation.
2643
2883
  */
@@ -3079,4 +3319,4 @@ declare namespace Tuple {
3079
3319
  const tap: <A, B>(f: (a: A, b: B) => void) => (tuple: Tuple<A, B>) => Tuple<A, B>;
3080
3320
  }
3081
3321
 
3082
- export { Deferred, type Failure, type Invalid, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };
3322
+ export { Combinable, Deferred, type Failure, type Invalid, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };
package/dist/core.d.ts CHANGED
@@ -1,6 +1,170 @@
1
- import { M as Maybe, W as WithValue, a as WithLog, D as Deferred, R as Result, b as WithKind, c as WithError, d as RetryOptions, e as TimeoutOptions, f as WithTimeout, g as WithMinInterval, h as WithCooldown, i as WithConcurrency, j as WithSize, k as WithMs, l as WithN, T as Task, m as WithErrors, n as WithFirst, o as WithSecond } from './Task-CnF22Q2o.js';
2
- export { E as Error, N as None, O as Ok, S as Some } from './Task-CnF22Q2o.js';
3
- import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
1
+ import { M as Maybe, W as WithValue, c as WithLog, D as Deferred, R as Result, d as WithKind, e as WithError, f as RetryOptions, g as TimeoutOptions, h as WithTimeout, i as WithMinInterval, j as WithCooldown, k as WithConcurrency, l as WithSize, m as WithMs, n as WithN, T as Task, o as WithErrors, p as WithFirst, q as WithSecond } from './Task-DeiWgoeJ.js';
2
+ export { E as Equality, a as Error, N as None, O as Ok, b as Ordering, S as Some } from './Task-DeiWgoeJ.js';
3
+ import { NonEmptyList } from './types.js';
4
+
5
+ /**
6
+ * A type that can combine two values of type `A` into one, with a neutral starting value.
7
+ * `empty` is the identity: `combine(empty)(a) === a` and `combine(a)(empty) === a`.
8
+ * `combine(b)(a)` appends `b` onto `a` — `a` is the accumulated value, `b` is the new element.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * pipe(["hello", ", ", "world"], Combinable.fold(Combinable.string)); // "hello, world"
13
+ * pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
14
+ * ```
15
+ */
16
+ type Combinable<A> = {
17
+ readonly empty: A;
18
+ readonly combine: (b: A) => (a: A) => A;
19
+ };
20
+ declare namespace Combinable {
21
+ /**
22
+ * Combines strings by concatenation. Empty string is the neutral element.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * pipe(["a", "b", "c"], Combinable.fold(Combinable.string)); // "abc"
27
+ * ```
28
+ */
29
+ const string: Combinable<string>;
30
+ /**
31
+ * Combines numbers by addition. `0` is the neutral element.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * pipe([1, 2, 3], Combinable.fold(Combinable.sum)); // 6
36
+ * ```
37
+ */
38
+ const sum: Combinable<number>;
39
+ /**
40
+ * Combines numbers by multiplication. `1` is the neutral element.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * pipe([2, 3, 4], Combinable.fold(Combinable.product)); // 24
45
+ * ```
46
+ */
47
+ const product: Combinable<number>;
48
+ /**
49
+ * Combines booleans with logical AND. `true` is the neutral element.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * pipe([true, true, false], Combinable.fold(Combinable.all)); // false
54
+ * ```
55
+ */
56
+ const all: Combinable<boolean>;
57
+ /**
58
+ * Combines booleans with logical OR. `false` is the neutral element.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * pipe([false, false, true], Combinable.fold(Combinable.any)); // true
63
+ * ```
64
+ */
65
+ const any: Combinable<boolean>;
66
+ /**
67
+ * Combines arrays by concatenation. Empty array is the neutral element.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * pipe([[1, 2], [3], [4, 5]], Combinable.fold(Combinable.array<number>())); // [1, 2, 3, 4, 5]
72
+ * ```
73
+ */
74
+ const array: <A>() => Combinable<readonly A[]>;
75
+ /**
76
+ * Lifts a `Combinable<A>` to `Combinable<Maybe<A>>`. `None` is the neutral element —
77
+ * combining with `None` on either side returns the other value unchanged.
78
+ * Two `Some` values combine their inner values using the inner `Combinable`.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const c = Combinable.maybe(Combinable.sum);
83
+ * c.combine(Maybe.some(3))(Maybe.some(2)); // Some(5)
84
+ * c.combine(Maybe.none())(Maybe.some(5)); // Some(5)
85
+ * ```
86
+ */
87
+ const maybe: <A>(inner: Combinable<A>) => Combinable<Maybe<A>>;
88
+ /**
89
+ * Folds an array into a single value using the `Combinable`'s `empty` as the starting point.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * pipe([1, 2, 3, 4, 5], Combinable.fold(Combinable.sum)); // 15
94
+ * pipe([], Combinable.fold(Combinable.sum)); // 0
95
+ * ```
96
+ */
97
+ const fold: <A>(c: Combinable<A>) => (data: readonly A[]) => A;
98
+ }
99
+
100
+ /**
101
+ * A synchronous memoized computation. The factory function runs exactly once —
102
+ * on the first call to `Lazy.evaluate` — and the result is cached for all subsequent calls.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const config = Lazy.from(() => parseConfig(rawInput));
107
+ *
108
+ * pipe(
109
+ * config,
110
+ * Lazy.map(cfg => cfg.port),
111
+ * Lazy.evaluate,
112
+ * ); // parseConfig ran once; cfg.port returned
113
+ * ```
114
+ */
115
+ type Lazy<A> = {
116
+ readonly get: () => A;
117
+ };
118
+ declare namespace Lazy {
119
+ /**
120
+ * Wraps a thunk in a `Lazy`. The thunk runs exactly once, on first `evaluate`.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const expensive = Lazy.from(() => computeExpensiveValue(input));
125
+ * ```
126
+ */
127
+ const from: <A>(f: () => A) => Lazy<A>;
128
+ /**
129
+ * Forces evaluation and returns the cached result. Safe to call multiple times.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const value = Lazy.evaluate(Lazy.from(() => 42)); // 42
134
+ * ```
135
+ */
136
+ const evaluate: <A>(lazy: Lazy<A>) => A;
137
+ /**
138
+ * Transforms the result of a `Lazy` without triggering evaluation.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * pipe(Lazy.from(() => loadConfig()), Lazy.map(cfg => cfg.port));
143
+ * ```
144
+ */
145
+ const map: <A, B>(f: (a: A) => B) => (lazy: Lazy<A>) => Lazy<B>;
146
+ /**
147
+ * Chains a `Lazy`-returning transformation without triggering evaluation.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * pipe(
152
+ * Lazy.from(() => loadConfig()),
153
+ * Lazy.chain(cfg => Lazy.from(() => openConnection(cfg.dbUrl))),
154
+ * );
155
+ * ```
156
+ */
157
+ const chain: <A, B>(f: (a: A) => Lazy<B>) => (lazy: Lazy<A>) => Lazy<B>;
158
+ /**
159
+ * Runs a side effect on the value without changing it. Fires once, on first `evaluate`.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * pipe(Lazy.from(() => compute()), Lazy.tap(v => console.log("computed:", v)));
164
+ * ```
165
+ */
166
+ const tap: <A>(f: (a: A) => void) => (lazy: Lazy<A>) => Lazy<A>;
167
+ }
4
168
 
5
169
  /** Keys of T for which undefined is assignable (i.e. optional fields). */
6
170
  type OptionalKeys<T> = {
@@ -1820,6 +1984,25 @@ declare namespace TaskResult {
1820
1984
  * Creates a failed TaskResult with the given error.
1821
1985
  */
1822
1986
  const err: <E, A>(error: E) => TaskResult<E, A>;
1987
+ /**
1988
+ * Creates a TaskResult from a nullable value.
1989
+ * Returns Ok if the value is not null or undefined, error from onNull otherwise.
1990
+ */
1991
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => TaskResult<E, A>;
1992
+ /**
1993
+ * Creates a TaskResult from a Maybe.
1994
+ * Some becomes Ok, None becomes error from onNone.
1995
+ */
1996
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => TaskResult<E, A>;
1997
+ /**
1998
+ * Lifts a Result into a TaskResult.
1999
+ */
2000
+ const fromResult: <E, A>(result: Result<E, A>) => TaskResult<E, A>;
2001
+ /**
2002
+ * Wraps a Promise-returning function of any arguments, returning a new function
2003
+ * that catches rejections and returns a TaskResult.
2004
+ */
2005
+ const fromThrowable: <Args extends readonly unknown[], A, E>(f: (...args: Args) => Promise<A>, onError: (e: unknown) => E) => (...args: Args) => TaskResult<E, A>;
1823
2006
  /**
1824
2007
  * Creates a TaskResult from a function that may throw.
1825
2008
  * Catches any errors and transforms them using the onError function.
@@ -1888,6 +2071,11 @@ declare namespace TaskResult {
1888
2071
  * ```
1889
2072
  */
1890
2073
  const tapError: <E, A>(f: (e: E) => void) => (data: TaskResult<E, A>) => TaskResult<E, A>;
2074
+ /**
2075
+ * Applies a function wrapped in a TaskResult to a value wrapped in a TaskResult.
2076
+ * Both Tasks run in parallel.
2077
+ */
2078
+ const ap: <E, A>(arg: TaskResult<E, A>) => <B>(data: TaskResult<E, (a: A) => B>) => TaskResult<E, B>;
1891
2079
  /**
1892
2080
  * Executes a `TaskResult` with an optional signal, returning `Promise<Result<E, A>>`.
1893
2081
  * Use as a terminal step in a `pipe` chain.
@@ -2223,6 +2411,16 @@ declare namespace TaskMaybe {
2223
2411
  * Lifts an Option into a TaskMaybe.
2224
2412
  */
2225
2413
  const fromMaybe: <A>(option: Maybe<A>) => TaskMaybe<A>;
2414
+ /**
2415
+ * Creates a TaskMaybe from a nullable value.
2416
+ * Returns Some if the value is not null or undefined, None otherwise.
2417
+ */
2418
+ const fromNullable: <A>(value: A | null | undefined) => TaskMaybe<A>;
2419
+ /**
2420
+ * Creates a TaskMaybe from a Result.
2421
+ * Ok becomes Some, Error becomes None (the error value is discarded).
2422
+ */
2423
+ const fromResult: <E, A>(result: Result<E, A>) => TaskMaybe<A>;
2226
2424
  /**
2227
2425
  * Lifts a Task into a TaskMaybe by wrapping its result in Some.
2228
2426
  */
@@ -2230,15 +2428,16 @@ declare namespace TaskMaybe {
2230
2428
  /**
2231
2429
  * Creates a TaskMaybe from a Promise-returning function.
2232
2430
  * Returns Some if the promise resolves, None if it rejects.
2431
+ * The factory optionally receives an `AbortSignal` forwarded from the call site.
2233
2432
  *
2234
2433
  * @example
2235
2434
  * ```ts
2236
- * const fetchUser = TaskMaybe.tryCatch(() =>
2237
- * fetch("/user/1").then(r => r.json())
2435
+ * const fetchUser = TaskMaybe.tryCatch((signal) =>
2436
+ * fetch("/user/1", { signal }).then(r => r.json())
2238
2437
  * );
2239
2438
  * ```
2240
2439
  */
2241
- const tryCatch: <A>(f: () => Promise<A>) => TaskMaybe<A>;
2440
+ const tryCatch: <A>(f: (signal?: AbortSignal) => Promise<A>) => TaskMaybe<A>;
2242
2441
  /**
2243
2442
  * Transforms the value inside a TaskMaybe.
2244
2443
  */
@@ -2391,6 +2590,30 @@ declare namespace Validation {
2391
2590
  * ```
2392
2591
  */
2393
2592
  const fromPredicate: <E, A>(pred: (a: A) => boolean, onFalse: (a: A) => E) => (a: A) => Validation<E, A>;
2593
+ /**
2594
+ * Creates a Validation from a nullable value.
2595
+ * If the value is null or undefined, returns Invalid with the error from onNull.
2596
+ * Otherwise, returns Valid.
2597
+ *
2598
+ * @example
2599
+ * ```ts
2600
+ * pipe(null, Validation.fromNullable(() => "is null")); // Invalid(["is null"])
2601
+ * pipe(42, Validation.fromNullable(() => "is null")); // Valid(42)
2602
+ * ```
2603
+ */
2604
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => Validation<E, A>;
2605
+ /**
2606
+ * Creates a Validation from a Maybe.
2607
+ * If the Maybe is None, returns Invalid with the error from onNone.
2608
+ * Otherwise, returns Valid.
2609
+ *
2610
+ * @example
2611
+ * ```ts
2612
+ * pipe(Maybe.none(), Validation.fromMaybe(() => "is none")); // Invalid(["is none"])
2613
+ * pipe(Maybe.some(42), Validation.fromMaybe(() => "is none")); // Valid(42)
2614
+ * ```
2615
+ */
2616
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => Validation<E, A>;
2394
2617
  /**
2395
2618
  * Transforms the success value inside a Validation.
2396
2619
  *
@@ -2624,20 +2847,37 @@ declare namespace TaskValidation {
2624
2847
  * Lifts a Validation into a TaskValidation.
2625
2848
  */
2626
2849
  const fromValidation: <E, A>(validation: Validation<E, A>) => TaskValidation<E, A>;
2850
+ /**
2851
+ * Creates a TaskValidation from a nullable value.
2852
+ * If the value is null or undefined, returns Invalid with the error from onNull.
2853
+ * Otherwise, returns Valid.
2854
+ */
2855
+ const fromNullable: <E>(onNull: () => E) => <A>(value: A | null | undefined) => TaskValidation<E, A>;
2856
+ /**
2857
+ * Creates a TaskValidation from a Maybe.
2858
+ * Some becomes Valid, None becomes Invalid with the error from onNone.
2859
+ */
2860
+ const fromMaybe: <E>(onNone: () => E) => <A>(maybe: Maybe<A>) => TaskValidation<E, A>;
2861
+ /**
2862
+ * Creates a TaskValidation from a Result.
2863
+ * Ok becomes Valid, Error(e) becomes Invalid([e]).
2864
+ */
2865
+ const fromResult: <E, A>(result: Result<E, A>) => TaskValidation<E, A>;
2627
2866
  /**
2628
2867
  * Creates a TaskValidation from a Promise-returning function.
2629
2868
  * Catches any errors and transforms them using the onError function.
2869
+ * The factory optionally receives an `AbortSignal` forwarded from the call site.
2630
2870
  *
2631
2871
  * @example
2632
2872
  * ```ts
2633
2873
  * const fetchUser = (id: string): TaskValidation<string, User> =>
2634
2874
  * TaskValidation.tryCatch(
2635
- * () => fetch(`/users/${id}`).then(r => r.json()),
2875
+ * (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
2636
2876
  * e => `Failed to fetch user: ${e}`
2637
2877
  * );
2638
2878
  * ```
2639
2879
  */
2640
- const tryCatch: <E, A>(f: () => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
2880
+ const tryCatch: <E, A>(f: (signal?: AbortSignal) => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
2641
2881
  /**
2642
2882
  * Transforms the success value inside a TaskValidation.
2643
2883
  */
@@ -3079,4 +3319,4 @@ declare namespace Tuple {
3079
3319
  const tap: <A, B>(f: (a: A, b: B) => void) => (tuple: Tuple<A, B>) => Tuple<A, B>;
3080
3320
  }
3081
3321
 
3082
- export { Deferred, type Failure, type Invalid, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };
3322
+ export { Combinable, Deferred, type Failure, type Invalid, Lazy, Lens, type Loading, Logged, Maybe, type NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, Result, State, type Success, Task, TaskMaybe, TaskResult, TaskValidation, These, type TheseBoth, type TheseFirst, type TheseSecond, Tuple, type Valid, Validation };