Skip to content

Commit

Permalink
feat: tapReaderTask
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej committed May 20, 2023
1 parent 8ff1247 commit 456baa4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/modules/ReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Added in v2.0.0
- [tapIO](#tapio)
- [tapReader](#tapreader)
- [tapReaderEither](#tapreadereither)
- [tapReaderTask](#tapreadertask)
- [tapTask](#taptask)
- [tapTaskEither](#taptaskeither)
- [constructors](#constructors)
Expand Down Expand Up @@ -343,6 +344,28 @@ export declare const tapReaderEither: {

Added in v2.16.0

## tapReaderTask

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 tapReaderTask: {
<R1, R2, E, A, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RT.ReaderTask<R2, _>): ReaderTaskEither<
R1 & R2,
E,
A
>
<R2, A, _>(f: (a: A) => RT.ReaderTask<R2, _>): <R1, E>(
self: ReaderTaskEither<R1, E, A>
) => ReaderTaskEither<R1 & R2, E, A>
}
```

Added in v2.16.0

## tapTask

Composes computations in sequence, using the return value of one computation to determine the next computation and
Expand Down
20 changes: 20 additions & 0 deletions src/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,26 @@ export const tapTaskEither: {
): ReaderTaskEither<R, E1 | E2, A> => tap(self, fromTaskEitherK(f))
)

/**
* Composes computations in sequence, using the return value of one computation to determine the next computation and
* keeping only the result of the first.
*
* @category combinators
* @since 2.16.0
*/
export const tapReaderTask: {
<R1, R2, E, A, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderTask<R2, _>): ReaderTaskEither<R1 & R2, E, A>
<R2, A, _>(f: (a: A) => ReaderTask<R2, _>): <R1, E>(
self: ReaderTaskEither<R1, E, A>
) => ReaderTaskEither<R1 & R2, E, A>
} = /*#__PURE__*/ dual(
2,
<R1, R2, E, A, _>(
self: ReaderTaskEither<R1, E, A>,
f: (a: A) => ReaderTask<R2, _>
): ReaderTaskEither<R1 & R2, E, A> => tap(self, fromReaderTaskK(f))
)

/**
* @category instances
* @since 2.7.0
Expand Down
4 changes: 4 additions & 0 deletions test/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,4 +782,8 @@ describe.concurrent('ReaderTaskEither', () => {
it('tapTaskEither', async () => {
U.deepStrictEqual(await _.tapTaskEither(_.of(1), () => TE.of(2))({})(), E.of(1))
})

it('tapReaderTask', async () => {
U.deepStrictEqual(await _.tapReaderTask(_.of(1), () => RT.of(2))({})(), E.of(1))
})
})

0 comments on commit 456baa4

Please sign in to comment.