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.

The function must have a concrete two-stage type. Generic container helpers such as Maybe.map are higher-kinded and cannot be flipped directly; wrap them in a concrete function first.

A

B

C

(a) => (b) => C

(b) => (a) => C

const prepend = (prefix: string) => (text: string) => prefix + text;
const append = flip(prepend);

prepend("Hello, ")("World"); // "Hello, World"
append("World")("Hello, ");  // "Hello, World"

uncurry for converting curried functions to multi-argument functions