@satoshibits/functional 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,444 @@
1
+ "use strict";
2
+ /**
3
+ * @module reader
4
+ * @description Reader represents a computation with access to a shared environment/context.
5
+ * The Reader monad provides a way to compose functions that all depend on some shared
6
+ * configuration or dependency injection context, without having to pass it explicitly
7
+ * through every function call.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Reader } from './reader.mts';
12
+ *
13
+ * // basic usage
14
+ * type Config = { apiUrl: string; timeout: number };
15
+ *
16
+ * const getApiUrl: Reader<Config, string> = config => config.apiUrl;
17
+ * const getTimeout: Reader<Config, number> = config => config.timeout;
18
+ *
19
+ * // composing readers
20
+ * const buildRequest = Reader.chain((url: string) =>
21
+ * Reader.map((timeout: number) => ({ url, timeout }))(getTimeout)
22
+ * )(getApiUrl);
23
+ *
24
+ * // running readers
25
+ * const config: Config = { apiUrl: 'https://api.example.com', timeout: 5000 };
26
+ * const request = Reader.run(config)(buildRequest);
27
+ * // => { url: 'https://api.example.com', timeout: 5000 }
28
+ * ```
29
+ *
30
+ * @category Core
31
+ * @since 2025-09-18
32
+ */
33
+ /**
34
+ * Reader utility functions for working with Reader types.
35
+ * @description Provides a functional API for creating, transforming, and composing Readers.
36
+ * All functions are curried to support functional composition and partial application.
37
+ *
38
+ * @category Utilities
39
+ * @since 2025-09-18
40
+ */
41
+ export var Reader = {
42
+ /**
43
+ * Creates a Reader that returns the given value, ignoring the environment.
44
+ * @description Factory function for creating Readers from values. The resulting
45
+ * Reader will always return the provided value regardless of the environment.
46
+ *
47
+ * @template R - The type of the environment
48
+ * @template A - The type of the value
49
+ * @param {A} value - The value to wrap in a Reader
50
+ * @returns {Reader<R, A>} A Reader that returns the value
51
+ *
52
+ * @category Constructors
53
+ * @example
54
+ * ```typescript
55
+ * const reader = Reader.of<Config, number>(42);
56
+ * Reader.run(config)(reader); // => 42
57
+ *
58
+ * // Useful for starting chains
59
+ * const result = Reader.run(config)(
60
+ * Reader.chain((n: number) => Reader.of<Config, number>(n * 2))(
61
+ * Reader.of<Config, number>(21)
62
+ * )
63
+ * ); // => 42
64
+ * ```
65
+ *
66
+ * @since 2025-09-18
67
+ */
68
+ of: function (value) { return function () { return value; }; },
69
+ /**
70
+ * Gets the current environment.
71
+ * @description Returns a Reader that provides access to the entire environment.
72
+ * This is the identity Reader for the environment type.
73
+ *
74
+ * @template R - The type of the environment
75
+ * @returns {Reader<R, R>} A Reader that returns the environment
76
+ *
77
+ * @category Environment
78
+ * @example
79
+ * ```typescript
80
+ * type Config = { port: number; host: string };
81
+ * const config: Config = { port: 3000, host: 'localhost' };
82
+ *
83
+ * const getConfig = Reader.ask<Config>();
84
+ * Reader.run(config)(getConfig); // => { port: 3000, host: 'localhost' }
85
+ * ```
86
+ *
87
+ * @since 2025-09-18
88
+ */
89
+ ask: function () { return function (deps) { return deps; }; },
90
+ /**
91
+ * Gets a value derived from the environment.
92
+ * @description Projects a value from the environment using a selector function.
93
+ * Useful for extracting specific parts of the environment.
94
+ *
95
+ * @template R - The type of the environment
96
+ * @template A - The type of the extracted value
97
+ * @param {function(R): A} f - Function to extract value from environment
98
+ * @returns {Reader<R, A>} A Reader that returns the extracted value
99
+ *
100
+ * @category Environment
101
+ * @example
102
+ * ```typescript
103
+ * type Config = { db: { host: string; port: number } };
104
+ *
105
+ * const getDbHost = Reader.asks<Config, string>(config => config.db.host);
106
+ * const config: Config = { db: { host: 'localhost', port: 5432 } };
107
+ * Reader.run(config)(getDbHost); // => 'localhost'
108
+ * ```
109
+ *
110
+ * @since 2025-09-18
111
+ */
112
+ asks: function (f) { return f; },
113
+ /**
114
+ * Transforms the value inside a Reader using the given function.
115
+ * @description Applies a pure function to the value produced by a Reader,
116
+ * creating a new Reader with the transformed value. This is the functor
117
+ * map operation for Reader types.
118
+ *
119
+ * @template R - The environment type
120
+ * @template A - The input type
121
+ * @template B - The output type
122
+ * @param {function(A): B} f - Function to transform the value
123
+ * @returns {function(Reader<R, A>): Reader<R, B>} A function that transforms Readers
124
+ *
125
+ * @category Transformations
126
+ * @example
127
+ * ```typescript
128
+ * type Config = { multiplier: number };
129
+ * const getValue: Reader<Config, number> = config => 10 * config.multiplier;
130
+ *
131
+ * const double = Reader.map((n: number) => n * 2);
132
+ * const doubled = double(getValue);
133
+ *
134
+ * const config: Config = { multiplier: 3 };
135
+ * Reader.run(config)(doubled); // => 60
136
+ * ```
137
+ *
138
+ * @since 2025-09-18
139
+ */
140
+ map: function (f) { return function (reader) {
141
+ return function (deps) { return f(reader(deps)); };
142
+ }; },
143
+ /**
144
+ * Chains Reader-returning operations.
145
+ * @description Sequences two Readers where the second depends on the result
146
+ * of the first. This is the monadic bind operation for Reader types.
147
+ *
148
+ * @template R - The environment type
149
+ * @template A - The input type
150
+ * @template B - The output type
151
+ * @param {function(A): Reader<R, B>} f - Function that returns a new Reader
152
+ * @returns {function(Reader<R, A>): Reader<R, B>} A function that chains Readers
153
+ *
154
+ * @category Combinators
155
+ * @example
156
+ * ```typescript
157
+ * type Config = { baseUrl: string; apiKey: string };
158
+ *
159
+ * const getBaseUrl: Reader<Config, string> = config => config.baseUrl;
160
+ * const buildEndpoint = (base: string): Reader<Config, string> =>
161
+ * config => `${base}/api?key=${config.apiKey}`;
162
+ *
163
+ * const getEndpoint = Reader.chain(buildEndpoint)(getBaseUrl);
164
+ *
165
+ * const config: Config = { baseUrl: 'https://api.com', apiKey: 'secret' };
166
+ * Reader.run(config)(getEndpoint); // => 'https://api.com/api?key=secret'
167
+ * ```
168
+ *
169
+ * @since 2025-09-18
170
+ */
171
+ chain: function (f) { return function (reader) {
172
+ return function (deps) { return f(reader(deps))(deps); };
173
+ }; },
174
+ /**
175
+ * Alias for chain to match fp-ts naming.
176
+ * @description See {@link chain} for details.
177
+ *
178
+ * @category Combinators
179
+ * @since 2025-09-18
180
+ */
181
+ flatMap: function (f) { return function (reader) {
182
+ return function (deps) { return f(reader(deps))(deps); };
183
+ }; },
184
+ /**
185
+ * Applies a Reader of a function to a Reader of a value.
186
+ * @description Enables applying functions wrapped in Readers to values wrapped
187
+ * in Readers. This is the applicative apply operation for Reader types.
188
+ *
189
+ * @template R - The environment type
190
+ * @template A - The input type
191
+ * @template B - The output type
192
+ * @param {Reader<R, A>} readerValue - Reader containing a value
193
+ * @returns {function(Reader<R, function(A): B>): Reader<R, B>} A function that applies Reader functions
194
+ *
195
+ * @category Combinators
196
+ * @example
197
+ * ```typescript
198
+ * type Config = { x: number; y: number };
199
+ *
200
+ * const add = (a: number) => (b: number) => a + b;
201
+ * const getX: Reader<Config, number> = config => config.x;
202
+ * const getY: Reader<Config, number> = config => config.y;
203
+ *
204
+ * const sum = Reader.ap(getY)(
205
+ * Reader.map(add)(getX)
206
+ * );
207
+ *
208
+ * const config: Config = { x: 5, y: 3 };
209
+ * Reader.run(config)(sum); // => 8
210
+ * ```
211
+ *
212
+ * @since 2025-09-18
213
+ */
214
+ ap: function (readerValue) { return function (readerFn) {
215
+ return function (deps) { return readerFn(deps)(readerValue(deps)); };
216
+ }; },
217
+ /**
218
+ * Runs a Reader with the given environment.
219
+ * @description Executes a Reader by providing it with the required environment,
220
+ * returning the computed value.
221
+ *
222
+ * @template R - The type of the environment
223
+ * @template A - The type of the value
224
+ * @param {R} deps - The environment to provide
225
+ * @returns {function(Reader<R, A>): A} A function that runs Readers
226
+ *
227
+ * @category Execution
228
+ * @example
229
+ * ```typescript
230
+ * type Config = { name: string };
231
+ * const getName: Reader<Config, string> = config => config.name;
232
+ *
233
+ * const config: Config = { name: 'Alice' };
234
+ * const name = Reader.run(config)(getName); // => 'Alice'
235
+ * ```
236
+ *
237
+ * @since 2025-09-18
238
+ */
239
+ run: function (deps) { return function (reader) { return reader(deps); }; },
240
+ /**
241
+ * Modifies the environment before running a Reader.
242
+ * @description Transforms the environment using a function before passing it
243
+ * to the Reader. This is contravariant mapping on the environment.
244
+ *
245
+ * @template R - The new environment type
246
+ * @template S - The original environment type
247
+ * @param {function(R): S} f - Function to transform the environment
248
+ * @returns {function(Reader<S, A>): Reader<R, A>} A function that adapts Readers
249
+ *
250
+ * @category Transformations
251
+ * @example
252
+ * ```typescript
253
+ * type AppConfig = { db: DbConfig; api: ApiConfig };
254
+ * type DbConfig = { host: string; port: number };
255
+ *
256
+ * const getDbHost: Reader<DbConfig, string> = config => config.host;
257
+ * const getAppDbHost = Reader.local<AppConfig, DbConfig>(
258
+ * app => app.db
259
+ * )(getDbHost);
260
+ *
261
+ * const appConfig: AppConfig = {
262
+ * db: { host: 'localhost', port: 5432 },
263
+ * api: { url: 'https://api.com' }
264
+ * };
265
+ * Reader.run(appConfig)(getAppDbHost); // => 'localhost'
266
+ * ```
267
+ *
268
+ * @since 2025-09-18
269
+ */
270
+ local: function (f) { return function (reader) {
271
+ return function (deps) { return reader(f(deps)); };
272
+ }; },
273
+ /**
274
+ * Converts an array of Readers into a Reader of an array.
275
+ * @description Sequences multiple Readers, collecting their results into an array.
276
+ *
277
+ * @template R - The environment type
278
+ * @template A - The type of values in the Readers
279
+ * @param {Reader<R, A>[]} readers - Array of Readers to sequence
280
+ * @returns {Reader<R, A[]>} A Reader containing an array of results
281
+ *
282
+ * @category Combinators
283
+ * @example
284
+ * ```typescript
285
+ * type Config = { x: number; y: number; z: number };
286
+ *
287
+ * const readers = [
288
+ * (c: Config) => c.x,
289
+ * (c: Config) => c.y,
290
+ * (c: Config) => c.z
291
+ * ];
292
+ * const combined = Reader.sequence(readers);
293
+ *
294
+ * const config: Config = { x: 1, y: 2, z: 3 };
295
+ * Reader.run(config)(combined); // => [1, 2, 3]
296
+ * ```
297
+ *
298
+ * @since 2025-09-18
299
+ */
300
+ sequence: function (readers) {
301
+ return function (deps) { return readers.map(function (reader) { return reader(deps); }); };
302
+ },
303
+ /**
304
+ * Maps a function returning a Reader over an array and sequences the results.
305
+ * @description Applies a Reader-returning function to each element of an array
306
+ * and collects all results.
307
+ *
308
+ * @template R - The environment type
309
+ * @template A - The input type
310
+ * @template B - The output type
311
+ * @param {function(A): Reader<R, B>} f - Function that returns a Reader
312
+ * @returns {function(A[]): Reader<R, B[]>} A function that traverses arrays with Readers
313
+ *
314
+ * @category Combinators
315
+ * @example
316
+ * ```typescript
317
+ * type Config = { multiplier: number };
318
+ *
319
+ * const multiplyBy = (n: number): Reader<Config, number> =>
320
+ * config => n * config.multiplier;
321
+ *
322
+ * const multiplyAll = Reader.traverse(multiplyBy);
323
+ * const results = multiplyAll([1, 2, 3]);
324
+ *
325
+ * const config: Config = { multiplier: 10 };
326
+ * Reader.run(config)(results); // => [10, 20, 30]
327
+ * ```
328
+ *
329
+ * @since 2025-09-18
330
+ */
331
+ traverse: function (f) { return function (as) {
332
+ return Reader.sequence(as.map(f));
333
+ }; },
334
+ /**
335
+ * Combines the results of a tuple of Readers into a Reader of a tuple.
336
+ * @description Takes multiple Readers and returns a Reader containing a tuple
337
+ * of their results.
338
+ *
339
+ * @template R - The environment type
340
+ * @template T - Tuple type of Readers
341
+ * @param {...T} readers - Readers to combine
342
+ * @returns {Reader<R, { [K in keyof T]: T[K] extends Reader<R, infer U> ? U : never }>} Reader of tuple
343
+ *
344
+ * @category Combinators
345
+ * @example
346
+ * ```typescript
347
+ * type Config = { name: string; age: number; active: boolean };
348
+ *
349
+ * const getName: Reader<Config, string> = c => c.name;
350
+ * const getAge: Reader<Config, number> = c => c.age;
351
+ * const getActive: Reader<Config, boolean> = c => c.active;
352
+ *
353
+ * const combined = Reader.sequenceT(getName, getAge, getActive);
354
+ *
355
+ * const config: Config = { name: 'Alice', age: 30, active: true };
356
+ * Reader.run(config)(combined); // => ['Alice', 30, true]
357
+ * ```
358
+ *
359
+ * @since 2025-09-18
360
+ */
361
+ sequenceT: function () {
362
+ var readers = [];
363
+ for (var _i = 0; _i < arguments.length; _i++) {
364
+ readers[_i] = arguments[_i];
365
+ }
366
+ return function (deps) { return readers.map(function (r) { return r(deps); }); };
367
+ },
368
+ /**
369
+ * Combines the results of a record of Readers into a Reader of a record.
370
+ * @description Takes an object with Reader values and returns a Reader containing
371
+ * an object with the results.
372
+ *
373
+ * @template R - The environment type
374
+ * @template S - Record type with Reader values
375
+ * @param {S} readers - Record of Readers to combine
376
+ * @returns {Reader<R, { [K in keyof S]: S[K] extends Reader<R, infer U> ? U : never }>} Reader of record
377
+ *
378
+ * @category Combinators
379
+ * @example
380
+ * ```typescript
381
+ * type Config = { user: string; host: string; port: number };
382
+ *
383
+ * const readers = {
384
+ * username: (c: Config) => c.user,
385
+ * server: (c: Config) => c.host,
386
+ * portNumber: (c: Config) => c.port
387
+ * };
388
+ *
389
+ * const combined = Reader.sequenceS(readers);
390
+ *
391
+ * const config: Config = { user: 'admin', host: 'localhost', port: 3000 };
392
+ * Reader.run(config)(combined);
393
+ * // => { username: 'admin', server: 'localhost', portNumber: 3000 }
394
+ * ```
395
+ *
396
+ * @since 2025-09-18
397
+ */
398
+ sequenceS: function (readers) {
399
+ return function (deps) {
400
+ var result = {};
401
+ for (var key in readers) {
402
+ if (Object.prototype.hasOwnProperty.call(readers, key)) {
403
+ result[key] = readers[key](deps);
404
+ }
405
+ }
406
+ return result;
407
+ };
408
+ },
409
+ /**
410
+ * Executes a Reader for its side effects, discarding the result.
411
+ * @description Runs a Reader-returning function but preserves the original value.
412
+ * Useful for logging or other side effects where the result isn't needed.
413
+ *
414
+ * @template R - The environment type
415
+ * @template A - The type of the value
416
+ * @param {function(A): Reader<R, any>} f - Function that returns a Reader (result discarded)
417
+ * @returns {function(Reader<R, A>): Reader<R, A>} A function that executes side effects
418
+ *
419
+ * @category Combinators
420
+ * @example
421
+ * ```typescript
422
+ * type Config = { logger: (msg: string) => void };
423
+ *
424
+ * const log = (msg: string): Reader<Config, void> =>
425
+ * config => config.logger(msg);
426
+ *
427
+ * const getValue: Reader<Config, number> = () => 42;
428
+ * const logged = Reader.chainFirst((n: number) => log(`Got: ${n}`))(getValue);
429
+ *
430
+ * const config: Config = { logger: console.log };
431
+ * Reader.run(config)(logged); // logs "Got: 42", returns 42
432
+ * ```
433
+ *
434
+ * @since 2025-09-18
435
+ */
436
+ chainFirst: function (f) { return function (reader) {
437
+ return function (deps) {
438
+ var a = reader(deps);
439
+ f(a)(deps);
440
+ return a;
441
+ };
442
+ }; },
443
+ };
444
+ //# sourceMappingURL=reader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.mjs","sourceRoot":"","sources":["../src/reader.mts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA2BH;;;;;;;GAOG;AACH,MAAM,CAAC,IAAM,MAAM,GAAG;IACpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,EAAE,EAAE,UAAQ,KAAQ,IAAmB,OAAA,cAAM,OAAA,KAAK,EAAL,CAAK,EAAX,CAAW;IAElD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,GAAG,EAAE,cAAwB,OAAA,UAAA,IAAI,IAAI,OAAA,IAAI,EAAJ,CAAI,EAAZ,CAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAI,EAAE,UAAQ,CAAiB,IAAmB,OAAA,CAAC,EAAD,CAAC;IAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,EAAE,UAAW,CAAkB,IAAK,OAAA,UAAC,MAAoB;QAC1D,OAAA,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAf,CAAe;IAAvB,CAAuB,EADc,CACd;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,EAAE,UAAW,CAA6B,IAAK,OAAA,UAAC,MAAoB;QACvE,OAAA,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAArB,CAAqB;IAA7B,CAA6B,EADqB,CACrB;IAE/B;;;;;;OAMG;IACH,OAAO,EAAE,UAAW,CAA6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;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,SAAS,EAAE;QACT,iBAA+C;aAA/C,UAA+C,EAA/C,qBAA+C,EAA/C,IAA+C;YAA/C,4BAA+C;;QAE/C,OAAA,UAAC,IAAI,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,EAAP,CAAO,CAAiB,EAA3C,CAA2C;IAArD,CAAqD;IAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,SAAS,EAAE,UACT,OAA4C;QAE5C,OAAA,UAAC,IAAI;YACH,IAAM,MAAM,GAAG,EAAO,CAAC;YACvB,KAAK,IAAM,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC1B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;oBACvD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;IARD,CAQC;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,UAAU,EAAE,UAAQ,CAA+B,IAAK,OAAA,UAAC,MAAoB;QAC3E,OAAA,UAAA,IAAI;YACF,IAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;IAJD,CAIC,EALqD,CAKrD;CACJ,CAAC"}
package/dist/result.d.mts CHANGED
@@ -71,6 +71,16 @@ export type Result<T, E = string> = {
71
71
  success: false;
72
72
  error: E;
73
73
  };
74
+ /**
75
+ * Do notation builder for Result types
76
+ * @internal
77
+ */
78
+ export interface ResultDoBuilder<E = unknown> {
79
+ bind: <K extends string, T>(key: K, result: Result<T, E> | ((ctx: Record<string, unknown>) => Result<T, E>)) => ResultDoBuilder<E>;
80
+ map: <T>(f: (ctx: Record<string, unknown>) => T) => Result<T, E>;
81
+ flatMap: <T>(f: (ctx: Record<string, unknown>) => Result<T, E>) => Result<T, E>;
82
+ value: () => Result<Record<string, unknown>, E>;
83
+ }
74
84
  /**
75
85
  * Result utility functions for working with Result types.
76
86
  * @description Provides a functional API for creating, transforming, and composing Results.
@@ -573,6 +583,192 @@ export declare const Result: {
573
583
  * @since 2025-07-03
574
584
  */
575
585
  fromThrowable: <T extends unknown[], U>(fn: (...args: T) => U) => (...args: T) => Result<U, Error>;
586
+ /**
587
+ * Maps a function returning a Result over an array and sequences the results.
588
+ * @description Applies a Result-returning function to each element of an array
589
+ * and collects all results. If any operation fails, returns the first error.
590
+ *
591
+ * @template T - The input type
592
+ * @template U - The output type
593
+ * @template E - The error type
594
+ * @param {function(T): Result<U, E>} f - Function that returns a Result
595
+ * @returns {function(T[]): Result<U[], E>} A function that traverses arrays with Results
596
+ *
597
+ * @category Combinators
598
+ * @example
599
+ * ```typescript
600
+ * const parseNumber = (s: string): Result<number, string> => {
601
+ * const n = Number(s);
602
+ * return isNaN(n) ? Result.err(`Not a number: ${s}`) : Result.ok(n);
603
+ * };
604
+ *
605
+ * const parseAll = Result.traverse(parseNumber);
606
+ * parseAll(['1', '2', '3']); // => { success: true, data: [1, 2, 3] }
607
+ * parseAll(['1', 'x', '3']); // => { success: false, error: 'Not a number: x' }
608
+ * ```
609
+ *
610
+ * @since 2025-09-18
611
+ */
612
+ traverse: <T, U, E>(f: (t: T) => Result<U, E>) => (ts: T[]) => Result<U[], E>;
613
+ /**
614
+ * Applies a Result of a function to a Result of a value.
615
+ * @description Enables applying functions wrapped in Results to values wrapped
616
+ * in Results. If either Result is an error, returns that error. This is the
617
+ * applicative apply operation for Result types.
618
+ *
619
+ * @template T - The input type
620
+ * @template U - The output type
621
+ * @template E - The error type
622
+ * @param {Result<T, E>} resultValue - Result containing a value
623
+ * @returns {function(Result<function(T): U, E>): Result<U, E>} A function that applies Result functions
624
+ *
625
+ * @category Combinators
626
+ * @example
627
+ * ```typescript
628
+ * const add = (a: number) => (b: number) => a + b;
629
+ * const resultAdd = Result.ok(add);
630
+ * const result5 = Result.ok(5);
631
+ * const result3 = Result.ok(3);
632
+ *
633
+ * const sum = Result.ap(result3)(
634
+ * Result.ap(result5)(
635
+ * Result.map(add)(Result.ok(10))
636
+ * )
637
+ * ); // => { success: true, data: 18 }
638
+ * ```
639
+ *
640
+ * @since 2025-09-18
641
+ */
642
+ ap: <T, U, E>(resultValue: Result<T, E>) => (resultFn: Result<(t: T) => U, E>) => Result<U, E>;
643
+ /**
644
+ * Maps both the success and error values of a Result.
645
+ * @description Transforms both channels of a Result simultaneously. Useful for
646
+ * normalizing both success values and errors in a single operation.
647
+ *
648
+ * @template T - The input success type
649
+ * @template U - The output success type
650
+ * @template E - The input error type
651
+ * @template F - The output error type
652
+ * @param {function(T): U} f - Function to transform the success value
653
+ * @param {function(E): F} g - Function to transform the error value
654
+ * @returns {function(Result<T, E>): Result<U, F>} A function that transforms both channels
655
+ *
656
+ * @category Transformations
657
+ * @example
658
+ * ```typescript
659
+ * const transform = Result.bimap(
660
+ * (n: number) => n.toString(),
661
+ * (e: Error) => e.message
662
+ * );
663
+ *
664
+ * transform(Result.ok(42)); // => { success: true, data: '42' }
665
+ * transform(Result.err(new Error('fail'))); // => { success: false, error: 'fail' }
666
+ * ```
667
+ *
668
+ * @since 2025-09-18
669
+ */
670
+ bimap: <T, U, E, F>(f: (t: T) => U, g: (e: E) => F) => (result: Result<T, E>) => Result<U, F>;
671
+ /**
672
+ * Executes a Result for its side effects, discarding the result.
673
+ * @description Runs a Result-returning function but preserves the original value.
674
+ * Useful for logging or other side effects where the result isn't needed.
675
+ *
676
+ * @template T - The type of the value
677
+ * @template E - The error type
678
+ * @param {function(T): Result<any, E>} f - Function that returns a Result (result discarded)
679
+ * @returns {function(Result<T, E>): Result<T, E>} A function that executes side effects
680
+ *
681
+ * @category Combinators
682
+ * @example
683
+ * ```typescript
684
+ * const log = (msg: string): Result<void, never> => {
685
+ * console.log(msg);
686
+ * return Result.ok(undefined);
687
+ * };
688
+ *
689
+ * const result = Result.chainFirst((n: number) => log(`Got: ${n}`))(
690
+ * Result.ok(42)
691
+ * ); // logs "Got: 42", returns { success: true, data: 42 }
692
+ * ```
693
+ *
694
+ * @since 2025-09-18
695
+ */
696
+ chainFirst: <T, E>(f: (t: T) => Result<unknown, E>) => (result: Result<T, E>) => Result<T, E>;
697
+ /**
698
+ * Combines the results of a tuple of Results into a Result of a tuple.
699
+ * @description Takes multiple Results and returns a Result containing a tuple
700
+ * of their values. If any Result is an error, returns the first error.
701
+ *
702
+ * @template T - Tuple type of Results
703
+ * @param {...T} results - Results to combine
704
+ * @returns {Result<{ [K in keyof T]: T[K] extends Result<infer U, any> ? U : never }, T[number] extends Result<any, infer E> ? E : never>} Result of tuple
705
+ *
706
+ * @category Combinators
707
+ * @example
708
+ * ```typescript
709
+ * const result1 = Result.ok(1);
710
+ * const result2 = Result.ok('hello');
711
+ * const result3 = Result.ok(true);
712
+ *
713
+ * const combined = Result.sequenceT(result1, result2, result3);
714
+ * // => { success: true, data: [1, 'hello', true] }
715
+ * ```
716
+ *
717
+ * @since 2025-09-18
718
+ */
719
+ sequenceT: <T extends readonly Result<unknown, unknown>[]>(...results: T) => Result<{ [K in keyof T]: T[K] extends Result<infer U, unknown> ? U : never; }, T[number] extends Result<unknown, infer E> ? E : never>;
720
+ /**
721
+ * Combines the results of a record of Results into a Result of a record.
722
+ * @description Takes an object with Result values and returns a Result containing
723
+ * an object with the unwrapped values. If any Result is an error, returns the first error.
724
+ *
725
+ * @template R - Record type with Result values
726
+ * @param {R} results - Record of Results to combine
727
+ * @returns {Result<{ [K in keyof R]: R[K] extends Result<infer U, any> ? U : never }, R[keyof R] extends Result<any, infer E> ? E : never>} Result of record
728
+ *
729
+ * @category Combinators
730
+ * @example
731
+ * ```typescript
732
+ * const results = {
733
+ * user: Result.ok({ name: 'Alice' }),
734
+ * count: Result.ok(42),
735
+ * enabled: Result.ok(true)
736
+ * };
737
+ *
738
+ * const combined = Result.sequenceS(results);
739
+ * // => { success: true, data: { user: { name: 'Alice' }, count: 42, enabled: true } }
740
+ * ```
741
+ *
742
+ * @since 2025-09-18
743
+ */
744
+ sequenceS: <R extends Record<string, Result<unknown, unknown>>>(results: R) => Result<{ [K in keyof R]: R[K] extends Result<infer U, unknown> ? U : never; }, R[keyof R] extends Result<unknown, infer E> ? E : never>;
745
+ /**
746
+ * Do notation helper for Result types.
747
+ * @description Provides a way to write sequential Result operations in an
748
+ * imperative style, similar to async/await but for Result types.
749
+ *
750
+ * @template E - The error type
751
+ * @returns {object} Do notation builder
752
+ *
753
+ * @category Do Notation
754
+ * @example
755
+ * ```typescript
756
+ * const result = Result.Do<string>()
757
+ * .bind('x', Result.ok(5))
758
+ * .bind('y', Result.ok(3))
759
+ * .map(({ x, y }) => x + y);
760
+ * // => { success: true, data: 8 }
761
+ *
762
+ * const withError = Result.Do<string>()
763
+ * .bind('x', Result.ok(5))
764
+ * .bind('y', Result.err<number, string>('error'))
765
+ * .map(({ x, y }) => x + y);
766
+ * // => { success: false, error: 'error' }
767
+ * ```
768
+ *
769
+ * @since 2025-09-18
770
+ */
771
+ Do: <E = unknown>() => ResultDoBuilder<E>;
576
772
  };
577
773
  /**
578
774
  * Utility type guard for checking if a value is a Result.
@@ -1 +1 @@
1
- {"version":3,"file":"result.d.mts","sourceRoot":"","sources":["../src/result.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,IAC5B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;I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