Skip to content

flip

flip<A, B, C>(f): (b) => (a) => C

Defined in: Composition/flip.ts:20

Flips the order of arguments for a curried binary function. Converts a data-last function to data-first.

A

B

C

(a) => (b) => C

(b): (a) => C

B

(a): C

A

C

// Original data-last (for pipe)
pipe(
  Option.of(5),
  Option.map(n => n * 2)
); // Some(10)

// Flipped to data-first
const mapFirst = flip(Option.map);
mapFirst(Option.of(5))(n => n * 2); // Some(10)

uncurry for converting curried functions to multi-argument functions