Skip to content

Commit d77c733

Browse files
committed
docs: update imports and type annotations across documentation for clarity and consistency
1 parent 6c49b07 commit d77c733

File tree

5 files changed

+50
-39
lines changed

5 files changed

+50
-39
lines changed

docs/either/index.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ console.log(result2); // 0
226226
Compares `this` to another `Either`, returns `false` if the values inside are different.
227227

228228
```ts
229-
import { Either, Left, Right } from "holo-fn/either";
229+
import { type Either, Left, Right } from "holo-fn/either";
230230

231231
const calculate = (a: number, b: number): Either<string, number> => {
232232
if (b === 0) {
@@ -247,7 +247,6 @@ const result2 = calculate(10, 2)
247247
.map(n => n + 1);
248248

249249
console.log(result2.equals(new Right(0))); // false
250-
251250
```
252251

253252
## Helpers
@@ -509,6 +508,7 @@ Curried version of `equals` for `Either`. Compares `this` to another `Either`, r
509508

510509
```ts
511510
import { equals, Right } from 'holo-fn/either';
511+
import { pipe } from 'remeda';
512512

513513
const result = pipe(
514514
new Right(10),
@@ -525,9 +525,9 @@ console.log(result); // true
525525
Combines an array of `Either` values into a single `Either`. Returns `Right` with all values if all are `Right`, or `Left` with all errors if any are `Left`.
526526

527527
```ts
528-
import { all, right, left } from 'holo-fn/either';
528+
import { all, left, right, type Either } from 'holo-fn/either';
529529

530-
const result1 = all([right(1), right(2), right(3)]);
530+
const result1: Either<unknown, number[]> = all([right(1), right(2), right(3)]);
531531
console.log(result1.unwrapOr([])); // [1, 2, 3]
532532

533533
const result2 = all([left('Name required'), left('Email invalid'), right(25)]);
@@ -552,9 +552,9 @@ Combines an array of `Either` values into a single `Either`, stopping at the fir
552552
Unlike `all` which collects all errors, `sequence` returns immediately when it finds the first `Left`.
553553

554554
```ts
555-
import { sequence, right, left } from 'holo-fn/either';
555+
import { left, right, sequence, type Either } from 'holo-fn/either';
556556

557-
const result1 = sequence([right(1), right(2), right(3)]);
557+
const result1: Either<unknown, number[]> = sequence([right(1), right(2), right(3)]);
558558
console.log(result1.unwrapOr([])); // [1, 2, 3]
559559

560560
const result2 = sequence([
@@ -577,7 +577,7 @@ Separates an array of `Either` values into two groups: `lefts` and `rights`. Alw
577577
Unlike `all` and `sequence` which return an `Either`, `partition` returns a plain object with two arrays.
578578

579579
```ts
580-
import { partition, left, right } from 'holo-fn/either';
580+
import { left, partition, right } from 'holo-fn/either';
581581

582582
const eithers = [
583583
right<string, number>(1),
@@ -604,8 +604,8 @@ errors.forEach((err) => console.error(err));
604604
### Discriminated union errors
605605

606606
```ts
607-
import { pipe } from 'rambda';
608607
import { left, match, type Either } from 'holo-fn/either';
608+
import { pipe } from 'rambda';
609609

610610
type User = {
611611
name: string;
@@ -643,8 +643,8 @@ const message = pipe(
643643
### Batch operations with error tracking
644644

645645
```ts
646-
import { pipe } from 'rambda';
647646
import { all, left, match, right } from 'holo-fn/either';
647+
import { pipe } from 'rambda';
648648

649649
type AddressData = {
650650
street: string;

docs/helpers/inspect.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ pipe(
3939
### Without Label
4040

4141
```typescript
42-
import { ok } from 'holo-fn/result';
4342
import { inspect } from 'holo-fn';
43+
import { map, ok } from 'holo-fn/result';
44+
import { pipe } from 'rambda';
4445
4546
pipe(
4647
ok({ id: 1, name: 'Alice' }),
@@ -52,9 +53,9 @@ pipe(
5253
### Debugging Pipelines
5354

5455
```typescript
55-
import { pipe } from 'rambda';
56-
import { just, map } from 'holo-fn/maybe';
5756
import { inspect } from 'holo-fn';
57+
import { just, map } from 'holo-fn/maybe';
58+
import { pipe } from 'rambda';
5859
5960
const result = pipe(
6061
just(10),
@@ -69,8 +70,8 @@ const result = pipe(
6970
### With Arrays
7071

7172
```typescript
72-
import { pipe } from 'rambda';
7373
import { inspect } from 'holo-fn';
74+
import { pipe } from 'rambda';
7475
7576
pipe(
7677
[1, 2, 3, 4],
@@ -85,8 +86,8 @@ pipe(
8586
### With Plain Objects
8687

8788
```typescript
88-
import { pipe } from 'rambda';
8989
import { inspect } from 'holo-fn';
90+
import { pipe } from 'rambda';
9091
9192
const user = pipe(
9293
{ id: 1, name: 'Alice', age: 30 },
@@ -101,9 +102,9 @@ const user = pipe(
101102
### Debugging Complex Transformations
102103

103104
```typescript
104-
import { pipe } from 'rambda';
105-
import { fromNullable, map, chain } from 'holo-fn/maybe';
106105
import { inspect } from 'holo-fn';
106+
import { chain, fromNullable, map } from 'holo-fn/maybe';
107+
import { pipe } from 'rambda';
107108
108109
const getUserEmail = (userId: number) =>
109110
pipe(
@@ -120,9 +121,9 @@ const getUserEmail = (userId: number) =>
120121
### Finding Where Transformations Fail
121122

122123
```typescript
123-
import { pipe } from 'rambda';
124-
import { fromThrowable } from 'holo-fn/result';
125124
import { inspect } from 'holo-fn';
125+
import { fromThrowable, map } from 'holo-fn/result';
126+
import { pipe } from 'rambda';
126127
127128
const parseAndValidate = (input: string) =>
128129
pipe(
@@ -138,9 +139,9 @@ const parseAndValidate = (input: string) =>
138139
### Monitoring Data Flow
139140

140141
```typescript
141-
import { pipe } from 'rambda';
142-
import { all } from 'holo-fn/maybe';
143142
import { inspect } from 'holo-fn';
143+
import { all, map } from 'holo-fn/maybe';
144+
import { pipe } from 'rambda';
144145
145146
const results = pipe(
146147
[

docs/helpers/tap.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ A function that:
2828
### With Maybe
2929

3030
```typescript
31-
import { just, map, tap } from "holo-fn";
31+
import { tap } from "holo-fn";
32+
import { just, map } from "holo-fn/maybe";
3233
import { pipe } from "rambda";
3334
3435
const result = pipe(
@@ -45,7 +46,8 @@ const result = pipe(
4546
### With Result
4647

4748
```typescript
48-
import { ok, map, tap } from "holo-fn";
49+
import { tap } from "holo-fn";
50+
import { map, ok } from "holo-fn/result";
4951
import { pipe } from "rambda";
5052
5153
const result = pipe(
@@ -62,7 +64,8 @@ const result = pipe(
6264
### With Either
6365

6466
```typescript
65-
import { right, map, tap } from "holo-fn";
67+
import { tap } from "holo-fn";
68+
import { map, right } from "holo-fn/either";
6669
import { pipe } from "rambda";
6770
6871
const result = pipe(
@@ -234,7 +237,7 @@ TypeScript correctly infers the type through `tap`:
234237
const result: Maybe<number> = pipe(
235238
just(42),
236239
tap(x => console.log(x)), // x: Maybe<number>
237-
map(x => x * 2) // Type: Maybe<number>
240+
map(x => x * 2) // Type: Maybe<number>
238241
);
239242
240243
// Works with union types

docs/maybe/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ console.log(result2); // "No value"
118118
Compares the values inside `this` and the other, returns `true` if both are `Nothing` or if the values are equal.
119119

120120
```ts
121+
import type { Maybe } from "holo-fn";
121122
import { Just, Nothing } from "holo-fn/maybe";
122123

123124
const result1 = new Just("value").chain(v => new Just(v + " modified"));
124125

125126
console.log(result1.equals(new Just("value"))); // false
126127
console.log(result1.equals(new Just("value modified"))); // true
127128

128-
const result2 = new Just("value").chain(v => new Nothing());
129+
const result2: Maybe<string> = new Just("value").chain(v => new Nothing());
129130
console.log(result2.equals(new Nothing())); // true
130131
console.log(result2.equals(new Just("value"))); // false
131132
```
@@ -320,10 +321,10 @@ console.log(result); // true
320321
Combines an array of `Maybe` values into a single `Maybe` containing an array. Returns `Just` with all values if all are `Just`, or `Nothing` if any is `Nothing`.
321322

322323
```ts
323-
import { all, just, nothing } from 'holo-fn/maybe';
324+
import { all, just, nothing, type Maybe } from 'holo-fn/maybe';
324325

325326
// All success case
326-
const result1 = all([just(1), just(2), just(3)]);
327+
const result1: Maybe<number[]> = all([just(1), just(2), just(3)]);
327328
console.log(result1.unwrapOr([])); // [1, 2, 3]
328329

329330
// Any failure case
@@ -344,8 +345,9 @@ console.log(result3.unwrapOr([])); // []
344345
When you need to work with multiple `Maybe` values:
345346

346347
```ts
347-
import { pipe } from 'rambda';
348+
348349
import { all, just, match } from 'holo-fn/maybe';
350+
import { pipe } from 'rambda';
349351

350352
const name = just('Test User');
351353
const age = just(25);
@@ -361,14 +363,13 @@ const user = pipe(
361363

362364
console.log(user);
363365
// Output: { name: 'Test User', age: 25, email: '[email protected]' }
364-
365366
```
366367

367368
### Conditional logic with predicates
368369

369370
```ts
370-
import { pipe } from 'rambda';
371371
import { just, match } from 'holo-fn/maybe';
372+
import { pipe } from 'rambda';
372373

373374
const value = just(42);
374375

@@ -390,8 +391,8 @@ console.log(`The number is categorized as: ${category}`);
390391
### Chaining operations with early exit
391392

392393
```ts
393-
import { pipe } from 'rambda';
394394
import { chain, filter, fromNullable, map } from 'holo-fn/maybe';
395+
import { pipe } from 'rambda';
395396

396397
const user: { email?: string } | null = { email: '[email protected]' };
397398

docs/result/index.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ console.log(validateAge(15)); // 0 (fails validation)
316316
**Common use cases:**
317317

318318
```ts
319+
import { fromThrowable, ok, validate } from "holo-fn/result";
320+
import { pipe } from "remeda";
321+
319322
// Validate email format
320323
const validateEmail = (email: string) =>
321324
pipe(
@@ -325,7 +328,7 @@ const validateEmail = (email: string) =>
325328
validate((s) => s.includes('.'), 'Invalid domain')
326329
);
327330

328-
console.log(validateEmail('test@example.com').unwrapOr('Invalid'));
331+
console.log(validateEmail('testexample.com').unwrapOr('Invalid'));
329332

330333
// Parse and validate numbers
331334
const parsePositive = (input: string) =>
@@ -339,7 +342,7 @@ const parsePositive = (input: string) =>
339342
);
340343

341344
console.log(parsePositive('42').unwrapOr(0)); // 42
342-
console.log(parsePositive('-5').unwrapOr(0));
345+
console.log(parsePositive('-5').unwrapOr(0)); // 0
343346

344347
// Validate objects
345348
type User = { name: string; age: number };
@@ -399,6 +402,7 @@ Curried version of `equals` for `Result`. Compares `this` to another `Result`, r
399402

400403
```ts
401404
import { equals, Ok } from 'holo-fn/result';
405+
import { pipe } from 'remeda';
402406

403407
const result1 = pipe(
404408
new Ok(10),
@@ -422,9 +426,10 @@ console.log(result2); // false
422426
Combines an array of `Result` values into a single `Result`. Returns `Ok` with all values if all are `Ok`, or `Err` with all errors if any are `Err`.
423427

424428
```ts
425-
import { all, ok, err } from 'holo-fn/result';
429+
import type { Result } from 'holo-fn';
430+
import { all, err, ok } from 'holo-fn/result';
426431

427-
const result1 = all([ok(1), ok(2), ok(3)]);
432+
const result1: Result<number[], unknown[]> = all([ok(1), ok(2), ok(3)]);
428433
console.log(result1.unwrapOr([])); // [1, 2, 3]
429434

430435
const result2 = all([err('Name required'), err('Email invalid'), ok(25)]);
@@ -448,9 +453,10 @@ Combines an array of `Result` values into a single `Result`, stopping at the fir
448453
Unlike `all` which collects all errors, `sequence` returns immediately when it finds the first `Err`.
449454

450455
```ts
451-
import { sequence, ok, err } from 'holo-fn/result';
456+
import type { Result } from 'holo-fn';
457+
import { err, ok, sequence } from 'holo-fn/result';
452458

453-
const result1 = sequence([ok(1), ok(2), ok(3)]);
459+
const result1: Result<number[], unknown> = sequence([ok(1), ok(2), ok(3)]);
454460
console.log(result1.unwrapOr([])); // [1, 2, 3]
455461

456462
const result2 = sequence([
@@ -461,7 +467,7 @@ const result2 = sequence([
461467
console.log(result2.match({
462468
ok: (v) => v,
463469
err: (e) => e
464-
})); // 'First error' (not an array!)
470+
})); // 'First error'
465471
```
466472

467473
---
@@ -473,7 +479,7 @@ Separates an array of `Result` values into two groups: successes (`oks`) and fai
473479
Unlike `all` and `sequence` which return a `Result`, `partition` returns a plain object with two arrays.
474480

475481
```ts
476-
import { partition, ok, err } from 'holo-fn/result';
482+
import { err, ok, partition } from 'holo-fn/result';
477483

478484
const results = [
479485
ok<number, string>(1),

0 commit comments

Comments
 (0)