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 rte from reader io #1800

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions docs/modules/ReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Added in v2.0.0
- [fromOption](#fromoption)
- [fromReader](#fromreader)
- [fromReaderEither](#fromreadereither)
- [fromReaderIO](#fromreaderio)
- [fromTask](#fromtask)
- [fromTaskEither](#fromtaskeither)
- [toUnion](#tounion)
Expand Down Expand Up @@ -446,6 +447,16 @@ export declare const fromReaderEither: <R, E, A>(fa: ReaderEither<R, E, A>) => R

Added in v2.0.0

## fromReaderIO

**Signature**

```ts
export declare const fromReaderIO: <R, A, E = never>(fa: RIO.ReaderIO<R, A>) => ReaderTaskEither<R, E, A>
```

Added in v2.13.2

## fromTask

**Signature**
Expand Down
6 changes: 6 additions & 0 deletions src/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export const fromIOEither: <E, A, R = unknown>(fa: IOEither<E, A>) => ReaderTask
export const fromReaderEither: <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderTaskEither<R, E, A> = (ma) =>
flow(ma, TE.fromEither)

/**
* @category conversions
* @since 2.13.2
*/
export const fromReaderIO: <R, A, E = never>(fa: ReaderIO<R, A>) => ReaderTaskEither<R, E, A> = R.map(TE.fromIO)

/**
* @category pattern matching
* @since 2.10.0
Expand Down
4 changes: 4 additions & 0 deletions test/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ describe('ReaderTaskEither', () => {
U.deepStrictEqual(await _.fromIOEither(() => E.left('error'))({})(), E.left('error'))
})

it('fromReaderIO', async () => {
U.deepStrictEqual(await _.fromReaderIO(RIO.of(1))({})(), E.right(1))
})

it('fold', async () => {
const fold = _.fold(
(l: string) => R.of(T.of(l.length)),
Expand Down