@nlozgachev/pipelined 0.44.0 → 0.46.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.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { M as Maybe, R as Result, T as Task } from './Validation-DM2eh6wj.js';
2
- export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, c as TaskMaybe, d as TaskResult, e as TaskValidation, V as Validation } from './Validation-DM2eh6wj.js';
3
- import { n as WithValue, h as WithLog, D as Deferred, g as WithKind, d as WithError, R as RetryOptions, a as TimeoutOptions, m as WithTimeout, i as WithMinInterval, b as WithCooldown, W as WithConcurrency, l as WithSize, c as WithDuration, j as WithN, f as WithFirst, k as WithSecond } from './InternalTypes-7o9-yrHq.js';
1
+ import { M as Maybe, R as Result, T as Task } from './Validation-BMsvixWH.js';
2
+ export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, c as TaskMaybe, d as TaskResult, e as TaskValidation, V as Validation } from './Validation-BMsvixWH.js';
3
+ import { o as WithValue, i as WithLog, D as Deferred, h as WithKind, e as WithError, R as RetryOptions, b as TimeoutOptions, n as WithTimeout, j as WithMinInterval, c as WithCooldown, W as WithConcurrency, m as WithSize, d as WithDuration, k as WithN, g as WithFirst, l as WithSecond } from './InternalTypes-Mssktd7z.js';
4
4
  import { Duration } from './types.js';
5
5
 
6
6
  /**
@@ -81,8 +81,8 @@ declare namespace Combinable {
81
81
  * @example
82
82
  * ```ts
83
83
  * const c = Combinable.maybe(Combinable.sum);
84
- * c.combine(Maybe.some(3))(Maybe.some(2)); // Some(5)
85
- * c.combine(Maybe.none())(Maybe.some(5)); // Some(5)
84
+ * c.combine(Maybe.make.some(3))(Maybe.make.some(2)); // Some(5)
85
+ * c.combine(Maybe.make.none())(Maybe.make.some(5)); // Some(5)
86
86
  * ```
87
87
  */
88
88
  const maybe: <A>(inner: Combinable<A>) => Combinable<Maybe<A>>;
@@ -179,8 +179,8 @@ declare namespace Lazy {
179
179
  * type Address = { city: string; zip: string };
180
180
  * type User = { name: string; address: Address };
181
181
  *
182
- * const addressLens = Lens.prop<User>()("address");
183
- * const cityLens = Lens.prop<Address>()("city");
182
+ * const addressLens = Lens.from.property<User>()("address");
183
+ * const cityLens = Lens.from.property<Address>()("city");
184
184
  * const userCityLens = pipe(addressLens, Lens.andThen(cityLens));
185
185
  *
186
186
  * pipe(user, Lens.get(userCityLens)); // "Berlin"
@@ -193,28 +193,30 @@ type Lens<S, A> = {
193
193
  readonly set: (a: A) => (s: S) => S;
194
194
  };
195
195
  declare namespace Lens {
196
- /**
197
- * Constructs a Lens from a getter and a setter.
198
- *
199
- * @example
200
- * ```ts
201
- * const nameLens = Lens.make(
202
- * (user: User) => user.name,
203
- * (name) => (user) => ({ ...user, name }),
204
- * );
205
- * ```
206
- */
207
- const make: <S, A>(get: (s: S) => A, set: (a: A) => (s: S) => S) => Lens<S, A>;
208
- /**
209
- * Creates a Lens that focuses on a property of an object.
210
- * Call with the structure type first, then the key.
211
- *
212
- * @example
213
- * ```ts
214
- * const nameLens = Lens.prop<User>()("name");
215
- * ```
216
- */
217
- const prop: <S>() => <K extends keyof S>(key: K) => Lens<S, S[K]>;
196
+ namespace from {
197
+ /**
198
+ * Constructs a Lens from a getter and a setter.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * const nameLens = Lens.from.accessors(
203
+ * (user: User) => user.name,
204
+ * (name) => (user) => ({ ...user, name }),
205
+ * );
206
+ * ```
207
+ */
208
+ const accessors: <S, A>(get: (s: S) => A, set: (a: A) => (s: S) => S) => Lens<S, A>;
209
+ /**
210
+ * Creates a Lens that focuses on a property of an object.
211
+ * Call with the structure type first, then the key.
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * const nameLens = Lens.from.property<User>()("name");
216
+ * ```
217
+ */
218
+ const property: <S>() => <K extends keyof S>(key: K) => Lens<S, S[K]>;
219
+ }
218
220
  /**
219
221
  * Reads the focused value from a structure.
220
222
  *
@@ -249,8 +251,8 @@ declare namespace Lens {
249
251
  * @example
250
252
  * ```ts
251
253
  * const userCityLens = pipe(
252
- * Lens.prop<User>()("address"),
253
- * Lens.andThen(Lens.prop<Address>()("city")),
254
+ * Lens.from.property<User>()("address"),
255
+ * Lens.andThen(Lens.from.property<Address>()("city")),
254
256
  * );
255
257
  * ```
256
258
  */
@@ -262,8 +264,8 @@ declare namespace Lens {
262
264
  * @example
263
265
  * ```ts
264
266
  * const userBioOpt = pipe(
265
- * Lens.prop<User>()("profile"),
266
- * Lens.andThenOptional(Optional.prop<Profile>()("bio")),
267
+ * Lens.from.property<User>()("profile"),
268
+ * Lens.andThenOptional(Optional.from.property<Profile>()("bio")),
267
269
  * );
268
270
  * ```
269
271
  */
@@ -275,9 +277,9 @@ declare namespace Lens {
275
277
  * @example
276
278
  * ```ts
277
279
  * pipe(
278
- * Lens.prop<User>()("address"),
280
+ * Lens.from.property<User>()("address"),
279
281
  * Lens.toOptional,
280
- * Optional.andThen(Optional.prop<Address>()("landmark")),
282
+ * Optional.andThen(Optional.from.property<Address>()("landmark")),
281
283
  * );
282
284
  * ```
283
285
  */
@@ -295,13 +297,13 @@ declare namespace Lens {
295
297
  * @example
296
298
  * ```ts
297
299
  * const program = pipe(
298
- * Logged.make<string, number>(0),
300
+ * Logged.from.value<string, number>(0),
299
301
  * Logged.chain(n => pipe(
300
- * Logged.tell("start"),
302
+ * Logged.from.entry("start"),
301
303
  * Logged.map(() => n + 1),
302
304
  * )),
303
305
  * Logged.chain(n => pipe(
304
- * Logged.tell("done"),
306
+ * Logged.from.entry("done"),
305
307
  * Logged.map(() => n * 10),
306
308
  * )),
307
309
  * );
@@ -311,32 +313,34 @@ declare namespace Lens {
311
313
  */
312
314
  type Logged<L, A> = WithValue<A> & WithLog<L>;
313
315
  declare namespace Logged {
314
- /**
315
- * Wraps a pure value into a `Logged` with an empty log.
316
- *
317
- * @example
318
- * ```ts
319
- * Logged.make<string, number>(42); // { value: 42, log: [] }
320
- * ```
321
- */
322
- const make: <W, A>(value: A) => Logged<W, A>;
323
- /**
324
- * Creates a `Logged` that records a single log entry and produces no
325
- * meaningful value. Use this to append to the log inside a `chain`.
326
- *
327
- * @example
328
- * ```ts
329
- * Logged.tell("operation completed"); // { value: undefined, log: ["operation completed"] }
330
- * ```
331
- */
332
- const tell: <W>(entry: W) => Logged<W, undefined>;
316
+ namespace from {
317
+ /**
318
+ * Wraps a pure value into a `Logged` with an empty log.
319
+ *
320
+ * @example
321
+ * ```ts
322
+ * Logged.from.value<string, number>(42); // { value: 42, log: [] }
323
+ * ```
324
+ */
325
+ const value: <W, A>(val: A) => Logged<W, A>;
326
+ /**
327
+ * Creates a `Logged` that records a single log entry and produces no
328
+ * meaningful value. Use this to append to the log inside a `chain`.
329
+ *
330
+ * @example
331
+ * ```ts
332
+ * Logged.from.entry("operation completed"); // { value: undefined, log: ["operation completed"] }
333
+ * ```
334
+ */
335
+ const entry: <W>(logEntry: W) => Logged<W, undefined>;
336
+ }
333
337
  /**
334
338
  * Transforms the value inside a `Logged` without affecting the log.
335
339
  *
336
340
  * @example
337
341
  * ```ts
338
342
  * pipe(
339
- * Logged.make<string, number>(5),
343
+ * Logged.from.value<string, number>(5),
340
344
  * Logged.map(n => n * 2),
341
345
  * ); // { value: 10, log: [] }
342
346
  * ```
@@ -352,9 +356,9 @@ declare namespace Logged {
352
356
  * @example
353
357
  * ```ts
354
358
  * const result = pipe(
355
- * Logged.make<string, number>(1),
356
- * Logged.chain(n => pipe(Logged.tell("step"), Logged.map(() => n + 1))),
357
- * Logged.chain(n => pipe(Logged.tell("done"), Logged.map(() => n * 10))),
359
+ * Logged.from.value<string, number>(1),
360
+ * Logged.chain(n => pipe(Logged.from.entry("step"), Logged.map(() => n + 1))),
361
+ * Logged.chain(n => pipe(Logged.from.entry("done"), Logged.map(() => n * 10))),
358
362
  * );
359
363
  *
360
364
  * Logged.run(result); // [20, ["step", "done"]]
@@ -385,7 +389,7 @@ declare namespace Logged {
385
389
  * @example
386
390
  * ```ts
387
391
  * pipe(
388
- * Logged.make<string, number>(42),
392
+ * Logged.from.value<string, number>(42),
389
393
  * Logged.tap(n => console.log("value:", n)),
390
394
  * );
391
395
  * ```
@@ -398,8 +402,8 @@ declare namespace Logged {
398
402
  * @example
399
403
  * ```ts
400
404
  * const result = pipe(
401
- * Logged.make<string, number>(1),
402
- * Logged.chain(n => pipe(Logged.tell("incremented"), Logged.map(() => n + 1))),
405
+ * Logged.from.value<string, number>(1),
406
+ * Logged.chain(n => pipe(Logged.from.entry("incremented"), Logged.map(() => n + 1))),
403
407
  * );
404
408
  *
405
409
  * const [value, log] = Logged.run(result);
@@ -412,7 +416,7 @@ declare namespace Logged {
412
416
  *
413
417
  * @example
414
418
  * ```ts
415
- * pipe(Logged.make<string, number>(42), Logged.bindTo("value")); // Logged({ value: 42 })
419
+ * pipe(Logged.from.value<string, number>(42), Logged.bindTo("value")); // Logged({ value: 42 })
416
420
  * ```
417
421
  */
418
422
  const bindTo: <K extends string>(key: K) => <W, A>(data: Logged<W, A>) => Logged<W, { [P in K]: A; }>;
@@ -422,8 +426,8 @@ declare namespace Logged {
422
426
  * @example
423
427
  * ```ts
424
428
  * pipe(
425
- * Logged.make<string, { a: number }>({ a: 1 }),
426
- * Logged.bind("b", ({ a }) => Logged.make<string, number>(a + 1))
429
+ * Logged.from.value<string, { a: number }>({ a: 1 }),
430
+ * Logged.bind("b", ({ a }) => Logged.from.value<string, number>(a + 1))
427
431
  * ); // Logged({ value: { a: 1, b: 2 } })
428
432
  * ```
429
433
  */
@@ -1035,19 +1039,29 @@ declare namespace Op {
1035
1039
  *
1036
1040
  * @example
1037
1041
  * ```ts
1038
- * Op.toResult(() => new ApiError("no result"))(outcome);
1042
+ * Op.to.Result(() => new ApiError("no result"))(outcome);
1039
1043
  * ```
1040
1044
  */
1041
- const toResult: <E, A>(onNil: () => E) => (outcome: Outcome<E, A>) => Result<E, A>;
1042
- /**
1043
- * Converts an Outcome to a `Maybe`. `Ok` becomes `Some`; `Err` and `Nil` become `None`.
1044
- *
1045
- * @example
1046
- * ```ts
1047
- * Op.toMaybe(outcome); // Maybe<User>
1048
- * ```
1049
- */
1050
- const toMaybe: <E, A>(outcome: Outcome<E, A>) => Maybe<A>;
1045
+ namespace to {
1046
+ /**
1047
+ * Converts an Outcome to a `Result`. `Nil` becomes `Err(onNil())`.
1048
+ *
1049
+ * @example
1050
+ * ```ts
1051
+ * Op.to.Result(() => new ApiError("no result"))(outcome);
1052
+ * ```
1053
+ */
1054
+ const Result: <E, A>(onNil: () => E) => (outcome: Outcome<E, A>) => Result<E, A>;
1055
+ /**
1056
+ * Converts an Outcome to a `Maybe`. `Ok` becomes `Some`; `Err` and `Nil` become `None`.
1057
+ *
1058
+ * @example
1059
+ * ```ts
1060
+ * Op.to.Maybe(outcome); // Maybe<User>
1061
+ * ```
1062
+ */
1063
+ const Maybe: <E, A>(outcome: Outcome<E, A>) => Maybe<A>;
1064
+ }
1051
1065
  /**
1052
1066
  * Resolves when all invocations settle, returning their outcomes in order.
1053
1067
  * An alternative to `Promise.all` that stays within the `Op` type system.
@@ -1147,7 +1161,7 @@ type OptionalKeys<T> = {
1147
1161
  * ```ts
1148
1162
  * type Profile = { username: string; bio?: string };
1149
1163
  *
1150
- * const bioOpt = Optional.prop<Profile>()("bio");
1164
+ * const bioOpt = Optional.from.property<Profile>()("bio");
1151
1165
  *
1152
1166
  * pipe(profile, Optional.get(bioOpt)); // Some("hello") or None
1153
1167
  * pipe(profile, Optional.set(bioOpt)("hello")); // new Profile with bio set
@@ -1159,30 +1173,32 @@ type Optional<S, A> = {
1159
1173
  readonly set: (a: A) => (s: S) => S;
1160
1174
  };
1161
1175
  declare namespace Optional {
1162
- /**
1163
- * Constructs an Optional from a getter (returning Maybe<A>) and a setter.
1164
- *
1165
- * @example
1166
- * ```ts
1167
- * const firstChar = Optional.make(
1168
- * (s: string) => s.length > 0 ? Maybe.some(s[0]) : Maybe.none(),
1169
- * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
1170
- * );
1171
- * ```
1172
- */
1173
- const make: <S, A>(get: (s: S) => Maybe<A>, set: (a: A) => (s: S) => S) => Optional<S, A>;
1174
- /**
1175
- * Creates an Optional that focuses on an optional property of an object.
1176
- * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
1177
- * Call with the structure type first, then the key.
1178
- *
1179
- * @example
1180
- * ```ts
1181
- * type Profile = { username: string; bio?: string };
1182
- * const bioOpt = Optional.prop<Profile>()("bio");
1183
- * ```
1184
- */
1185
- const prop: <S>() => <K extends OptionalKeys<S>>(key: K) => Optional<S, NonNullable<S[K]>>;
1176
+ namespace from {
1177
+ /**
1178
+ * Constructs an Optional from a getter (returning Maybe<A>) and a setter.
1179
+ *
1180
+ * @example
1181
+ * ```ts
1182
+ * const firstChar = Optional.from.accessors(
1183
+ * (s: string) => s.length > 0 ? Maybe.make.some(s[0]) : Maybe.make.none(),
1184
+ * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
1185
+ * );
1186
+ * ```
1187
+ */
1188
+ const accessors: <S, A>(get: (s: S) => Maybe<A>, set: (a: A) => (s: S) => S) => Optional<S, A>;
1189
+ /**
1190
+ * Creates an Optional that focuses on an optional property of an object.
1191
+ * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
1192
+ * Call with the structure type first, then the key.
1193
+ *
1194
+ * @example
1195
+ * ```ts
1196
+ * type Profile = { username: string; bio?: string };
1197
+ * const bioOpt = Optional.from.property<Profile>()("bio");
1198
+ * ```
1199
+ */
1200
+ const property: <S>() => <K extends OptionalKeys<S>>(key: K) => Optional<S, NonNullable<S[K]>>;
1201
+ }
1186
1202
  /**
1187
1203
  * Creates an Optional that focuses on an element at a given index in an array.
1188
1204
  * Returns None when the index is out of bounds; set is a no-op when out of bounds.
@@ -1266,8 +1282,8 @@ declare namespace Optional {
1266
1282
  * @example
1267
1283
  * ```ts
1268
1284
  * const deepOpt = pipe(
1269
- * Optional.prop<User>()("address"),
1270
- * Optional.andThen(Optional.prop<Address>()("landmark")),
1285
+ * Optional.from.property<User>()("address"),
1286
+ * Optional.andThen(Optional.from.property<Address>()("landmark")),
1271
1287
  * );
1272
1288
  * ```
1273
1289
  */
@@ -1279,8 +1295,8 @@ declare namespace Optional {
1279
1295
  * @example
1280
1296
  * ```ts
1281
1297
  * const cityOpt = pipe(
1282
- * Optional.prop<User>()("address"),
1283
- * Optional.andThenLens(Lens.prop<Address>()("city")),
1298
+ * Optional.from.property<User>()("address"),
1299
+ * Optional.andThenLens(Lens.from.property<Address>()("city")),
1284
1300
  * );
1285
1301
  * ```
1286
1302
  */
@@ -1295,7 +1311,7 @@ declare namespace Optional {
1295
1311
  * Use it when you need to combine, negate, or adapt boolean checks as first-class values
1296
1312
  * and do not require the extra type information that a `Refinement` provides.
1297
1313
  *
1298
- * Every `Refinement<A, B>` is a `Predicate<A>` — convert with `Predicate.fromRefinement`
1314
+ * Every `Refinement<A, B>` is a `Predicate<A>` — convert with `Predicate.from.Refinement`
1299
1315
  * when you want to compose a narrowing check alongside plain predicates.
1300
1316
  *
1301
1317
  * @example
@@ -1424,27 +1440,31 @@ declare namespace Predicate {
1424
1440
  * ```
1425
1441
  */
1426
1442
  const any: <A>(predicates: ReadonlyArray<Predicate<A>>) => Predicate<A>;
1427
- /**
1428
- * Converts a `Refinement<A, B>` into a `Predicate<A>`, discarding the compile-time
1429
- * narrowing. Use this when you want to combine a type guard with plain predicates
1430
- * using `and`, `or`, or `all`.
1431
- *
1432
- * @example
1433
- * ```ts
1434
- * const isString: Refinement<unknown, string> =
1435
- * Refinement.make(x => typeof x === "string");
1436
- *
1437
- * const isShortString: Predicate<unknown> = pipe(
1438
- * Predicate.fromRefinement(isString),
1439
- * Predicate.and(x => (x as string).length < 10)
1440
- * );
1441
- *
1442
- * isShortString("hi"); // true
1443
- * isShortString("a very long string that exceeds ten characters"); // false
1444
- * isShortString(42); // false
1445
- * ```
1446
- */
1447
- const fromRefinement: <A, B extends A>(r: Refinement<A, B>) => Predicate<A>;
1443
+ namespace from {
1444
+ /**
1445
+ * Converts a `Refinement<A, B>` into a `Predicate<A>`, discarding the compile-time
1446
+ * narrowing. Use this when you want to combine a type guard with plain predicates
1447
+ * using `and`, `or`, or `all`.
1448
+ *
1449
+ * This is a zero-cost runtime type cast.
1450
+ *
1451
+ * @example
1452
+ * ```ts
1453
+ * const isString: Refinement<unknown, string> =
1454
+ * Refinement.from.predicate(x => typeof x === "string");
1455
+ *
1456
+ * const isShortString: Predicate<unknown> = pipe(
1457
+ * Predicate.from.Refinement(isString),
1458
+ * Predicate.and(x => (x as string).length < 10)
1459
+ * );
1460
+ *
1461
+ * isShortString("hi"); // true
1462
+ * isShortString("a very long string that exceeds ten characters"); // false
1463
+ * isShortString(42); // false
1464
+ * ```
1465
+ */
1466
+ const Refinement: <A, B extends A>(r: Refinement<A, B>) => Predicate<A>;
1467
+ }
1448
1468
  }
1449
1469
 
1450
1470
  /**
@@ -1638,33 +1658,35 @@ declare namespace Reader {
1638
1658
  * type NonEmptyString = string & { readonly _tag: "NonEmptyString" };
1639
1659
  *
1640
1660
  * const isNonEmpty: Refinement<string, NonEmptyString> =
1641
- * Refinement.make(s => s.length > 0);
1661
+ * Refinement.from.predicate(s => s.length > 0);
1642
1662
  *
1643
1663
  * pipe(
1644
1664
  * "hello",
1645
- * Refinement.toFilter(isNonEmpty)
1665
+ * Refinement.to.Maybe(isNonEmpty)
1646
1666
  * ); // Some("hello")
1647
1667
  * ```
1648
1668
  */
1649
1669
  type Refinement<A, B extends A> = (a: A) => a is B;
1650
1670
  declare namespace Refinement {
1651
- /**
1652
- * Creates a `Refinement<A, B>` from a plain boolean predicate.
1653
- *
1654
- * This is an unsafe cast — the caller is responsible for ensuring that the
1655
- * predicate truly characterises values of type `B`. Use this only when
1656
- * bootstrapping a new refinement; prefer `compose`, `and`, or `or` to build
1657
- * derived refinements from existing ones.
1658
- *
1659
- * @example
1660
- * ```ts
1661
- * type PositiveNumber = number & { readonly _tag: "PositiveNumber" };
1662
- *
1663
- * const isPositive: Refinement<number, PositiveNumber> =
1664
- * Refinement.make(n => n > 0);
1665
- * ```
1666
- */
1667
- const make: <A, B extends A>(f: (a: A) => boolean) => Refinement<A, B>;
1671
+ namespace from {
1672
+ /**
1673
+ * Creates a `Refinement<A, B>` from a plain boolean predicate.
1674
+ *
1675
+ * This is an unsafe cast the caller is responsible for ensuring that the
1676
+ * predicate truly characterises values of type `B`. Use this only when
1677
+ * bootstrapping a new refinement; prefer `compose`, `and`, or `or` to build
1678
+ * derived refinements from existing ones.
1679
+ *
1680
+ * @example
1681
+ * ```ts
1682
+ * type PositiveNumber = number & { readonly _tag: "PositiveNumber" };
1683
+ *
1684
+ * const isPositive: Refinement<number, PositiveNumber> =
1685
+ * Refinement.from.predicate(n => n > 0);
1686
+ * ```
1687
+ */
1688
+ const predicate: <A, B extends A>(f: (a: A) => boolean) => Refinement<A, B>;
1689
+ }
1668
1690
  /**
1669
1691
  * Chains two refinements: if `ab` narrows `A` to `B` and `bc` narrows `B` to `C`,
1670
1692
  * the result narrows `A` directly to `C`.
@@ -1677,9 +1699,9 @@ declare namespace Refinement {
1677
1699
  * type TrimmedString = NonEmptyString & { readonly _tag: "Trimmed" };
1678
1700
  *
1679
1701
  * const isNonEmpty: Refinement<string, NonEmptyString> =
1680
- * Refinement.make(s => s.length > 0);
1702
+ * Refinement.from.predicate(s => s.length > 0);
1681
1703
  * const isTrimmed: Refinement<NonEmptyString, TrimmedString> =
1682
- * Refinement.make(s => s === s.trim());
1704
+ * Refinement.from.predicate(s => s === s.trim());
1683
1705
  *
1684
1706
  * const isNonEmptyTrimmed: Refinement<string, TrimmedString> = pipe(
1685
1707
  * isNonEmpty,
@@ -1696,9 +1718,9 @@ declare namespace Refinement {
1696
1718
  *
1697
1719
  * @example
1698
1720
  * ```ts
1699
- * const isString: Refinement<unknown, string> = Refinement.make(x => typeof x === "string");
1721
+ * const isString: Refinement<unknown, string> = Refinement.from.predicate(x => typeof x === "string");
1700
1722
  * const isNonEmpty: Refinement<unknown, { length: number }> =
1701
- * Refinement.make(x => (x as any).length > 0);
1723
+ * Refinement.from.predicate(x => (x as any).length > 0);
1702
1724
  *
1703
1725
  * const isNonEmptyString = pipe(isString, Refinement.and(isNonEmpty));
1704
1726
  * isNonEmptyString("hi"); // true
@@ -1714,8 +1736,8 @@ declare namespace Refinement {
1714
1736
  *
1715
1737
  * @example
1716
1738
  * ```ts
1717
- * const isString: Refinement<unknown, string> = Refinement.make(x => typeof x === "string");
1718
- * const isNumber: Refinement<unknown, number> = Refinement.make(x => typeof x === "number");
1739
+ * const isString: Refinement<unknown, string> = Refinement.from.predicate(x => typeof x === "string");
1740
+ * const isNumber: Refinement<unknown, number> = Refinement.from.predicate(x => typeof x === "number");
1719
1741
  *
1720
1742
  * const isStringOrNumber = pipe(isString, Refinement.or(isNumber));
1721
1743
  * isStringOrNumber("hi"); // true
@@ -1724,40 +1746,42 @@ declare namespace Refinement {
1724
1746
  * ```
1725
1747
  */
1726
1748
  const or: <A, C extends A>(second: Refinement<A, C>) => <B extends A>(first: Refinement<A, B>) => Refinement<A, B | C>;
1727
- /**
1728
- * Converts a `Refinement<A, B>` into a function `(a: A) => Maybe<B>`.
1729
- *
1730
- * Returns `Some(a)` when the refinement holds, `None` otherwise. Useful for
1731
- * integrating runtime validation into a `Maybe`-based pipeline.
1732
- *
1733
- * @example
1734
- * ```ts
1735
- * type PositiveNumber = number & { readonly _tag: "Positive" };
1736
- * const isPositive: Refinement<number, PositiveNumber> =
1737
- * Refinement.make(n => n > 0);
1738
- *
1739
- * pipe(-1, Refinement.toFilter(isPositive)); // None
1740
- * pipe(42, Refinement.toFilter(isPositive)); // Some(42)
1741
- * ```
1742
- */
1743
- const toFilter: <A, B extends A>(r: Refinement<A, B>) => (a: A) => Maybe<B>;
1744
- /**
1745
- * Converts a `Refinement<A, B>` into a function `(a: A) => Result<E, B>`.
1746
- *
1747
- * Returns `Ok(a)` when the refinement holds, `Err(onFail(a))` otherwise. Use
1748
- * this to surface validation failures as typed errors inside a `Result` pipeline.
1749
- *
1750
- * @example
1751
- * ```ts
1752
- * type NonEmptyString = string & { readonly _tag: "NonEmpty" };
1753
- * const isNonEmpty: Refinement<string, NonEmptyString> =
1754
- * Refinement.make(s => s.length > 0);
1755
- *
1756
- * pipe("", Refinement.toResult(isNonEmpty, () => "must not be empty")); // Err(...)
1757
- * pipe("hi", Refinement.toResult(isNonEmpty, () => "must not be empty")); // Ok("hi")
1758
- * ```
1759
- */
1760
- const toResult: <A, B extends A, E>(r: Refinement<A, B>, onFail: (a: A) => E) => (a: A) => Result<E, B>;
1749
+ namespace to {
1750
+ /**
1751
+ * Converts a `Refinement<A, B>` into a function `(a: A) => Maybe<B>`.
1752
+ *
1753
+ * Returns `Some(a)` when the refinement holds, `None` otherwise. Useful for
1754
+ * integrating runtime validation into a `Maybe`-based pipeline.
1755
+ *
1756
+ * @example
1757
+ * ```ts
1758
+ * type PositiveNumber = number & { readonly _tag: "Positive" };
1759
+ * const isPositive: Refinement<number, PositiveNumber> =
1760
+ * Refinement.from.predicate(n => n > 0);
1761
+ *
1762
+ * pipe(-1, Refinement.to.Maybe(isPositive)); // None
1763
+ * pipe(42, Refinement.to.Maybe(isPositive)); // Some(42)
1764
+ * ```
1765
+ */
1766
+ const Maybe: <A, B extends A>(r: Refinement<A, B>) => (a: A) => Maybe<B>;
1767
+ /**
1768
+ * Converts a `Refinement<A, B>` into a function `(a: A) => Result<E, B>`.
1769
+ *
1770
+ * Returns `Ok(a)` when the refinement holds, `Err(onFail(a))` otherwise. Use
1771
+ * this to surface validation failures as typed errors inside a `Result` pipeline.
1772
+ *
1773
+ * @example
1774
+ * ```ts
1775
+ * type NonEmptyString = string & { readonly _tag: "NonEmpty" };
1776
+ * const isNonEmpty: Refinement<string, NonEmptyString> =
1777
+ * Refinement.from.predicate(s => s.length > 0);
1778
+ *
1779
+ * pipe("", Refinement.to.Result(isNonEmpty, () => "must not be empty")); // Err(...)
1780
+ * pipe("hi", Refinement.to.Result(isNonEmpty, () => "must not be empty")); // Ok("hi")
1781
+ * ```
1782
+ */
1783
+ const Result: <A, B extends A, E>(r: Refinement<A, B>, onFail: (a: A) => E) => (a: A) => Result<E, B>;
1784
+ }
1761
1785
  }
1762
1786
 
1763
1787
  type NotAsked = WithKind<"NotAsked">;
@@ -1786,45 +1810,49 @@ type Success<A> = WithKind<"Success"> & WithValue<A>;
1786
1810
  */
1787
1811
  type RemoteData<E, A> = NotAsked | Loading | Failure<E> | Success<A>;
1788
1812
  declare namespace RemoteData {
1789
- /**
1790
- * Creates a NotAsked RemoteData.
1791
- */
1792
- const notAsked: () => NotAsked;
1793
- /**
1794
- * Creates a Loading RemoteData.
1795
- */
1796
- const loading: () => Loading;
1797
- /**
1798
- * Creates a Failure RemoteData with the given error.
1799
- */
1800
- const failure: <E>(error: E) => Failure<E>;
1801
- /**
1802
- * Creates a Success RemoteData with the given value.
1803
- */
1804
- const success: <A>(value: A) => Success<A>;
1805
- /**
1806
- * Type guard that checks if a RemoteData is NotAsked.
1807
- */
1808
- const isNotAsked: <E, A>(data: RemoteData<E, A>) => data is NotAsked;
1809
- /**
1810
- * Type guard that checks if a RemoteData is Loading.
1811
- */
1812
- const isLoading: <E, A>(data: RemoteData<E, A>) => data is Loading;
1813
- /**
1814
- * Type guard that checks if a RemoteData is Failure.
1815
- */
1816
- const isFailure: <E, A>(data: RemoteData<E, A>) => data is Failure<E>;
1817
- /**
1818
- * Type guard that checks if a RemoteData is Success.
1819
- */
1820
- const isSuccess: <E, A>(data: RemoteData<E, A>) => data is Success<A>;
1813
+ namespace make {
1814
+ /**
1815
+ * Creates a NotAsked RemoteData.
1816
+ */
1817
+ const notAsked: () => NotAsked;
1818
+ /**
1819
+ * Creates a Loading RemoteData.
1820
+ */
1821
+ const loading: () => Loading;
1822
+ /**
1823
+ * Creates a Failure RemoteData with the given error.
1824
+ */
1825
+ const failure: <E>(error: E) => Failure<E>;
1826
+ /**
1827
+ * Creates a Success RemoteData with the given value.
1828
+ */
1829
+ const success: <A>(value: A) => Success<A>;
1830
+ }
1831
+ namespace is {
1832
+ /**
1833
+ * Type guard that checks if a RemoteData is NotAsked.
1834
+ */
1835
+ const notAsked: <E, A>(data: RemoteData<E, A>) => data is NotAsked;
1836
+ /**
1837
+ * Type guard that checks if a RemoteData is Loading.
1838
+ */
1839
+ const loading: <E, A>(data: RemoteData<E, A>) => data is Loading;
1840
+ /**
1841
+ * Type guard that checks if a RemoteData is Failure.
1842
+ */
1843
+ const failure: <E, A>(data: RemoteData<E, A>) => data is Failure<E>;
1844
+ /**
1845
+ * Type guard that checks if a RemoteData is Success.
1846
+ */
1847
+ const success: <E, A>(data: RemoteData<E, A>) => data is Success<A>;
1848
+ }
1821
1849
  /**
1822
1850
  * Transforms the success value inside a RemoteData.
1823
1851
  *
1824
1852
  * @example
1825
1853
  * ```ts
1826
- * pipe(RemoteData.success(5), RemoteData.map(n => n * 2)); // Success(10)
1827
- * pipe(RemoteData.loading(), RemoteData.map(n => n * 2)); // Loading
1854
+ * pipe(RemoteData.make.success(5), RemoteData.map(n => n * 2)); // Success(10)
1855
+ * pipe(RemoteData.make.loading(), RemoteData.map(n => n * 2)); // Loading
1828
1856
  * ```
1829
1857
  */
1830
1858
  const map: <A, B>(f: (a: A) => B) => <E>(data: RemoteData<E, A>) => RemoteData<E, B>;
@@ -1833,7 +1861,7 @@ declare namespace RemoteData {
1833
1861
  *
1834
1862
  * @example
1835
1863
  * ```ts
1836
- * pipe(RemoteData.failure("oops"), RemoteData.mapError(e => e.toUpperCase())); // Failure("OOPS")
1864
+ * pipe(RemoteData.make.failure("oops"), RemoteData.mapError(e => e.toUpperCase())); // Failure("OOPS")
1837
1865
  * ```
1838
1866
  */
1839
1867
  const mapError: <E, F>(f: (e: E) => F) => <A>(data: RemoteData<E, A>) => RemoteData<F, A>;
@@ -1844,8 +1872,8 @@ declare namespace RemoteData {
1844
1872
  * @example
1845
1873
  * ```ts
1846
1874
  * pipe(
1847
- * RemoteData.success(5),
1848
- * RemoteData.chain(n => n > 0 ? RemoteData.success(n) : RemoteData.failure("negative"))
1875
+ * RemoteData.make.success(5),
1876
+ * RemoteData.chain(n => n > 0 ? RemoteData.make.success(n) : RemoteData.make.failure("negative"))
1849
1877
  * );
1850
1878
  * ```
1851
1879
  */
@@ -1857,9 +1885,9 @@ declare namespace RemoteData {
1857
1885
  * ```ts
1858
1886
  * const add = (a: number) => (b: number) => a + b;
1859
1887
  * pipe(
1860
- * RemoteData.success(add),
1861
- * RemoteData.ap(RemoteData.success(5)),
1862
- * RemoteData.ap(RemoteData.success(3))
1888
+ * RemoteData.make.success(add),
1889
+ * RemoteData.ap(RemoteData.make.success(5)),
1890
+ * RemoteData.ap(RemoteData.make.success(3))
1863
1891
  * ); // Success(8)
1864
1892
  * ```
1865
1893
  */
@@ -1909,9 +1937,9 @@ declare namespace RemoteData {
1909
1937
  *
1910
1938
  * @example
1911
1939
  * ```ts
1912
- * pipe(RemoteData.success(5), RemoteData.getOrElse(() => 0)); // 5
1913
- * pipe(RemoteData.loading(), RemoteData.getOrElse(() => 0)); // 0
1914
- * pipe(RemoteData.loading<string, number>(), RemoteData.getOrElse(() => null)); // null — typed as number | null
1940
+ * pipe(RemoteData.make.success(5), RemoteData.getOrElse(() => 0)); // 5
1941
+ * pipe(RemoteData.make.loading(), RemoteData.getOrElse(() => 0)); // 0
1942
+ * pipe(RemoteData.make.loading<string, number>(), RemoteData.getOrElse(() => null)); // null — typed as number | null
1915
1943
  * ```
1916
1944
  */
1917
1945
  const getOrElse: <E, A, B>(defaultValue: () => B) => (data: RemoteData<E, A>) => A | B;
@@ -1921,7 +1949,7 @@ declare namespace RemoteData {
1921
1949
  * @example
1922
1950
  * ```ts
1923
1951
  * pipe(
1924
- * RemoteData.success(5),
1952
+ * RemoteData.make.success(5),
1925
1953
  * RemoteData.tap(n => console.log("Value:", n)),
1926
1954
  * RemoteData.map(n => n * 2)
1927
1955
  * );
@@ -1935,7 +1963,7 @@ declare namespace RemoteData {
1935
1963
  * @example
1936
1964
  * ```ts
1937
1965
  * pipe(
1938
- * RemoteData.failure("not found"),
1966
+ * RemoteData.make.failure("not found"),
1939
1967
  * RemoteData.tapError(e => console.error("fetch failed:", e)),
1940
1968
  * RemoteData.map(render)
1941
1969
  * );
@@ -1947,58 +1975,62 @@ declare namespace RemoteData {
1947
1975
  * The fallback can produce a different success type, widening the result to `RemoteData<E, A | B>`.
1948
1976
  */
1949
1977
  const recover: <E, A, B>(fallback: (e: E) => RemoteData<E, B>) => (data: RemoteData<E, A>) => RemoteData<E, A | B>;
1950
- /**
1951
- * Converts a RemoteData to a Maybe.
1952
- * Success becomes Some, all other states become None.
1953
- */
1954
- const toMaybe: <E, A>(data: RemoteData<E, A>) => Maybe<A>;
1955
- /**
1956
- * Converts a RemoteData to a Result.
1957
- * Success becomes Ok, Failure becomes Err.
1958
- * NotAsked and Loading become Err with the provided fallback error.
1959
- *
1960
- * @example
1961
- * ```ts
1962
- * pipe(
1963
- * RemoteData.success(42),
1964
- * RemoteData.toResult(() => "not loaded")
1965
- * ); // Ok(42)
1966
- * ```
1967
- */
1968
- const toResult: <E>(onNotReady: () => E) => <A>(data: RemoteData<E, A>) => Result<E, A>;
1969
- /**
1970
- * Converts a Result to a RemoteData.
1971
- * Ok becomes Success, Err becomes Failure.
1972
- *
1973
- * @example
1974
- * ```ts
1975
- * const result = await Task.Result.tryCatch(fetchUser, String)();
1976
- * setState(RemoteData.fromResult(result)); // Success(user) or Failure(msg)
1977
- * ```
1978
- */
1979
- const fromResult: <E, A>(data: Result<E, A>) => RemoteData<E, A>;
1980
- /**
1981
- * Converts a Maybe to a RemoteData.
1982
- * Some becomes Success, None becomes Failure using the onNone error producer.
1983
- *
1984
- * @example
1985
- * ```ts
1986
- * pipe(Maybe.some(user), RemoteData.fromMaybe(() => "not found")); // Success(user)
1987
- * pipe(Maybe.none(), RemoteData.fromMaybe(() => "not found")); // Failure("not found")
1988
- * ```
1989
- */
1990
- const fromMaybe: <E>(onNone: () => E) => <A>(data: Maybe<A>) => RemoteData<E, A>;
1978
+ namespace to {
1979
+ /**
1980
+ * Converts a RemoteData to a Maybe.
1981
+ * Success becomes Some, all other states become None.
1982
+ */
1983
+ const Maybe: <E, A>(data: RemoteData<E, A>) => Maybe<A>;
1984
+ /**
1985
+ * Converts a RemoteData to a Result.
1986
+ * Success becomes Ok, Failure becomes Err.
1987
+ * NotAsked and Loading become Err with the provided fallback error.
1988
+ *
1989
+ * @example
1990
+ * ```ts
1991
+ * pipe(
1992
+ * RemoteData.make.success(42),
1993
+ * RemoteData.to.Result(() => "not loaded")
1994
+ * ); // Ok(42)
1995
+ * ```
1996
+ */
1997
+ const Result: <E>(onNotReady: () => E) => <A>(data: RemoteData<E, A>) => Result<E, A>;
1998
+ }
1999
+ namespace from {
2000
+ /**
2001
+ * Converts a Result to a RemoteData.
2002
+ * Ok becomes Success, Err becomes Failure.
2003
+ *
2004
+ * @example
2005
+ * ```ts
2006
+ * const result = await Task.Result.tryCatch(fetchUser, String)();
2007
+ * setState(RemoteData.from.Result(result)); // Success(user) or Failure(msg)
2008
+ * ```
2009
+ */
2010
+ const Result: <E, A>(data: Result<E, A>) => RemoteData<E, A>;
2011
+ /**
2012
+ * Converts a Maybe to a RemoteData.
2013
+ * Some becomes Success, None becomes Failure using the onNone error producer.
2014
+ *
2015
+ * @example
2016
+ * ```ts
2017
+ * pipe(Maybe.make.some(user), RemoteData.from.Maybe(() => "not found")); // Success(user)
2018
+ * pipe(Maybe.make.none(), RemoteData.from.Maybe(() => "not found")); // Failure("not found")
2019
+ * ```
2020
+ */
2021
+ const Maybe: <E>(onNone: () => E) => <A>(data: Maybe<A>) => RemoteData<E, A>;
2022
+ }
1991
2023
  /**
1992
2024
  * Filters a `Success` value. When the predicate passes, the value is kept. When it fails,
1993
2025
  * `Success` becomes `Failure` using the error produced by `onFalse`. All other states pass through unchanged.
1994
2026
  *
1995
2027
  * @example
1996
2028
  * ```ts
1997
- * RemoteData.filter(n => n > 0, n => `${n} is not a valid price`)(RemoteData.success(9.99));
2029
+ * RemoteData.filter(n => n > 0, n => `${n} is not a valid price`)(RemoteData.make.success(9.99));
1998
2030
  * // Success(9.99)
1999
- * RemoteData.filter(n => n > 0, n => `${n} is not a valid price`)(RemoteData.success(-1));
2031
+ * RemoteData.filter(n => n > 0, n => `${n} is not a valid price`)(RemoteData.make.success(-1));
2000
2032
  * // Failure("-1 is not a valid price")
2001
- * RemoteData.filter(n => n > 0, () => "error")(RemoteData.loading()); // Loading
2033
+ * RemoteData.filter(n => n > 0, () => "error")(RemoteData.make.loading()); // Loading
2002
2034
  * ```
2003
2035
  */
2004
2036
  const filter: <E, A>(pred: (a: A) => boolean, onFalse: (a: A) => E) => (data: RemoteData<E, A>) => RemoteData<E, A>;
@@ -2015,14 +2047,14 @@ declare namespace RemoteData {
2015
2047
  * the work function returns an error. If `acquire` itself fails, `release` is
2016
2048
  * skipped — there is nothing to clean up.
2017
2049
  *
2018
- * Build a Resource with `Resource.make` or `Resource.fromTask`, then run it
2050
+ * Build a Resource with `Resource.from.handlers` or `Resource.from.Task`, then run it
2019
2051
  * with `Resource.use`.
2020
2052
  *
2021
2053
  * @example
2022
2054
  * ```ts
2023
- * const dbResource = Resource.make(
2055
+ * const dbResource = Resource.from.handlers(
2024
2056
  * Task.Result.tryCatch(() => openConnection(config), (e) => new DbError(e)),
2025
- * (conn) => Task.from(() => conn.close())
2057
+ * (conn) => Task.from.Promise(() => conn.close())
2026
2058
  * );
2027
2059
  *
2028
2060
  * const result = await pipe(
@@ -2037,32 +2069,34 @@ type Resource<E, A> = {
2037
2069
  readonly release: (a: A) => Task<void>;
2038
2070
  };
2039
2071
  declare namespace Resource {
2040
- /**
2041
- * Creates a Resource from an acquire operation that may fail and a release function.
2042
- *
2043
- * @example
2044
- * ```ts
2045
- * const fileResource = Resource.make(
2046
- * Task.Result.tryCatch(() => fs.promises.open("data.csv", "r"), toFileError),
2047
- * (handle) => Task.from(() => handle.close())
2048
- * );
2049
- * ```
2050
- */
2051
- const make: <E, A>(acquire: Task.Result<E, A>, release: (a: A) => Task<void>) => Resource<E, A>;
2052
- /**
2053
- * Creates a Resource from an acquire operation that cannot fail.
2054
- * Use this when opening the resource is guaranteed to succeed, such as
2055
- * in-memory locks, counters, or timers.
2056
- *
2057
- * @example
2058
- * ```ts
2059
- * const timerResource = Resource.fromTask<never, Timer>(
2060
- * Task.from(() => Promise.resolve(startTimer())),
2061
- * (timer) => Task.from(() => Promise.resolve(timer.stop()))
2062
- * );
2063
- * ```
2064
- */
2065
- const fromTask: <E, A>(acquire: Task<A>, release: (a: A) => Task<void>) => Resource<E, A>;
2072
+ namespace from {
2073
+ /**
2074
+ * Creates a Resource from an acquire operation that may fail and a release function.
2075
+ *
2076
+ * @example
2077
+ * ```ts
2078
+ * const fileResource = Resource.from.handlers(
2079
+ * Task.Result.tryCatch(() => fs.promises.open("data.csv", "r"), toFileError),
2080
+ * (handle) => Task.from.Promise(() => handle.close())
2081
+ * );
2082
+ * ```
2083
+ */
2084
+ const handlers: <E, A>(acquire: Task.Result<E, A>, release: (a: A) => Task<void>) => Resource<E, A>;
2085
+ /**
2086
+ * Creates a Resource from an acquire operation that cannot fail.
2087
+ * Use this when opening the resource is guaranteed to succeed, such as
2088
+ * in-memory locks, counters, or timers.
2089
+ *
2090
+ * @example
2091
+ * ```ts
2092
+ * const timerResource = Resource.from.Task<never, Timer>(
2093
+ * Task.from.Promise(() => Promise.resolve(startTimer())),
2094
+ * (timer) => Task.from.Promise(() => Promise.resolve(timer.stop()))
2095
+ * );
2096
+ * ```
2097
+ */
2098
+ const Task: <E, A>(acquire: Task<A>, release: (a: A) => Task<void>) => Resource<E, A>;
2099
+ }
2066
2100
  /**
2067
2101
  * Acquires the resource, runs `f` with it, then releases it.
2068
2102
  *
@@ -2332,53 +2366,57 @@ type TheseBoth<First, Second> = WithKind<"Both"> & WithFirst<First> & WithSecond
2332
2366
  * const parse = (s: string): These<number, string> => {
2333
2367
  * const trimmed = s.trim();
2334
2368
  * const n = parseFloat(trimmed);
2335
- * if (isNaN(n)) return These.second("Not a number");
2336
- * if (s !== trimmed) return These.both(n, "Leading/trailing whitespace trimmed");
2337
- * return These.first(n);
2369
+ * if (isNaN(n)) return These.make.second("Not a number");
2370
+ * if (s !== trimmed) return These.make.both(n, "Leading/trailing whitespace trimmed");
2371
+ * return These.make.first(n);
2338
2372
  * };
2339
2373
  * ```
2340
2374
  */
2341
2375
  type These<A, B> = TheseFirst<A> | TheseSecond<B> | TheseBoth<A, B>;
2342
2376
  declare namespace These {
2343
- /**
2344
- * Creates a These holding only a first value.
2345
- *
2346
- * @example
2347
- * ```ts
2348
- * These.first(42); // { kind: "First", first: 42 }
2349
- * ```
2350
- */
2351
- const first: <A>(value: A) => TheseFirst<A>;
2352
- /**
2353
- * Creates a These holding only a second value.
2354
- *
2355
- * @example
2356
- * ```ts
2357
- * These.second("warning"); // { kind: "Second", second: "warning" }
2358
- * ```
2359
- */
2360
- const second: <B>(value: B) => TheseSecond<B>;
2361
- /**
2362
- * Creates a These holding both a first and a second value simultaneously.
2363
- *
2364
- * @example
2365
- * ```ts
2366
- * These.both(42, "Deprecated API used"); // { kind: "Both", first: 42, second: "Deprecated API used" }
2367
- * ```
2368
- */
2369
- const both: <A, B>(f: A, s: B) => TheseBoth<A, B>;
2370
- /**
2371
- * Type guard — checks if a These holds only a first value.
2372
- */
2373
- const isFirst: <A, B>(data: These<A, B>) => data is TheseFirst<A>;
2374
- /**
2375
- * Type guard — checks if a These holds only a second value.
2376
- */
2377
- const isSecond: <A, B>(data: These<A, B>) => data is TheseSecond<B>;
2378
- /**
2379
- * Type guard — checks if a These holds both values simultaneously.
2380
- */
2381
- const isBoth: <A, B>(data: These<A, B>) => data is TheseBoth<A, B>;
2377
+ namespace make {
2378
+ /**
2379
+ * Creates a These holding only a first value.
2380
+ *
2381
+ * @example
2382
+ * ```ts
2383
+ * These.make.first(42); // { kind: "First", first: 42 }
2384
+ * ```
2385
+ */
2386
+ const first: <A>(value: A) => TheseFirst<A>;
2387
+ /**
2388
+ * Creates a These holding only a second value.
2389
+ *
2390
+ * @example
2391
+ * ```ts
2392
+ * These.make.second("warning"); // { kind: "Second", second: "warning" }
2393
+ * ```
2394
+ */
2395
+ const second: <B>(value: B) => TheseSecond<B>;
2396
+ /**
2397
+ * Creates a These holding both a first and a second value simultaneously.
2398
+ *
2399
+ * @example
2400
+ * ```ts
2401
+ * These.make.both(42, "Deprecated API used"); // { kind: "Both", first: 42, second: "Deprecated API used" }
2402
+ * ```
2403
+ */
2404
+ const both: <A, B>(f: A, s: B) => TheseBoth<A, B>;
2405
+ }
2406
+ namespace is {
2407
+ /**
2408
+ * Type guard — checks if a These holds only a first value.
2409
+ */
2410
+ const first: <A, B>(data: These<A, B>) => data is TheseFirst<A>;
2411
+ /**
2412
+ * Type guard — checks if a These holds only a second value.
2413
+ */
2414
+ const second: <A, B>(data: These<A, B>) => data is TheseSecond<B>;
2415
+ /**
2416
+ * Type guard — checks if a These holds both values simultaneously.
2417
+ */
2418
+ const both: <A, B>(data: These<A, B>) => data is TheseBoth<A, B>;
2419
+ }
2382
2420
  /**
2383
2421
  * Returns true if the These contains a first value (First or Both).
2384
2422
  */
@@ -2392,9 +2430,9 @@ declare namespace These {
2392
2430
  *
2393
2431
  * @example
2394
2432
  * ```ts
2395
- * pipe(These.first(5), These.mapFirst(n => n * 2)); // First(10)
2396
- * pipe(These.both(5, "warn"), These.mapFirst(n => n * 2)); // Both(10, "warn")
2397
- * pipe(These.second("warn"), These.mapFirst(n => n * 2)); // Second("warn")
2433
+ * pipe(These.make.first(5), These.mapFirst(n => n * 2)); // First(10)
2434
+ * pipe(These.make.both(5, "warn"), These.mapFirst(n => n * 2)); // Both(10, "warn")
2435
+ * pipe(These.make.second("warn"), These.mapFirst(n => n * 2)); // Second("warn")
2398
2436
  * ```
2399
2437
  */
2400
2438
  const mapFirst: <A, C>(f: (a: A) => C) => <B>(data: These<A, B>) => These<C, B>;
@@ -2403,8 +2441,8 @@ declare namespace These {
2403
2441
  *
2404
2442
  * @example
2405
2443
  * ```ts
2406
- * pipe(These.second("warn"), These.mapSecond(e => e.toUpperCase())); // Second("WARN")
2407
- * pipe(These.both(5, "warn"), These.mapSecond(e => e.toUpperCase())); // Both(5, "WARN")
2444
+ * pipe(These.make.second("warn"), These.mapSecond(e => e.toUpperCase())); // Second("WARN")
2445
+ * pipe(These.make.both(5, "warn"), These.mapSecond(e => e.toUpperCase())); // Both(5, "WARN")
2408
2446
  * ```
2409
2447
  */
2410
2448
  const mapSecond: <B, D>(f: (b: B) => D) => <A>(data: These<A, B>) => These<A, D>;
@@ -2414,7 +2452,7 @@ declare namespace These {
2414
2452
  * @example
2415
2453
  * ```ts
2416
2454
  * pipe(
2417
- * These.both(5, "warn"),
2455
+ * These.make.both(5, "warn"),
2418
2456
  * These.mapBoth(n => n * 2, e => e.toUpperCase())
2419
2457
  * ); // Both(10, "WARN")
2420
2458
  * ```
@@ -2426,11 +2464,11 @@ declare namespace These {
2426
2464
  *
2427
2465
  * @example
2428
2466
  * ```ts
2429
- * const double = (n: number): These<number, string> => These.first(n * 2);
2467
+ * const double = (n: number): These<number, string> => These.make.first(n * 2);
2430
2468
  *
2431
- * pipe(These.first(5), These.chainFirst(double)); // First(10)
2432
- * pipe(These.both(5, "warn"), These.chainFirst(double)); // First(10)
2433
- * pipe(These.second("warn"), These.chainFirst(double)); // Second("warn")
2469
+ * pipe(These.make.first(5), These.chainFirst(double)); // First(10)
2470
+ * pipe(These.make.both(5, "warn"), These.chainFirst(double)); // First(10)
2471
+ * pipe(These.make.second("warn"), These.chainFirst(double)); // Second("warn")
2434
2472
  * ```
2435
2473
  */
2436
2474
  const chainFirst: <A, B, C>(f: (a: A) => These<C, B>) => (data: These<A, B>) => These<C, B>;
@@ -2440,11 +2478,11 @@ declare namespace These {
2440
2478
  *
2441
2479
  * @example
2442
2480
  * ```ts
2443
- * const shout = (s: string): These<number, string> => These.second(s.toUpperCase());
2481
+ * const shout = (s: string): These<number, string> => These.make.second(s.toUpperCase());
2444
2482
  *
2445
- * pipe(These.second("warn"), These.chainSecond(shout)); // Second("WARN")
2446
- * pipe(These.both(5, "warn"), These.chainSecond(shout)); // Second("WARN")
2447
- * pipe(These.first(5), These.chainSecond(shout)); // First(5)
2483
+ * pipe(These.make.second("warn"), These.chainSecond(shout)); // Second("WARN")
2484
+ * pipe(These.make.both(5, "warn"), These.chainSecond(shout)); // Second("WARN")
2485
+ * pipe(These.make.first(5), These.chainSecond(shout)); // First(5)
2448
2486
  * ```
2449
2487
  */
2450
2488
  const chainSecond: <A, B, D>(f: (b: B) => These<A, D>) => (data: These<A, B>) => These<A, D>;
@@ -2490,10 +2528,10 @@ declare namespace These {
2490
2528
  *
2491
2529
  * @example
2492
2530
  * ```ts
2493
- * pipe(These.first(5), These.getFirstOrElse(() => 0)); // 5
2494
- * pipe(These.both(5, "warn"), These.getFirstOrElse(() => 0)); // 5
2495
- * pipe(These.second("warn"), These.getFirstOrElse(() => 0)); // 0
2496
- * pipe(These.second("warn"), These.getFirstOrElse(() => null)); // null — typed as number | null
2531
+ * pipe(These.make.first(5), These.getFirstOrElse(() => 0)); // 5
2532
+ * pipe(These.make.both(5, "warn"), These.getFirstOrElse(() => 0)); // 5
2533
+ * pipe(These.make.second("warn"), These.getFirstOrElse(() => 0)); // 0
2534
+ * pipe(These.make.second("warn"), These.getFirstOrElse(() => null)); // null — typed as number | null
2497
2535
  * ```
2498
2536
  */
2499
2537
  const getFirstOrElse: <A, C>(defaultValue: () => C) => <B>(data: These<A, B>) => A | C;
@@ -2503,20 +2541,20 @@ declare namespace These {
2503
2541
  *
2504
2542
  * @example
2505
2543
  * ```ts
2506
- * pipe(These.second("warn"), These.getSecondOrElse(() => "none")); // "warn"
2507
- * pipe(These.both(5, "warn"), These.getSecondOrElse(() => "none")); // "warn"
2508
- * pipe(These.first(5), These.getSecondOrElse(() => "none")); // "none"
2509
- * pipe(These.first(5), These.getSecondOrElse(() => null)); // null — typed as string | null
2544
+ * pipe(These.make.second("warn"), These.getSecondOrElse(() => "none")); // "warn"
2545
+ * pipe(These.make.both(5, "warn"), These.getSecondOrElse(() => "none")); // "warn"
2546
+ * pipe(These.make.first(5), These.getSecondOrElse(() => "none")); // "none"
2547
+ * pipe(These.make.first(5), These.getSecondOrElse(() => null)); // null — typed as string | null
2510
2548
  * ```
2511
2549
  */
2512
2550
  const getSecondOrElse: <B, D>(defaultValue: () => D) => <A>(data: These<A, B>) => B | D;
2513
2551
  /**
2514
- * Executes a side effect on the first value without changing the These.
2552
+ * Runs a side effect on the first value without changing the These.
2515
2553
  * Useful for logging or debugging.
2516
2554
  *
2517
2555
  * @example
2518
2556
  * ```ts
2519
- * pipe(These.first(5), These.tap(console.log)); // logs 5, returns First(5)
2557
+ * pipe(These.make.first(5), These.tap(console.log)); // logs 5, returns First(5)
2520
2558
  * ```
2521
2559
  */
2522
2560
  const tap: <A>(f: (a: A) => void) => <B>(data: These<A, B>) => These<A, B>;
@@ -2528,9 +2566,9 @@ declare namespace These {
2528
2566
  *
2529
2567
  * @example
2530
2568
  * ```ts
2531
- * These.swap(These.first(5)); // Second(5)
2532
- * These.swap(These.second("warn")); // First("warn")
2533
- * These.swap(These.both(5, "warn")); // Both("warn", 5)
2569
+ * These.swap(These.make.first(5)); // Second(5)
2570
+ * These.swap(These.make.second("warn")); // First("warn")
2571
+ * These.swap(These.make.both(5, "warn")); // Both("warn", 5)
2534
2572
  * ```
2535
2573
  */
2536
2574
  const swap: <A, B>(data: These<A, B>) => These<B, A>;
@@ -2548,7 +2586,7 @@ declare namespace These {
2548
2586
  * import { Tuple } from "@nlozgachev/pipelined/core";
2549
2587
  * import { pipe } from "@nlozgachev/pipelined/composition";
2550
2588
  *
2551
- * const entry = Tuple.make("alice", 42);
2589
+ * const entry = Tuple.from.pair("alice", 42);
2552
2590
  *
2553
2591
  * pipe(
2554
2592
  * entry,
@@ -2560,21 +2598,32 @@ declare namespace These {
2560
2598
  */
2561
2599
  type Tuple<A, B> = readonly [A, B];
2562
2600
  declare namespace Tuple {
2563
- /**
2564
- * Creates a pair from two values.
2565
- *
2566
- * @example
2567
- * ```ts
2568
- * Tuple.make("Paris", 2_161_000); // ["Paris", 2161000]
2569
- * ```
2570
- */
2571
- const make: <A, B>(first: A, second: B) => Tuple<A, B>;
2601
+ namespace from {
2602
+ /**
2603
+ * Creates a pair from two values.
2604
+ *
2605
+ * @example
2606
+ * ```ts
2607
+ * Tuple.from.pair("Paris", 2_161_000); // ["Paris", 2161000]
2608
+ * ```
2609
+ */
2610
+ const pair: <A, B>(first: A, second: B) => Tuple<A, B>;
2611
+ /**
2612
+ * Creates a Tuple from a two-element array.
2613
+ *
2614
+ * @example
2615
+ * ```ts
2616
+ * Tuple.from.array(["Paris", 2_161_000] as const); // ["Paris", 2161000]
2617
+ * ```
2618
+ */
2619
+ const array: <A, B>(arr: readonly [A, B]) => Tuple<A, B>;
2620
+ }
2572
2621
  /**
2573
2622
  * Returns the first value from the pair.
2574
2623
  *
2575
2624
  * @example
2576
2625
  * ```ts
2577
- * Tuple.first(Tuple.make("Paris", 2_161_000)); // "Paris"
2626
+ * Tuple.first(Tuple.from.pair("Paris", 2_161_000)); // "Paris"
2578
2627
  * ```
2579
2628
  */
2580
2629
  const first: <A, B>(tuple: Tuple<A, B>) => A;
@@ -2583,7 +2632,7 @@ declare namespace Tuple {
2583
2632
  *
2584
2633
  * @example
2585
2634
  * ```ts
2586
- * Tuple.second(Tuple.make("Paris", 2_161_000)); // 2161000
2635
+ * Tuple.second(Tuple.from.pair("Paris", 2_161_000)); // 2161000
2587
2636
  * ```
2588
2637
  */
2589
2638
  const second: <A, B>(tuple: Tuple<A, B>) => B;
@@ -2592,7 +2641,7 @@ declare namespace Tuple {
2592
2641
  *
2593
2642
  * @example
2594
2643
  * ```ts
2595
- * pipe(Tuple.make("alice", 42), Tuple.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
2644
+ * pipe(Tuple.from.pair("alice", 42), Tuple.mapFirst((s) => s.toUpperCase())); // ["ALICE", 42]
2596
2645
  * ```
2597
2646
  */
2598
2647
  const mapFirst: <A, C>(f: (a: A) => C) => <B>(tuple: Tuple<A, B>) => Tuple<C, B>;
@@ -2601,7 +2650,7 @@ declare namespace Tuple {
2601
2650
  *
2602
2651
  * @example
2603
2652
  * ```ts
2604
- * pipe(Tuple.make("alice", 42), Tuple.mapSecond((n) => n * 2)); // ["alice", 84]
2653
+ * pipe(Tuple.from.pair("alice", 42), Tuple.mapSecond((n) => n * 2)); // ["alice", 84]
2605
2654
  * ```
2606
2655
  */
2607
2656
  const mapSecond: <B, D>(f: (b: B) => D) => <A>(tuple: Tuple<A, B>) => Tuple<A, D>;
@@ -2611,7 +2660,7 @@ declare namespace Tuple {
2611
2660
  * @example
2612
2661
  * ```ts
2613
2662
  * pipe(
2614
- * Tuple.make("alice", 42),
2663
+ * Tuple.from.pair("alice", 42),
2615
2664
  * Tuple.mapBoth(
2616
2665
  * (name) => name.toUpperCase(),
2617
2666
  * (score) => score * 2,
@@ -2626,7 +2675,7 @@ declare namespace Tuple {
2626
2675
  *
2627
2676
  * @example
2628
2677
  * ```ts
2629
- * pipe(Tuple.make("Alice", 100), Tuple.fold((name, score) => `${name}: ${score}`));
2678
+ * pipe(Tuple.from.pair("Alice", 100), Tuple.fold((name, score) => `${name}: ${score}`));
2630
2679
  * // "Alice: 100"
2631
2680
  * ```
2632
2681
  */
@@ -2636,19 +2685,21 @@ declare namespace Tuple {
2636
2685
  *
2637
2686
  * @example
2638
2687
  * ```ts
2639
- * Tuple.swap(Tuple.make("key", 1)); // [1, "key"]
2688
+ * Tuple.swap(Tuple.from.pair("key", 1)); // [1, "key"]
2640
2689
  * ```
2641
2690
  */
2642
2691
  const swap: <A, B>(tuple: Tuple<A, B>) => Tuple<B, A>;
2643
- /**
2644
- * Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
2645
- *
2646
- * @example
2647
- * ```ts
2648
- * Tuple.toArray(Tuple.make("hello", 42)); // ["hello", 42]
2649
- * ```
2650
- */
2651
- const toArray: <A, B>(tuple: Tuple<A, B>) => readonly (A | B)[];
2692
+ namespace to {
2693
+ /**
2694
+ * Converts the pair to a heterogeneous readonly array `readonly (A | B)[]`.
2695
+ *
2696
+ * @example
2697
+ * ```ts
2698
+ * Tuple.to.Array(Tuple.from.pair("hello", 42)); // ["hello", 42]
2699
+ * ```
2700
+ */
2701
+ const Array: <A, B>(tuple: Tuple<A, B>) => readonly (A | B)[];
2702
+ }
2652
2703
  /**
2653
2704
  * Runs a side effect with both values without changing the pair.
2654
2705
  * Useful for logging or debugging in the middle of a pipeline.
@@ -2656,7 +2707,7 @@ declare namespace Tuple {
2656
2707
  * @example
2657
2708
  * ```ts
2658
2709
  * pipe(
2659
- * Tuple.make("Paris", 2_161_000),
2710
+ * Tuple.from.pair("Paris", 2_161_000),
2660
2711
  * Tuple.tap((city, pop) => console.log(`${city}: ${pop}`)),
2661
2712
  * Tuple.mapSecond((n) => n / 1_000_000),
2662
2713
  * ); // logs "Paris: 2161000", returns ["Paris", 2.161]