Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LazyArg #1856

Merged
merged 4 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
**Note**: A feature tagged as Experimental is in a
high state of flux, you're at risk of it changing without notice.

# 2.15.0

**New Feature**

- `function`
- add `LazyArg`

# 2.14.0

**New Feature**
Expand Down
14 changes: 7 additions & 7 deletions docs/modules/Alt.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Added in v2.0.0

```ts
export interface Alt<F> extends Functor<F> {
readonly alt: <A>(fa: HKT<F, A>, that: Lazy<HKT<F, A>>) => HKT<F, A>
readonly alt: <A>(fa: HKT<F, A>, that: LazyArg<HKT<F, A>>) => HKT<F, A>
}
```

Expand All @@ -54,7 +54,7 @@ Added in v2.0.0

```ts
export interface Alt1<F extends URIS> extends Functor1<F> {
readonly alt: <A>(fa: Kind<F, A>, that: Lazy<Kind<F, A>>) => Kind<F, A>
readonly alt: <A>(fa: Kind<F, A>, that: LazyArg<Kind<F, A>>) => Kind<F, A>
}
```

Expand All @@ -66,7 +66,7 @@ Added in v2.0.0

```ts
export interface Alt2<F extends URIS2> extends Functor2<F> {
readonly alt: <E, A>(fa: Kind2<F, E, A>, that: Lazy<Kind2<F, E, A>>) => Kind2<F, E, A>
readonly alt: <E, A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>
}
```

Expand All @@ -78,7 +78,7 @@ Added in v2.0.0

```ts
export interface Alt2C<F extends URIS2, E> extends Functor2C<F, E> {
readonly alt: <A>(fa: Kind2<F, E, A>, that: Lazy<Kind2<F, E, A>>) => Kind2<F, E, A>
readonly alt: <A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>
}
```

Expand All @@ -90,7 +90,7 @@ Added in v2.0.0

```ts
export interface Alt3<F extends URIS3> extends Functor3<F> {
readonly alt: <R, E, A>(fa: Kind3<F, R, E, A>, that: Lazy<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
readonly alt: <R, E, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}
```

Expand All @@ -102,7 +102,7 @@ Added in v2.0.0

```ts
export interface Alt3C<F extends URIS3, E> extends Functor3C<F, E> {
readonly alt: <R, A>(fa: Kind3<F, R, E, A>, that: Lazy<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
readonly alt: <R, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}
```

Expand All @@ -114,7 +114,7 @@ Added in v2.2.0

```ts
export interface Alt4<F extends URIS4> extends Functor4<F> {
readonly alt: <S, R, E, A>(fa: Kind4<F, S, R, E, A>, that: Lazy<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
readonly alt: <S, R, E, A>(fa: Kind4<F, S, R, E, A>, that: LazyArg<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
}
```

Expand Down
49 changes: 26 additions & 23 deletions docs/modules/Array.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Added in v2.0.0
- [getShow](#getshow)
- [getUnionMonoid](#getunionmonoid)
- [getUnionSemigroup](#getunionsemigroup)
- [legacy](#legacy)
- [chain](#chain)
- [lifting](#lifting)
- [fromEitherK](#fromeitherk)
- [fromOptionK](#fromoptionk)
Expand All @@ -107,7 +109,6 @@ Added in v2.0.0
- [isEmpty](#isempty)
- [isNonEmpty](#isnonempty)
- [sequencing](#sequencing)
- [chain](#chain)
- [chainFirst](#chainfirst)
- [chainRecBreadthFirst](#chainrecbreadthfirst)
- [chainRecDepthFirst](#chainrecdepthfirst)
Expand Down Expand Up @@ -407,7 +408,7 @@ In case of `Array` concatenates the inputs into a single array.
**Signature**

```ts
export declare const alt: <A>(that: Lazy<A[]>) => (fa: A[]) => A[]
export declare const alt: <A>(that: LazyArg<A[]>) => (fa: A[]) => A[]
```

**Example**
Expand Down Expand Up @@ -436,7 +437,7 @@ The `W` suffix (short for **W**idening) means that the return types will be merg
**Signature**

```ts
export declare const altW: <B>(that: Lazy<B[]>) => <A>(fa: A[]) => (B | A)[]
export declare const altW: <B>(that: LazyArg<B[]>) => <A>(fa: A[]) => (B | A)[]
```

**Example**
Expand Down Expand Up @@ -1328,6 +1329,20 @@ assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 3])

Added in v2.11.0

# legacy

## chain

Alias of `flatMap`.

**Signature**

```ts
export declare const chain: <A, B>(f: (a: A) => B[]) => (ma: A[]) => B[]
```

Added in v2.0.0

# lifting

## fromEitherK
Expand Down Expand Up @@ -1471,7 +1486,7 @@ Alias of [`matchLeft`](#matchleft).
**Signature**

```ts
export declare const foldLeft: <A, B>(onEmpty: Lazy<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B
export declare const foldLeft: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B
```

Added in v2.0.0
Expand All @@ -1483,7 +1498,7 @@ Alias of [`matchRight`](#matchright).
**Signature**

```ts
export declare const foldRight: <A, B>(onEmpty: Lazy<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B
export declare const foldRight: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B
```

Added in v2.0.0
Expand All @@ -1496,7 +1511,7 @@ it passes the array to `onNonEmpty` and returns the result.
**Signature**

```ts
export declare const match: <B, A>(onEmpty: Lazy<B>, onNonEmpty: (as: NEA.NonEmptyArray<A>) => B) => (as: A[]) => B
export declare const match: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (as: NEA.NonEmptyArray<A>) => B) => (as: A[]) => B
```

**Example**
Expand All @@ -1523,7 +1538,7 @@ it passes the array to `onNonEmpty` broken into its first element and remaining
**Signature**

```ts
export declare const matchLeft: <B, A>(onEmpty: Lazy<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B
export declare const matchLeft: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B
```

**Example**
Expand All @@ -1549,7 +1564,7 @@ Less strict version of [`matchLeft`](#matchleft). It will work when `onEmpty` an

```ts
export declare const matchLeftW: <B, A, C>(
onEmpty: Lazy<B>,
onEmpty: LazyArg<B>,
onNonEmpty: (head: A, tail: A[]) => C
) => (as: A[]) => B | C
```
Expand Down Expand Up @@ -1577,7 +1592,7 @@ it passes the array to `onNonEmpty` broken into its initial elements and the las
**Signature**

```ts
export declare const matchRight: <B, A>(onEmpty: Lazy<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B
export declare const matchRight: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B
```

**Example**
Expand All @@ -1603,7 +1618,7 @@ Less strict version of [`matchRight`](#matchright). It will work when `onEmpty`

```ts
export declare const matchRightW: <B, A, C>(
onEmpty: Lazy<B>,
onEmpty: LazyArg<B>,
onNonEmpty: (init: A[], last: A) => C
) => (as: A[]) => B | C
```
Expand Down Expand Up @@ -1633,7 +1648,7 @@ The `W` suffix (short for **W**idening) means that the handler return types will

```ts
export declare const matchW: <B, A, C>(
onEmpty: Lazy<B>,
onEmpty: LazyArg<B>,
onNonEmpty: (as: NEA.NonEmptyArray<A>) => C
) => (as: A[]) => B | C
```
Expand Down Expand Up @@ -1700,18 +1715,6 @@ Added in v2.0.0

# sequencing

## chain

Alias of `flatMap`.

**Signature**

```ts
export declare const chain: <A, B>(f: (a: A) => B[]) => (ma: A[]) => B[]
```

Added in v2.0.0

## chainFirst

Composes computations in sequence, using the return value of one computation to determine the next computation and
Expand Down
69 changes: 36 additions & 33 deletions docs/modules/Either.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ Added in v2.0.0
- [interop](#interop)
- [tryCatch](#trycatch)
- [tryCatchK](#trycatchk)
- [legacy](#legacy)
- [chain](#chain)
- [chainW](#chainw)
- [lifting](#lifting)
- [fromNullableK](#fromnullablek)
- [fromOptionK](#fromoptionk)
Expand All @@ -151,13 +154,11 @@ Added in v2.0.0
- [isLeft](#isleft)
- [isRight](#isright)
- [sequencing](#sequencing)
- [chain](#chain)
- [chainFirst](#chainfirst)
- [chainFirstW](#chainfirstw)
- [chainNullableK](#chainnullablek)
- [chainOptionK](#chainoptionk)
- [chainOptionKW](#chainoptionkw)
- [chainW](#chainw)
- [flatMap](#flatmap)
- [flatten](#flatten)
- [flattenW](#flattenw)
Expand Down Expand Up @@ -271,7 +272,7 @@ Added in v2.0.0
**Signature**

```ts
export declare const fromOption: <E>(onNone: Lazy<E>) => <A>(fa: Option<A>) => Either<E, A>
export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Either<E, A>
```

**Example**
Expand Down Expand Up @@ -421,7 +422,7 @@ In case of `Either` returns the left-most non-`Left` value (or the right-most `L
**Signature**

```ts
export declare const alt: <E, A>(that: Lazy<Either<E, A>>) => (fa: Either<E, A>) => Either<E, A>
export declare const alt: <E, A>(that: LazyArg<Either<E, A>>) => (fa: Either<E, A>) => Either<E, A>
```

**Example**
Expand Down Expand Up @@ -471,7 +472,7 @@ The `W` suffix (short for **W**idening) means that the error and the return type
**Signature**

```ts
export declare const altW: <E2, B>(that: Lazy<Either<E2, B>>) => <E1, A>(fa: Either<E1, A>) => Either<E2, B | A>
export declare const altW: <E2, B>(that: LazyArg<Either<E2, B>>) => <E1, A>(fa: Either<E1, A>) => Either<E2, B | A>
```

Added in v2.9.0
Expand Down Expand Up @@ -1044,7 +1045,7 @@ See also [`tryCatchK`](#trycatchk).
**Signature**

```ts
export declare const tryCatch: <E, A>(f: Lazy<A>, onThrow: (e: unknown) => E) => Either<E, A>
export declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (e: unknown) => E) => Either<E, A>
```

**Example**
Expand Down Expand Up @@ -1087,6 +1088,32 @@ export declare const tryCatchK: <A extends readonly unknown[], B, E>(

Added in v2.10.0

# legacy

## chain

Alias of `flatMap`.

**Signature**

```ts
export declare const chain: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, B>
```

Added in v2.0.0

## chainW

Alias of `flatMap`.

**Signature**

```ts
export declare const chainW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>
```

Added in v2.6.0

# lifting

## fromNullableK
Expand All @@ -1107,7 +1134,7 @@ Added in v2.9.0

```ts
export declare const fromOptionK: <E>(
onNone: Lazy<E>
onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => Either<E, B>
```

Expand Down Expand Up @@ -1326,18 +1353,6 @@ Added in v2.0.0

# sequencing

## chain

Alias of `flatMap`.

**Signature**

```ts
export declare const chain: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, B>
```

Added in v2.0.0

## chainFirst

Composes computations in sequence, using the return value of one computation to determine the next computation and
Expand Down Expand Up @@ -1385,7 +1400,7 @@ Added in v2.9.0

```ts
export declare const chainOptionK: <E>(
onNone: Lazy<E>
onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => (ma: Either<E, A>) => Either<E, B>
```

Expand All @@ -1401,24 +1416,12 @@ The `W` suffix (short for **W**idening) means that the error types will be merge

```ts
export declare const chainOptionKW: <E2>(
onNone: Lazy<E2>
onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>
```

Added in v2.13.2

## chainW

Alias of `flatMap`.

**Signature**

```ts
export declare const chainW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>
```

Added in v2.6.0

## flatMap

**Signature**
Expand Down
Loading