nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gcanti/fp-ts
Pull request #1501 (2021-04-30 16:29:38)

Add RTE.add-rte-chainFirstTaskEitherK(W)
port of #1500


Patch:
diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md
index 4291cef5..93d607b8 100644
--- a/docs/modules/ReaderTaskEither.ts.md
+++ b/docs/modules/ReaderTaskEither.ts.md
@@ -38,6 +38,8 @@ Added in v3.0.0
   - [chainFirstReaderKW](#chainfirstreaderkw)
   - [chainFirstReaderTaskK](#chainfirstreadertaskk)
   - [chainFirstReaderTaskKW](#chainfirstreadertaskkw)
+  - [chainFirstTaskEitherK](#chainfirsttaskeitherk)
+  - [chainFirstTaskEitherKW](#chainfirsttaskeitherkw)
   - [chainFirstTaskK](#chainfirsttaskk)
   - [chainFirstW](#chainfirstw)
   - [chainIOEitherK](#chainioeitherk)
@@ -422,6 +424,32 @@ export declare const chainFirstReaderTaskKW: <A, R2, B>(
 
 Added in v3.0.0
 
+## chainFirstTaskEitherK
+
+**Signature**
+
+```ts
+export declare const chainFirstTaskEitherK: <E, A, B>(
+  f: (a: A) => TE.TaskEither<E, B>
+) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
+```
+
+Added in v2.11.0
+
+## chainFirstTaskEitherKW
+
+Less strict version of [`chainFirstTaskEitherK`](#chainFirstTaskEitherK).
+
+**Signature**
+
+```ts
+export declare const chainFirstTaskEitherKW: <E2, A, B>(
+  f: (a: A) => TE.TaskEither<E2, B>
+) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>
+```
+
+Added in v2.11.0
+
 ## chainFirstTaskK
 
 **Signature**
diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts
index 6df55857..53ca9675 100644
--- a/src/ReaderTaskEither.ts
+++ b/src/ReaderTaskEither.ts
@@ -449,6 +449,24 @@ export const chainTaskEitherK: <E, A, B>(
   f: (a: A) => TaskEither<E, B>
 ) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = chainTaskEitherKW
 
+/**
+ * Less strict version of [`chainFirstTaskEitherK`](#chainFirstTaskEitherK).
+ *
+ * @category combinators
+ * @since 2.11.0
+ */
+export const chainFirstTaskEitherKW: <E2, A, B>(
+  f: (a: A) => TaskEither<E2, B>
+) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, A> = (f) => chainFirstW(fromTaskEitherK(f))
+
+/**
+ * @category combinators
+ * @since 2.11.0
+ */
+export const chainFirstTaskEitherK: <E, A, B>(
+  f: (a: A) => TaskEither<E, B>
+) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = chainFirstTaskEitherKW
+
 /**
  * @category combinators
  * @since 3.0.0


Test patch:
diff --git a/test/ReaderTaskEither.ts b/test/ReaderTaskEither.ts
index 02f3b3f7..0734a580 100644
--- a/test/ReaderTaskEither.ts
+++ b/test/ReaderTaskEither.ts
@@ -344,6 +344,11 @@ describe('ReaderTaskEither', () => {
     U.deepStrictEqual(await pipe(_.right('a'), _.chainTaskEitherK(f))(undefined)(), E.right(1))
   })
 
+  it('chainFirstTaskEitherKW', async () => {
+    const f = (s: string) => TE.right<number, string>(s.length)
+    U.deepStrictEqual(await pipe(_.right<string, {}, number>('a'), _.chainFirstTaskEitherKW(f))({})(), E.right('a'))
+  })
+
   it('chainReaderTaskK', async () => {
     const f = flow(S.size, RT.of)
     U.deepStrictEqual(await pipe(_.right('a'), _.chainReaderTaskK(f))(undefined)(), E.right(1))
Repository: gcanti/fp-ts
Pull request #1562 (2021-08-20 06:14:07)

Add chainFirstEitherK(W) in ReaderTaskEither module
**Before submitting a pull request,** please make sure the following is done:

- Fork [the repository](https://github.com/gcanti/fp-ts) and create your branch from `master`.
- Run `npm install` in the repository root.
- If you've fixed a bug or added code that should be tested, add tests!
- Ensure the test suite passes (`npm test`).

**Note**. If you've fixed a bug please link the related issue or, if missing, open an issue before sending a PR.

**Note**. If you find a typo in the **documentation**, make sure to modify the corresponding source (docs are generated).

**Note**. If you want to send a PR related to `fp-ts@1.x` please create your branch from `1.x`


vinassefranche: @gcanti is there something blocking on this P.R. I need this too :-)

Patch:
diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts
index dfa68bca..1158c1de 100644
--- a/src/ReaderTaskEither.ts
+++ b/src/ReaderTaskEither.ts
@@ -1156,6 +1156,24 @@ export const chainEitherKW: <E2, A, B>(
   f: (a: A) => Either<E2, B>
 ) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B> = chainEitherK as any
 
+/**
+ * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).
+ *
+ * @category combinators
+ * @since 2.12.0
+ */
+export const chainFirstEitherKW: <E2, A, B>(
+  f: (a: A) => Either<E2, B>
+) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, A> = (f) => chainFirstW(fromEitherK(f))
+
+/**
+ * @category combinators
+ * @since 2.12.0
+ */
+export const chainFirstEitherK: <E, A, B>(
+  f: (a: A) => Either<E, B>
+) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = chainFirstEitherKW
+
 /**
  * @category constructors
  * @since 2.0.0


Test patch:
diff --git a/test/ReaderTaskEither.ts b/test/ReaderTaskEither.ts
index e9d94ee0..a4047727 100644
--- a/test/ReaderTaskEither.ts
+++ b/test/ReaderTaskEither.ts
@@ -420,6 +420,11 @@ describe('ReaderTaskEither', () => {
     U.deepStrictEqual(await pipe(_.right('a'), _.chainEitherK(f))(undefined)(), E.right(1))
   })
 
+  it('chainFirstEitherKW', async () => {
+    const f = (s: string) => E.right<string, number>(s.length)
+    U.deepStrictEqual(await pipe(_.right<{}, number, string>('a'), _.chainFirstEitherKW(f))({})(), E.right('a'))
+  })
+
   it('chainIOEitherK', async () => {
     const f = (s: string) => IE.right(s.length)
     U.deepStrictEqual(await pipe(_.right('a'), _.chainIOEitherK(f))(undefined)(), E.right(1))
Repository: gcanti/fp-ts
Pull request #1659 (2022-01-15 14:18:39)

Add taskEither.chainFirstEitherK
This was missing.
I can do the port to the version 3 when this one is merged.


Patch:
diff --git a/docs/modules/TaskEither.ts.md b/docs/modules/TaskEither.ts.md
index ece6365b..abdff1af 100644
--- a/docs/modules/TaskEither.ts.md
+++ b/docs/modules/TaskEither.ts.md
@@ -45,6 +45,8 @@ Added in v2.0.0
   - [chainEitherK](#chaineitherk)
   - [chainEitherKW](#chaineitherkw)
   - [chainFirst](#chainfirst)
+  - [chainFirstEitherK](#chainfirsteitherk)
+  - [chainFirstEitherKW](#chainfirsteitherkw)
   - [chainFirstIOK](#chainfirstiok)
   - [chainFirstTaskK](#chainfirsttaskk)
   - [chainFirstW](#chainfirstw)
@@ -438,6 +440,30 @@ export declare const chainFirst: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma
 
 Added in v2.0.0
 
+## chainFirstEitherK
+
+**Signature**
+
+```ts
+export declare const chainFirstEitherK: <E, A, B>(
+  f: (a: A) => E.Either<E, B>
+) => (ma: TaskEither<E, A>) => TaskEither<E, A>
+```
+
+Added in v2.12.0
+
+## chainFirstEitherKW
+
+**Signature**
+
+```ts
+export declare const chainFirstEitherKW: <E2, A, B>(
+  f: (a: A) => E.Either<E2, B>
+) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>
+```
+
+Added in v2.12.0
+
 ## chainFirstIOK
 
 **Signature**
diff --git a/src/TaskEither.ts b/src/TaskEither.ts
index 5c230dce..ee1e7bb6 100644
--- a/src/TaskEither.ts
+++ b/src/TaskEither.ts
@@ -955,6 +955,22 @@ export const chainEitherKW: <E2, A, B>(
   f: (a: A) => Either<E2, B>
 ) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = chainEitherK as any
 
+/**
+ * @category combinators
+ * @since 2.12.0
+ */
+export const chainFirstEitherKW: <E2, A, B>(
+  f: (a: A) => E.Either<E2, B>
+) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = (f) => chainFirstW(fromEitherK(f))
+
+/**
+ * @category combinators
+ * @since 2.12.0
+ */
+export const chainFirstEitherK: <E, A, B>(
+  f: (a: A) => E.Either<E, B>
+) => (ma: TaskEither<E, A>) => TaskEither<E, A> = chainFirstEitherKW
+
 /**
  * @category constructors
  * @since 2.0.0


Test patch:
diff --git a/test/TaskEither.ts b/test/TaskEither.ts
index 2bc7a7d5..c3f72da4 100644
--- a/test/TaskEither.ts
+++ b/test/TaskEither.ts
@@ -461,6 +461,13 @@ describe('TaskEither', () => {
     U.deepStrictEqual(await pipe(_.right('a'), _.chainEitherK(f))(), E.right(1))
   })
 
+  it('chainFirstEitherK', async () => {
+    const f = (s: string) => E.right(s.length)
+    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(f))(), E.right('a'))
+    const g = (s: string) => E.left(s.length)
+    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(g))(), E.left(1))
+  })
+
   it('chainIOEitherK', async () => {
     const f = (s: string) => IE.right(s.length)
     U.deepStrictEqual(await pipe(_.right('a'), _.chainIOEitherK(f))(), E.right(1))
Repository: gcanti/fp-ts
Pull request #1662 (2022-01-17 10:16:14)

Add taskEither.chainFirstEitherK
port of #1659


Patch:
diff --git a/docs/modules/TaskEither.ts.md b/docs/modules/TaskEither.ts.md
index 3522fd83..1d1f438a 100644
--- a/docs/modules/TaskEither.ts.md
+++ b/docs/modules/TaskEither.ts.md
@@ -38,6 +38,8 @@ Added in v3.0.0
 - [combinators](#combinators)
   - [chainEitherK](#chaineitherk)
   - [chainEitherKW](#chaineitherkw)
+  - [chainFirstEitherK](#chainfirsteitherk)
+  - [chainFirstEitherKW](#chainfirsteitherkw)
   - [chainFirstIOK](#chainfirstiok)
   - [chainFirstTaskK](#chainfirsttaskk)
   - [chainFirstW](#chainfirstw)
@@ -339,6 +341,32 @@ export declare const chainEitherKW: <E2, A, B>(
 
 Added in v3.0.0
 
+## chainFirstEitherK
+
+**Signature**
+
+```ts
+export declare const chainFirstEitherK: <E, A, B>(
+  f: (a: A) => E.Either<E, B>
+) => (ma: TaskEither<E, A>) => TaskEither<E, A>
+```
+
+Added in v3.0.0
+
+## chainFirstEitherKW
+
+Less strict version of [`chainFirstEitherK`](#chainFirstEitherK).
+
+**Signature**
+
+```ts
+export declare const chainFirstEitherKW: <E2, A, B>(
+  f: (a: A) => E.Either<E2, B>
+) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>
+```
+
+Added in v3.0.0
+
 ## chainFirstIOK
 
 **Signature**
diff --git a/src/TaskEither.ts b/src/TaskEither.ts
index 5b2a7da0..8d09c514 100644
--- a/src/TaskEither.ts
+++ b/src/TaskEither.ts
@@ -892,6 +892,24 @@ export const chainEitherKW: <E2, A, B>(
   f: (a: A) => Either<E2, B>
 ) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = chainEitherK as any
 
+/**
+ * Less strict version of [`chainFirstEitherK`](#chainFirstEitherK).
+ *
+ * @category combinators
+ * @since 3.0.0
+ */
+export const chainFirstEitherKW: <E2, A, B>(
+  f: (a: A) => E.Either<E2, B>
+) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = (f) => chainFirstW(fromEitherK(f))
+
+/**
+ * @category combinators
+ * @since 3.0.0
+ */
+export const chainFirstEitherK: <E, A, B>(
+  f: (a: A) => E.Either<E, B>
+) => (ma: TaskEither<E, A>) => TaskEither<E, A> = chainFirstEitherKW
+
 /**
  * Derivable from `FromEither`.
  *


Test patch:
diff --git a/test/TaskEither.ts b/test/TaskEither.ts
index 36e93bf8..f9209fd6 100644
--- a/test/TaskEither.ts
+++ b/test/TaskEither.ts
@@ -396,6 +396,16 @@ describe('TaskEither', () => {
     U.deepStrictEqual(await pipe(_.right('a'), _.chainEitherK(f))(), E.right(1))
   })
 
+  it('chainFirstEitherK', async () => {
+    const f = (s: string) => E.right(s.length)
+    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(f))(), E.right('a'))
+    U.deepStrictEqual(await pipe(_.right<string, string>('a'), _.chainFirstEitherKW(f))(), E.right('a'))
+
+    const g = (s: string) => E.left(s.length)
+    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(g))(), E.left(1))
+    U.deepStrictEqual(await pipe(_.right<string, string>('a'), _.chainFirstEitherKW(g))(), E.left(1))
+  })
+
   it('chainIOEitherK', async () => {
     const f = flow(S.size, IE.of)
     U.deepStrictEqual(await pipe(_.right('a'), _.chainIOEitherK(f))(), E.right(1))
Repository: gcanti/fp-ts
Pull request #1766 (2022-09-08 14:15:27)

Flip the arguments of a curried function
This is the follow-up to #1748 on v3, replacing the deprecation. (The commits there haven't been merged into the new branch yet, so this will create a conflict if it does.)


Patch:
diff --git a/docs/modules/function.ts.md b/docs/modules/function.ts.md
index 8b701801..ca502a33 100644
--- a/docs/modules/function.ts.md
+++ b/docs/modules/function.ts.md
@@ -291,12 +291,22 @@ Added in v3.0.0
 
 ## flip
 
-Flips the order of the arguments of a function of two arguments.
+Flips the arguments of a curried function.
 
 **Signature**
 
 ```ts
-export declare const flip: <A, B, C>(f: (a: A, b: B) => C) => (b: B, a: A) => C
+export declare const flip: <A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C
+```
+
+**Example**
+
+```ts
+import { flip } from 'fp-ts/function'
+
+const f = (a: number) => (b: string) => a - b.length
+
+assert.strictEqual(flip(f)('aaa')(2), -1)
 ```
 
 Added in v3.0.0
diff --git a/dtslint/ts4.1/function.ts b/dtslint/ts4.1/function.ts
index f9264bb1..92c5a883 100644
--- a/dtslint/ts4.1/function.ts
+++ b/dtslint/ts4.1/function.ts
@@ -1,17 +1,6 @@
 import * as _ from '../../src/function'
 import * as A from '../../src/ReadonlyArray'
 
-//
-// flip
-//
-
-// should handle generics
-declare function snoc<A>(init: ReadonlyArray<A>, end: A): ReadonlyArray<A>
-_.flip(snoc) // $ExpectType <A>(b: A, a: readonly A[]) => ReadonlyArray<A>
-
-// $ExpectType <A>(init: readonly A[], end: A) => Option<A>
-_.flow(snoc, A.head)
-
 //
 // tupled
 //
diff --git a/src/function.ts b/src/function.ts
index ed693891..c931791f 100644
--- a/src/function.ts
+++ b/src/function.ts
@@ -199,11 +199,18 @@ export const constUndefined: Lazy<undefined> =
 export const constVoid: Lazy<void> = constUndefined
 
 /**
- * Flips the order of the arguments of a function of two arguments.
+ * Flips the arguments of a curried function.
+ *
+ * @example
+ * import { flip } from 'fp-ts/function'
+ *
+ * const f = (a: number) => (b: string) => a - b.length
+ *
+ * assert.strictEqual(flip(f)('aaa')(2), -1)
  *
  * @since 3.0.0
  */
-export const flip = <A, B, C>(f: (a: A, b: B) => C): ((b: B, a: A) => C) => (b, a) => f(a, b)
+export const flip = <A, B, C>(f: (a: A) => (b: B) => C): ((b: B) => (a: A) => C) => (b) => (a) => f(a)(b)
 
 /**
  * Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.


Test patch:
diff --git a/test/function.ts b/test/function.ts
index a579cc08..e6316984 100644
--- a/test/function.ts
+++ b/test/function.ts
@@ -12,8 +12,8 @@ const g = U.double
 
 describe('function', () => {
   it('flip', () => {
-    const f = (a: number, b: string) => a - b.length
-    U.deepStrictEqual(_.flip(f)('aaa', 2), -1)
+    const f = (a: number) => (b: string) => a - b.length
+    U.deepStrictEqual(_.flip(f)('aaa')(2), -1)
   })
 
   it('unsafeCoerce', () => {