Skip to content

Commit

Permalink
feat: tapTask
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej authored and gcanti committed May 19, 2023
1 parent 75920e8 commit e5abd49
Show file tree
Hide file tree
Showing 16 changed files with 504 additions and 157 deletions.
60 changes: 49 additions & 11 deletions docs/modules/ReaderTask.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Added in v2.3.0
- [combinators](#combinators)
- [tap](#tap)
- [tapIO](#tapio)
- [tapTask](#taptask)
- [constructors](#constructors)
- [ask](#ask)
- [asks](#asks)
Expand Down Expand Up @@ -52,6 +53,7 @@ Added in v2.3.0
- [chain](#chain)
- [chainFirst](#chainfirst)
- [chainFirstIOK](#chainfirstiok)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainFirstW](#chainfirstw)
- [chainW](#chainw)
- [lifting](#lifting)
Expand All @@ -71,7 +73,6 @@ Added in v2.3.0
- [chainFirstReaderIOKW](#chainfirstreaderiokw)
- [chainFirstReaderK](#chainfirstreaderk)
- [chainFirstReaderKW](#chainfirstreaderkw)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainIOK](#chainiok)
- [chainReaderIOK](#chainreaderiok)
- [chainReaderIOKW](#chainreaderiokw)
Expand Down Expand Up @@ -165,6 +166,41 @@ test()

Added in v2.16.0

## tapTask

Composes computations in sequence, using the return value of one computation to determine the next computation and
keeping only the result of the first.

**Signature**

```ts
export declare const tapTask: {
<R, A, _>(self: ReaderTask<R, A>, f: (a: A) => T.Task<_>): ReaderTask<R, A>
<A, _>(f: (a: A) => T.Task<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>
}
```

**Example**

```ts
import { pipe } from 'fp-ts/function'
import * as RT from 'fp-ts/ReaderTask'
import * as T from 'fp-ts/Task'

const effect = pipe(
RT.ask<number>(),
RT.tapTask((value) => T.of(value + 1))
)

async function test() {
assert.deepStrictEqual(await effect(1)(), 1)
}

test()
```

Added in v2.16.0

# constructors

## ask
Expand Down Expand Up @@ -542,6 +578,18 @@ export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: Rea

Added in v2.10.0

## chainFirstTaskK

Alias of `tapTask`.

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>
```

Added in v2.10.0

## chainFirstW

Alias of `tap`.
Expand Down Expand Up @@ -742,16 +790,6 @@ export declare const chainFirstReaderKW: <A, R1, B>(

Added in v2.11.0

## chainFirstTaskK

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>
```

Added in v2.10.0

## chainIOK

**Signature**
Expand Down
61 changes: 48 additions & 13 deletions docs/modules/ReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Added in v2.0.0
- [tap](#tap)
- [tapEither](#tapeither)
- [tapIO](#tapio)
- [tapTask](#taptask)
- [constructors](#constructors)
- [ask](#ask)
- [asks](#asks)
Expand Down Expand Up @@ -97,6 +98,7 @@ Added in v2.0.0
- [chainFirstEitherK](#chainfirsteitherk)
- [chainFirstEitherKW](#chainfirsteitherkw)
- [chainFirstIOK](#chainfirstiok)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainFirstW](#chainfirstw)
- [chainNullableK](#chainnullablek)
- [chainOptionK](#chainoptionk)
Expand Down Expand Up @@ -145,7 +147,6 @@ Added in v2.0.0
- [chainFirstReaderTaskKW](#chainfirstreadertaskkw)
- [chainFirstTaskEitherK](#chainfirsttaskeitherk)
- [chainFirstTaskEitherKW](#chainfirsttaskeitherkw)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainIOEitherK](#chainioeitherk)
- [chainIOEitherKW](#chainioeitherkw)
- [chainIOK](#chainiok)
Expand Down Expand Up @@ -299,6 +300,38 @@ test()

Added in v2.16.0

## tapTask

Composes computations in sequence, using the return value of one computation to determine the next computation and
keeping only the result of the first.

**Signature**

```ts
export declare const tapTask: {
<R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => T.Task<_>): ReaderTaskEither<R, E, A>
<A, _>(f: (a: A) => T.Task<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
}
```

**Example**

```ts
import * as RTE from 'fp-ts/ReaderTaskEither'
import * as E from 'fp-ts/Either'
import * as T from 'fp-ts/Task'

const effect = RTE.tapTask(RTE.ask<number>(), (value) => T.of(value + 1))

async function test() {
assert.deepStrictEqual(await effect(1)(), E.of(1))
}

test()
```

Added in v2.16.0

# constructors

## ask
Expand Down Expand Up @@ -1219,6 +1252,20 @@ export declare const chainFirstIOK: <A, B>(

Added in v2.10.0

## chainFirstTaskK

Alias of `tapTask`.

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(
f: (a: A) => T.Task<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
```

Added in v2.10.0

## chainFirstW

Alias of `tap`.
Expand Down Expand Up @@ -1818,18 +1865,6 @@ export declare const chainFirstTaskEitherKW: <E2, A, B>(

Added in v2.11.0

## chainFirstTaskK

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(
f: (a: A) => T.Task<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
```

Added in v2.10.0

## chainIOEitherK

**Signature**
Expand Down
45 changes: 32 additions & 13 deletions docs/modules/StateReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Added in v2.0.0
- [tap](#tap)
- [tapEither](#tapeither)
- [tapIO](#tapio)
- [tapTask](#taptask)
- [constructors](#constructors)
- [ask](#ask)
- [asks](#asks)
Expand Down Expand Up @@ -79,6 +80,7 @@ Added in v2.0.0
- [chainFirstEitherK](#chainfirsteitherk)
- [chainFirstEitherKW](#chainfirsteitherkw)
- [chainFirstIOK](#chainfirstiok)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainFirstW](#chainfirstw)
- [chainW](#chainw)
- [lifting](#lifting)
Expand All @@ -105,7 +107,6 @@ Added in v2.0.0
- [chainEitherKW](#chaineitherkw)
- [chainFirstReaderK](#chainfirstreaderk)
- [chainFirstReaderKW](#chainfirstreaderkw)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainIOEitherK](#chainioeitherk)
- [chainIOEitherKW](#chainioeitherkw)
- [chainIOK](#chainiok)
Expand Down Expand Up @@ -218,6 +219,22 @@ export declare const tapIO: {

Added in v2.16.0

## tapTask

Composes computations in sequence, using the return value of one computation to determine the next computation and
keeping only the result of the first.

**Signature**

```ts
export declare const tapTask: {
<S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<_>): StateReaderTaskEither<S, R, E, A>
<A, _>(f: (a: A) => Task<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
}
```

Added in v2.16.0

# constructors

## ask
Expand Down Expand Up @@ -888,6 +905,20 @@ export declare const chainFirstIOK: <A, B>(

Added in v2.10.0

## chainFirstTaskK

Alias of `tapTask`.

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(
f: (a: A) => Task<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
```

Added in v2.10.0

## chainFirstW

Alias of `tap`.
Expand Down Expand Up @@ -1193,18 +1224,6 @@ export declare const chainFirstReaderKW: <A, R1, B>(

Added in v2.11.0

## chainFirstTaskK

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(
f: (a: A) => Task<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
```

Added in v2.10.0

## chainIOEitherK

**Signature**
Expand Down
57 changes: 46 additions & 11 deletions docs/modules/TaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Added in v2.0.0
- [tap](#tap)
- [tapEither](#tapeither)
- [tapIO](#tapio)
- [tapTask](#taptask)
- [constructors](#constructors)
- [left](#left)
- [leftIO](#leftio)
Expand Down Expand Up @@ -96,6 +97,7 @@ Added in v2.0.0
- [chainFirstEitherK](#chainfirsteitherk)
- [chainFirstEitherKW](#chainfirsteitherkw)
- [chainFirstIOK](#chainfirstiok)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainFirstW](#chainfirstw)
- [chainNullableK](#chainnullablek)
- [chainOptionK](#chainoptionk)
Expand Down Expand Up @@ -130,7 +132,6 @@ Added in v2.0.0
- [matchEW](#matchew)
- [matchW](#matchw)
- [sequencing](#sequencing)
- [chainFirstTaskK](#chainfirsttaskk)
- [chainIOEitherK](#chainioeitherk)
- [chainIOEitherKW](#chainioeitherkw)
- [chainIOK](#chainiok)
Expand Down Expand Up @@ -275,6 +276,38 @@ test()

Added in v2.16.0

## tapTask

Composes computations in sequence, using the return value of one computation to determine the next computation and
keeping only the result of the first.

**Signature**

```ts
export declare const tapTask: {
<E, A, _>(self: TaskEither<E, A>, f: (a: A) => T.Task<_>): TaskEither<E, A>
<A, _>(f: (a: A) => T.Task<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>
}
```

**Example**

```ts
import * as TE from 'fp-ts/TaskEither'
import * as T from 'fp-ts/Task'
import * as E from 'fp-ts/Either'

const effect = TE.tapIO(TE.of(1), (value) => T.of(value + 1))

async function test() {
assert.deepStrictEqual(await effect(), E.of(1))
}

test()
```

Added in v2.16.0

# constructors

## left
Expand Down Expand Up @@ -1217,6 +1250,18 @@ export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: Tas

Added in v2.10.0

## chainFirstTaskK

Alias of `tapTask`.

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>
```

Added in v2.10.0

## chainFirstW

Alias of `tap`.
Expand Down Expand Up @@ -1616,16 +1661,6 @@ Added in v2.10.0

# sequencing

## chainFirstTaskK

**Signature**

```ts
export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>
```

Added in v2.10.0

## chainIOEitherK

**Signature**
Expand Down

0 comments on commit e5abd49

Please sign in to comment.