From 22ebe0ddbacc0f75b22edbb68d8f866190c684a6 Mon Sep 17 00:00:00 2001 From: vinassefranche Date: Tue, 11 Jan 2022 15:03:07 +0100 Subject: [PATCH 1/3] Add ReaderTaskEither.bindEitherK --- docs/modules/ReaderTaskEither.ts.md | 32 +++++++++++++++++++++++++++++ src/ReaderTaskEither.ts | 18 ++++++++++++++++ test/ReaderTaskEither.ts | 12 +++++++++++ 3 files changed, 62 insertions(+) diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md index db57baeef3..229f9c53e0 100644 --- a/docs/modules/ReaderTaskEither.ts.md +++ b/docs/modules/ReaderTaskEither.ts.md @@ -37,6 +37,8 @@ Added in v2.0.0 - [apSecondW](#apsecondw) - [asksReaderTaskEither](#asksreadertaskeither) - [asksReaderTaskEitherW](#asksreadertaskeitherw) + - [bindEitherK](#bindeitherk) + - [bindEitherKW](#bindeitherkw) - [chainEitherK](#chaineitherk) - [chainEitherKW](#chaineitherkw) - [chainFirst](#chainfirst) @@ -427,6 +429,36 @@ export declare const asksReaderTaskEitherW: ( Added in v2.11.0 +## bindEitherK + +**Signature** + +```ts +export declare const bindEitherK: ( + name: Exclude, + f: (a: A) => E.Either +) => ( + ma: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + +## bindEitherKW + +**Signature** + +```ts +export declare const bindEitherKW: ( + name: Exclude, + f: (a: A) => E.Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + ## chainEitherK **Signature** diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts index 0399475193..dace291b36 100644 --- a/src/ReaderTaskEither.ts +++ b/src/ReaderTaskEither.ts @@ -1377,6 +1377,24 @@ export const bindW: ( fa: ReaderTaskEither ) => ReaderTaskEither = bind as any +/** + * @category combinators + * @since 2.12.0 + */ +export const bindEitherK = (name: Exclude, f: (a: A) => Either) => + bind(name, (a) => fromEither(f(a))) + +/** + * @category combinators + * @since 2.12.0 + */ +export const bindEitherKW: ( + name: Exclude, + f: (a: A) => Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither = bindEitherK as any + // ------------------------------------------------------------------------------------- // pipeable sequence S // ------------------------------------------------------------------------------------- diff --git a/test/ReaderTaskEither.ts b/test/ReaderTaskEither.ts index 3a72f296c2..2fc940a976 100644 --- a/test/ReaderTaskEither.ts +++ b/test/ReaderTaskEither.ts @@ -492,6 +492,18 @@ describe('ReaderTaskEither', () => { ) }) + it('bindEitherK', async () => { + U.deepStrictEqual( + await pipe( + _.right(1), + _.bindTo('a'), + _.bindEitherK('b', () => E.right('b')), + _.bindEitherKW('c', () => E.right('c')) + )(undefined)(), + E.right({ a: 1, b: 'b', c: 'c' }) + ) + }) + it('apS', async () => { U.deepStrictEqual( await pipe(_.right(1), _.bindTo('a'), _.apS('b', _.right('b')))(undefined)(), From 7a2ba6e24c9d7671282daaccc0c6bf3e22f97e47 Mon Sep 17 00:00:00 2001 From: vinassefranche Date: Mon, 17 Jan 2022 09:39:17 +0100 Subject: [PATCH 2/3] Remove the combinators category --- docs/modules/ReaderTaskEither.ts.md | 64 ++++++++++++++--------------- src/ReaderTaskEither.ts | 2 - 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md index 229f9c53e0..88ee9fe905 100644 --- a/docs/modules/ReaderTaskEither.ts.md +++ b/docs/modules/ReaderTaskEither.ts.md @@ -37,8 +37,6 @@ Added in v2.0.0 - [apSecondW](#apsecondw) - [asksReaderTaskEither](#asksreadertaskeither) - [asksReaderTaskEitherW](#asksreadertaskeitherw) - - [bindEitherK](#bindeitherk) - - [bindEitherKW](#bindeitherkw) - [chainEitherK](#chaineitherk) - [chainEitherKW](#chaineitherkw) - [chainFirst](#chainfirst) @@ -161,6 +159,8 @@ Added in v2.0.0 - [apS](#aps) - [apSW](#apsw) - [bind](#bind) + - [bindEitherK](#bindeitherk) + - [bindEitherKW](#bindeitherkw) - [bindTo](#bindto) - [bindW](#bindw) - [bracket](#bracket) @@ -429,36 +429,6 @@ export declare const asksReaderTaskEitherW: ( Added in v2.11.0 -## bindEitherK - -**Signature** - -```ts -export declare const bindEitherK: ( - name: Exclude, - f: (a: A) => E.Either -) => ( - ma: ReaderTaskEither -) => ReaderTaskEither -``` - -Added in v2.12.0 - -## bindEitherKW - -**Signature** - -```ts -export declare const bindEitherKW: ( - name: Exclude, - f: (a: A) => E.Either -) => ( - fa: ReaderTaskEither -) => ReaderTaskEither -``` - -Added in v2.12.0 - ## chainEitherK **Signature** @@ -1855,6 +1825,36 @@ export declare const bind: ( Added in v2.8.0 +## bindEitherK + +**Signature** + +```ts +export declare const bindEitherK: ( + name: Exclude, + f: (a: A) => E.Either +) => ( + ma: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + +## bindEitherKW + +**Signature** + +```ts +export declare const bindEitherKW: ( + name: Exclude, + f: (a: A) => E.Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + ## bindTo **Signature** diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts index dace291b36..5abe1f2536 100644 --- a/src/ReaderTaskEither.ts +++ b/src/ReaderTaskEither.ts @@ -1378,14 +1378,12 @@ export const bindW: ( ) => ReaderTaskEither = bind as any /** - * @category combinators * @since 2.12.0 */ export const bindEitherK = (name: Exclude, f: (a: A) => Either) => bind(name, (a) => fromEither(f(a))) /** - * @category combinators * @since 2.12.0 */ export const bindEitherKW: ( From af8d37094e189eb9fb5b95208ba3e1f6e4197f2c Mon Sep 17 00:00:00 2001 From: vinassefranche Date: Mon, 17 Jan 2022 10:26:37 +0100 Subject: [PATCH 3/3] Add ReaderTaskEither.apEitherSK --- docs/modules/ReaderTaskEither.ts.md | 32 +++++++++++++++++++++++++++++ src/ReaderTaskEither.ts | 16 +++++++++++++++ test/ReaderTaskEither.ts | 12 +++++++++++ 3 files changed, 60 insertions(+) diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md index 88ee9fe905..92a463ebbe 100644 --- a/docs/modules/ReaderTaskEither.ts.md +++ b/docs/modules/ReaderTaskEither.ts.md @@ -156,6 +156,8 @@ Added in v2.0.0 - [utils](#utils) - [ApT](#apt) - [Do](#do) + - [apEitherSK](#apeithersk) + - [apEitherSKW](#apeitherskw) - [apS](#aps) - [apSW](#apsw) - [bind](#bind) @@ -1780,6 +1782,36 @@ export declare const Do: ReaderTaskEither Added in v2.9.0 +## apEitherSK + +**Signature** + +```ts +export declare const apEitherSK: ( + name: Exclude, + f: E.Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + +## apEitherSKW + +**Signature** + +```ts +export declare const apEitherSKW: ( + name: Exclude, + f: E.Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither +``` + +Added in v2.12.0 + ## apS **Signature** diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts index 5abe1f2536..68b0164f4f 100644 --- a/src/ReaderTaskEither.ts +++ b/src/ReaderTaskEither.ts @@ -1414,6 +1414,22 @@ export const apSW: ( fa: ReaderTaskEither ) => ReaderTaskEither = apS as any +/** + * @since 2.12.0 + */ +export const apEitherSK = (name: Exclude, f: Either) => + apS(name, fromEither(f)) + +/** + * @since 2.12.0 + */ +export const apEitherSKW: ( + name: Exclude, + f: Either +) => ( + fa: ReaderTaskEither +) => ReaderTaskEither = apEitherSK as any + // ------------------------------------------------------------------------------------- // sequence T // ------------------------------------------------------------------------------------- diff --git a/test/ReaderTaskEither.ts b/test/ReaderTaskEither.ts index 2fc940a976..9d9772a9b2 100644 --- a/test/ReaderTaskEither.ts +++ b/test/ReaderTaskEither.ts @@ -511,6 +511,18 @@ describe('ReaderTaskEither', () => { ) }) + it('apEitherSK', async () => { + U.deepStrictEqual( + await pipe( + _.right(1), + _.bindTo('a'), + _.apEitherSK('b', E.right('b')), + _.apEitherSKW('c', E.right('c')) + )(undefined)(), + E.right({ a: 1, b: 'b', c: 'c' }) + ) + }) + describe('array utils', () => { const input: ReadonlyNonEmptyArray = ['a', 'b']