<A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BCreates a tupled version of this function: instead of n arguments, it accepts a single tuple argument.
When to use
Use to adapt a multi-argument function so it accepts one tuple argument.
Example (Converting arguments to a tuple)
import { Function } from "effect"
import * as assert from "node:assert"
const sumTupled = Function.tupled((x: number, y: number): number => x + y)
assert.deepStrictEqual(sumTupled([1, 2]), 3)combinatorsuntupled
Source effect/Function.ts:5451 lines
export const const tupled: <
A extends ReadonlyArray<unknown>,
B
>(
f: (...a: A) => B
) => (a: A) => B
Creates a tupled version of this function: instead of n arguments, it accepts a single tuple argument.
When to use
Use to adapt a multi-argument function so it accepts one tuple argument.
Example (Converting arguments to a tuple)
import { Function } from "effect"
import * as assert from "node:assert"
const sumTupled = Function.tupled((x: number, y: number): number => x + y)
assert.deepStrictEqual(sumTupled([1, 2]), 3)
tupled = <function (type parameter) A in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BA extends interface ReadonlyArray<T>ReadonlyArray<unknown>, function (type parameter) B in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BB>(f: (...a: A) => Bf: (...a: A extends ReadonlyArray<unknown>a: function (type parameter) A in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BA) => function (type parameter) B in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BB): (a: A extends ReadonlyArray<unknown>a: function (type parameter) A in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BA) => function (type parameter) B in <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => BB => (a: A extends ReadonlyArray<unknown>a) => f: (...a: A) => Bf(...a: A extends ReadonlyArray<unknown>a)