diff --git a/docs/modules/StateReaderTaskEither.ts.md b/docs/modules/StateReaderTaskEither.ts.md index c626c7b77..bfc91e880 100644 --- a/docs/modules/StateReaderTaskEither.ts.md +++ b/docs/modules/StateReaderTaskEither.ts.md @@ -32,7 +32,9 @@ Added in v2.0.0 - [of](#of) - [combinators](#combinators) - [apFirst](#apfirst) + - [apFirstW](#apfirstw) - [apSecond](#apsecond) + - [apSecondW](#apsecondw) - [asksStateReaderTaskEither](#asksstatereadertaskeither) - [asksStateReaderTaskEitherW](#asksstatereadertaskeitherw) - [chainEitherK](#chaineitherk) @@ -322,6 +324,20 @@ export declare const apFirst: ( Added in v2.0.0 +## apFirstW + +Less strict version of [`apFirst`](#apfirst). + +**Signature** + +```ts +export declare const apFirstW: ( + second: StateReaderTaskEither +) => (first: StateReaderTaskEither) => StateReaderTaskEither +``` + +Added in v2.12.0 + ## apSecond Combine two effectful actions, keeping only the result of the second. @@ -338,6 +354,20 @@ export declare const apSecond: ( Added in v2.0.0 +## apSecondW + +Less strict version of [`apSecond`](#apsecond). + +**Signature** + +```ts +export declare const apSecondW: ( + second: StateReaderTaskEither +) => (first: StateReaderTaskEither) => StateReaderTaskEither +``` + +Added in v2.12.0 + ## asksStateReaderTaskEither Effectfully accesses the environment. diff --git a/src/StateReaderTaskEither.ts b/src/StateReaderTaskEither.ts index a25de670b..07f80405f 100644 --- a/src/StateReaderTaskEither.ts +++ b/src/StateReaderTaskEither.ts @@ -591,6 +591,18 @@ export const apFirst = /*#__PURE__*/ apFirst_(Apply) +/** + * Less strict version of [`apFirst`](#apfirst). + * + * @category combinators + * @since 2.12.0 + */ +export const apFirstW: ( + second: StateReaderTaskEither +) => ( + first: StateReaderTaskEither +) => StateReaderTaskEither = apFirst as any + /** * Combine two effectful actions, keeping only the result of the second. * @@ -603,6 +615,18 @@ export const apSecond = /*#__PURE__*/ apSecond_(Apply) +/** + * Less strict version of [`apSecond`](#apsecond). + * + * @category combinators + * @since 2.12.0 + */ +export const apSecondW: ( + second: StateReaderTaskEither +) => ( + first: StateReaderTaskEither +) => StateReaderTaskEither = apSecond as any + /** * @category instances * @since 2.7.0 diff --git a/test/StateReaderTaskEither.ts b/test/StateReaderTaskEither.ts index 7a5517f1a..1c6968291 100644 --- a/test/StateReaderTaskEither.ts +++ b/test/StateReaderTaskEither.ts @@ -61,11 +61,25 @@ describe('StateReaderTaskEither', () => { U.deepStrictEqual(e, E.right('a')) }) + it('apFirstW', async () => { + const fa = _.right('a') + const fb = _.right(6) + const e = await pipe(fa, _.apFirstW(fb), _.evaluate(state))({ k: 'v', x: 5 })() + U.deepStrictEqual(e, E.right('a')) + }) + it('apSecond', async () => { const e = await pipe(_.right('a'), _.apSecond(_.right('b')), _.evaluate(state))({})() U.deepStrictEqual(e, E.right('b')) }) + it('apSecondW', async () => { + const fa = _.right('a') + const fb = _.right(6) + const e = await pipe(fa, _.apSecondW(fb), _.evaluate(state))({ k: 'v', x: 5 })() + U.deepStrictEqual(e, E.right(6)) + }) + it('chain', async () => { const f = (s: string) => (s.length > 2 ? _.right(s.length) : _.right(0)) const e = await pipe(_.right('aaa'), _.chain(f), _.evaluate(state))({})()