Hyperlinkv0.8.0-beta.28

Function

Function.tupledconsteffect/Function.ts:545
<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)
combinatorsuntupled
export const tupled = <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => B => (a) => f(...a)