/** * Provides small helpers for defining and reusing TypeScript functions. * * The main helpers are `pipe` and `flow` for left-to-right composition and * `dual` for APIs that support both direct and pipe-friendly call styles. The * module also contains small identity, constant, tuple, type-level, and * memoization helpers used across the library. * * @stability stable * @since 2.0.0 */ import type { TypeLambda } from "./HKT.ts"; /** * Type lambda for function types, used for higher-kinded type operations. * * **When to use** * * Use when defining higher-kinded abstractions that must accept function types * as one of their type-lambda inputs. * * **Example** (Creating a function type with a type lambda) * * ```ts import.meta.vitest * import type { Function, HKT } from "effect" * * // Create a function type using the type lambda * type StringToNumber = HKT.Kind * // Equivalent to: (a: string) => number * ``` * * @stability stable * @category utility types * @since 2.0.0 */ export interface FunctionTypeLambda extends TypeLambda { readonly type: (a: this["In"]) => this["Target"]; } /** * Creates a function that can be called in data-first style or data-last * (`pipe`-friendly) style. * * **When to use** * * Use to expose one implementation through both direct and `pipe`-friendly * call styles. * * **Details** * * Pass either the arity of the uncurried function or a predicate that decides * whether the current call is data-first. Arity is the common case. Use a * predicate when optional arguments make arity ambiguous. * * **Example** (Selecting data-first or data-last style by arity) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >(2, (self, that) => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Defining overloads with call signatures) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum: { * (that: number): (self: number) => number * (self: number, that: number): number * } = Function.dual(2, (self: number, that: number): number => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Selecting data-first or data-last style with a predicate) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >( * (args) => args.length === 2, * (self, that) => self + that * ) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * @stability stable * @category combinators * @since 2.0.0 */ export declare const dual: { /** * Creates a function that can be called in data-first style or data-last * (`pipe`-friendly) style. * * **When to use** * * Use to expose one implementation through both direct and `pipe`-friendly * call styles. * * **Details** * * Pass either the arity of the uncurried function or a predicate that decides * whether the current call is data-first. Arity is the common case. Use a * predicate when optional arguments make arity ambiguous. * * **Example** (Selecting data-first or data-last style by arity) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >(2, (self, that) => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Defining overloads with call signatures) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum: { * (that: number): (self: number) => number * (self: number, that: number): number * } = Function.dual(2, (self: number, that: number): number => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Selecting data-first or data-last style with a predicate) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >( * (args) => args.length === 2, * (self, that) => self + that * ) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * @stability stable * @category combinators * @since 2.0.0 */ ) => any, DataFirst extends (...args: Array) => any>(arity: Parameters["length"], body: DataFirst): DataLast & DataFirst; /** * Creates a function that can be called in data-first style or data-last * (`pipe`-friendly) style. * * **When to use** * * Use to expose one implementation through both direct and `pipe`-friendly * call styles. * * **Details** * * Pass either the arity of the uncurried function or a predicate that decides * whether the current call is data-first. Arity is the common case. Use a * predicate when optional arguments make arity ambiguous. * * **Example** (Selecting data-first or data-last style by arity) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >(2, (self, that) => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Defining overloads with call signatures) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum: { * (that: number): (self: number) => number * (self: number, that: number): number * } = Function.dual(2, (self: number, that: number): number => self + that) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * **Example** (Selecting data-first or data-last style with a predicate) * * ```ts import.meta.vitest * import { Function, pipe } from "effect" * * const sum = Function.dual< * (that: number) => (self: number) => number, * (self: number, that: number) => number * >( * (args) => args.length === 2, * (self, that) => self + that * ) * * sum(2, 3) // => 5 * pipe(2, sum(3)) // => 5 * ``` * * @stability stable * @category combinators * @since 2.0.0 */ ) => any, DataFirst extends (...args: Array) => any>(isDataFirst: (args: IArguments) => boolean, body: DataFirst): DataLast & DataFirst; }; /** * Applies a function to a given value. * * **When to use** * * Use to pass a fixed value into a unary function, especially when the function * is the value flowing through `pipe`. * * **Details** * * `apply(a)(f)` is equivalent to `f(a)`. * * **Example** (Applying an argument to a function) * * ```ts import.meta.vitest * import { Function, pipe, String } from "effect" * * pipe(String.length, Function.apply("hello")) // => 5 * ``` * * @see {@link pipe} for building left-to-right pipelines * * @stability stable * @category combinators * @since 2.0.0 */ export declare const apply: (a: A) => (self: (a: A) => B) => B; /** * A zero-argument function that produces a value when invoked. * * **When to use** * * Use to type a lazy value provider that should not run until called. * * **Example** (Creating a lazy argument) * * ```ts import.meta.vitest * import { Function } from "effect" * * const constNull: Function.LazyArg = Function.constant(null) * constNull() // => null * ``` * * @stability stable * @category models * @since 2.0.0 */ export type LazyArg = () => A; /** * Represents a function with multiple arguments. * * **When to use** * * Use to describe a function whose argument list is represented as a tuple * type. * * **Example** (Typing a variadic function) * * ```ts import.meta.vitest * import type { Function } from "effect" * * const sum: Function.FunctionN<[number, number], number> = (a, b) => a + b * sum(2, 3) // => 5 * ``` * * @stability stable * @category models * @since 2.0.0 */ export type FunctionN, B> = (...args: A) => B; /** * Returns its input argument unchanged. * * **When to use** * * Use to return a value unchanged where a function is required. * * **Example** (Returning the same value) * * ```ts import.meta.vitest * import { identity } from "effect" * * identity(5) // => 5 * ``` * * @stability stable * @category combinators * @since 2.0.0 */ export declare const identity: (a: A) => A; /** * Ensures that the type of an expression matches some type, * without changing the resulting type of that expression. * * **When to use** * * Use to check assignability while preserving the expression's precise inferred * type. * * **Example** (Checking an expression against a type) * * ```ts import.meta.vitest * import { Function } from "effect" * * const test1 = Function.satisfies()(5 as const) // => 5 * // ^? const test: 5 * // @ts-expect-error * const test2 = Function.satisfies()(5) * // ^? Argument of type 'number' is not assignable to parameter of type 'string' * ``` * * @see {@link cast} for changing only the static TypeScript type * * @stability stable * @category utility types * @since 2.0.0 */ export declare const satisfies: () => (b: B) => B; /** * Returns the input value with a different static type. * * **When to use** * * Use when you need an explicit type-level cast and accept that the value is * returned unchanged at runtime. * * **Gotchas** * * This is a type-level cast only; it performs no runtime validation or * conversion. * * @see {@link satisfies} for checking assignability without changing the resulting type * * @stability stable * @category utility types * @since 4.0.0 */ export declare const cast: (a: A) => B; /** * Creates a zero-argument function that always returns the provided value. * * **When to use** * * Use when you need a thunk or callback that returns the same value on every * invocation. * * **Example** (Creating a constant thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * const constNull = Function.constant(null) * * constNull() // => null * constNull() // => null * ``` * * @stability stable * @category constructors * @since 2.0.0 */ export declare const constant: (value: A) => LazyArg; /** * Returns `true` when called. * * **When to use** * * Use when you need a thunk that returns `true` on every invocation. * * **Example** (Returning true from a thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.constTrue() // => true * ``` * * @stability stable * @category constants * @since 2.0.0 */ export declare const constTrue: LazyArg; /** * Returns `false` when called. * * **When to use** * * Use when you need a thunk that returns `false` on every invocation. * * **Example** (Returning false from a thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.constFalse() // => false * ``` * * @stability stable * @category constants * @since 2.0.0 */ export declare const constFalse: LazyArg; /** * Returns `null` when called. * * **When to use** * * Use when you need a thunk that returns `null` on every invocation. * * **Example** (Returning null from a thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.constNull() // => null * ``` * * @stability stable * @category constants * @since 2.0.0 */ export declare const constNull: LazyArg; /** * Returns `undefined` when called. * * **When to use** * * Use when you need a thunk that returns `undefined` on every invocation. * * **Example** (Returning undefined from a thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.constUndefined() // => undefined * ``` * * @stability stable * @category constants * @since 2.0.0 */ export declare const constUndefined: LazyArg; /** * Returns no meaningful value when called. * * **When to use** * * Use when you need a thunk that is called only for its effect and has no * meaningful return value. * * **Example** (Returning void from a thunk) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.constVoid() // => undefined * ``` * * @stability stable * @category constants * @since 2.0.0 */ export declare const constVoid: LazyArg; /** * Reverses the order of arguments for a curried function. * * **When to use** * * Use to adapt a curried function when its argument groups need to be supplied * in the opposite order. * * **Example** (Flipping curried arguments) * * ```ts import.meta.vitest * import { Function } from "effect" * * const f = (a: number) => (b: string) => a - b.length * * Function.flip(f)("aaa")(2) // => -1 * ``` * * @stability stable * @category combinators * @since 2.0.0 */ export declare const flip: , B extends Array, C>(f: (...a: A) => (...b: B) => C) => (...b: B) => (...a: A) => C; /** * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`. * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`. * * **When to use** * * Use to compose exactly two unary functions into a reusable unary function. * * **Example** (Composing two functions) * * ```ts import.meta.vitest * import { Function } from "effect" * * const increment = (n: number) => n + 1 * const square = (n: number) => n * n * * Function.compose(increment, square)(2) // => 9 * ``` * * @see {@link flow} for composing a left-to-right sequence of functions * @see {@link pipe} for applying a value through a left-to-right sequence immediately * * @stability stable * @category combinators * @since 2.0.0 */ export declare const compose: { /** * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`. * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`. * * **When to use** * * Use to compose exactly two unary functions into a reusable unary function. * * **Example** (Composing two functions) * * ```ts import.meta.vitest * import { Function } from "effect" * * const increment = (n: number) => n + 1 * const square = (n: number) => n * n * * Function.compose(increment, square)(2) // => 9 * ``` * * @see {@link flow} for composing a left-to-right sequence of functions * @see {@link pipe} for applying a value through a left-to-right sequence immediately * * @stability stable * @category combinators * @since 2.0.0 */ (bc: (b: B) => C): (self: (a: A) => B) => (a: A) => C; /** * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`. * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`. * * **When to use** * * Use to compose exactly two unary functions into a reusable unary function. * * **Example** (Composing two functions) * * ```ts import.meta.vitest * import { Function } from "effect" * * const increment = (n: number) => n + 1 * const square = (n: number) => n * n * * Function.compose(increment, square)(2) // => 9 * ``` * * @see {@link flow} for composing a left-to-right sequence of functions * @see {@link pipe} for applying a value through a left-to-right sequence immediately * * @stability stable * @category combinators * @since 2.0.0 */ (self: (a: A) => B, bc: (b: B) => C): (a: A) => C; }; /** * Marks an impossible branch by accepting a `never` value and returning any * type. * * **When to use** * * Use when you need a return value in a branch that exhaustive checks prove * cannot be reached. * * **Gotchas** * * Calling `absurd` throws, because a value of type `never` should be * impossible at runtime. * * **Example** (Handling impossible values) * * ```ts import.meta.vitest * import { absurd } from "effect" * * const handleNever = (value: never) => { * return absurd(value) // This will throw an error if called * } * ``` * * @stability stable * @category utility types * @since 2.0.0 */ export declare const absurd: (_: never) => A; /** * 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) * * ```ts import.meta.vitest * import { Function } from "effect" * * const sumTupled = Function.tupled((x: number, y: number): number => x + y) * * sumTupled([1, 2]) // => 3 * ``` * * @see {@link untupled} for adapting a tuple-argument function back to multiple arguments * * @stability stable * @category combinators * @since 2.0.0 */ export declare const tupled: , B>(f: (...a: A) => B) => (a: A) => B; /** * Converts a tupled function back to an uncurried function. * * **When to use** * * Use to adapt a tuple-argument function so it accepts multiple arguments. * * **Example** (Converting a tuple to arguments) * * ```ts import.meta.vitest * import { Function } from "effect" * * const getFirst = Function.untupled((tuple: [A, B]): A => tuple[0]) * * getFirst(1, 2) // => 1 * ``` * * @see {@link tupled} for adapting a multi-argument function to one tuple argument * * @stability stable * @category combinators * @since 2.0.0 */ export declare const untupled: , B>(f: (a: A) => B) => (...a: A) => B; /** * Pipes the value of an expression through a left-to-right sequence of * functions. * * **When to use** * * Use when you need to compose data-last functions into readable * transformation pipelines instead of method-style chains. * * **Details** * * Takes an initial value, passes it to the first function, then passes each * result to the next function in order. The final function result is returned. * * **Gotchas** * * Each function passed after the initial value must accept a single argument, * because `pipe` calls each step with only the previous result. * * **Example** (Piping values through functions) * * In this example, `1` is passed to the first function, and each result becomes * the input for the next function. * * ```ts import.meta.vitest * import { pipe } from "effect" * * pipe( * 1, * (n) => n + 1, * (n) => n * 2, * (n) => `result: ${n}` * ) // => "result: 4" * ``` * * **Example** (Rewriting method chains with pipe) * * The same transformation can be written with data-last functions. * * ```ts import.meta.vitest * import { Array, pipe } from "effect" * * const numbers = [1, 2, 3, 4] * const double = (n: number) => n * 2 * const greaterThanFour = (n: number) => n > 4 * * pipe( * numbers, * Array.map(double), * Array.filter(greaterThanFour) * ) // => [6, 8] * ``` * * @stability stable * @category combinators * @since 2.0.0 */ export declare function pipe(a: A): A; export declare function pipe(a: A, ab: (a: A) => B): B; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C): C; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): F; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): G; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): H; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I): I; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): J; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K): K; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L): L; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M): M; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N): N; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O): O; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P): P; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q): Q; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R): R; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R, rs: (r: R) => S): S; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J, jk: (j: J) => K, kl: (k: K) => L, lm: (l: L) => M, mn: (m: M) => N, no: (n: N) => O, op: (o: O) => P, pq: (p: P) => Q, qr: (q: Q) => R, rs: (r: R) => S, st: (s: S) => T): T; /** * Performs left-to-right function composition. * * **When to use** * * Use to build a reusable function from a left-to-right sequence of * transformations. * * **Details** * * The first function may have any arity. Every following function must be * unary. * * **Example** (Composing functions left to right) * * ```ts import.meta.vitest * import { flow } from "effect" * * const len = (s: string): number => s.length * const double = (n: number): number => n * 2 * * const f = flow(len, double) * * f("aaa") // => 6 * ``` * * @see {@link pipe} for applying a value through a left-to-right sequence immediately * @see {@link compose} for composing exactly two functions * * @stability stable * @category combinators * @since 2.0.0 */ export declare function flow, B = never>(ab: (...a: A) => B): (...a: A) => B; export declare function flow, B = never, C = never>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C; export declare function flow, B = never, C = never, D = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...a: A) => D; export declare function flow, B = never, C = never, D = never, E = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): (...a: A) => E; export declare function flow, B = never, C = never, D = never, E = never, F = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): (...a: A) => F; export declare function flow, B = never, C = never, D = never, E = never, F = never, G = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): (...a: A) => G; export declare function flow, B = never, C = never, D = never, E = never, F = never, G = never, H = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): (...a: A) => H; export declare function flow, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I): (...a: A) => I; export declare function flow, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): (...a: A) => J; /** * Creates a compile-time placeholder for a value of any type. * * **When to use** * * Use as a temporary typed placeholder while developing incomplete code. * * **Gotchas** * * `hole` is intended for temporary development use. If the placeholder is * evaluated at runtime, it throws. * * **Example** (Creating a development placeholder) * * ```ts import.meta.vitest * import { hole } from "effect" * * // Intentionally not called: `hole` throws if the placeholder is evaluated. * const buildUser = (id: number): { readonly id: number; readonly name: string } => ({ * id, * name: hole() * }) * * ``` * * @stability stable * @category utility types * @since 2.0.0 */ export declare const hole: () => T; /** * Returns the second argument and discards the first. The SK combinator is * a fundamental combinator in the lambda calculus and the SKI combinator * calculus. * * **When to use** * * Use to discard the first argument and return the second argument. * * **Example** (Discarding the first argument) * * ```ts import.meta.vitest * import { Function } from "effect" * * Function.SK(0, "hello") // => "hello" * ``` * * @stability stable * @category combinators * @since 2.0.0 */ export declare const SK: (_: A, b: B) => B; /** * Creates a memoized function whose input is an object, caching results by * object identity. * * **When to use** * * Use to reuse the result of a synchronous computation whose output is stable * for a given object reference. * * **Details** * * Each memoized wrapper owns a private `WeakMap` keyed by object identity. * * **Gotchas** * * `undefined` is reserved to represent a cache miss and is therefore not * supported as a return value. * * Structurally equal objects do not share cache entries. If the same object is * mutated after its first call, later calls still return the cached result for * that reference. * * @stability stable * @category caching * @since 4.0.0 */ export declare function memoize(f: (a: A) => O): (ast: A) => O; /** * Creates a memoized idempotent object transformation that caches both inputs * and their outputs by object identity. * * **When to use** * * Use when an object transformation is idempotent and its output can be safely * reused as a fixed point. * * **Details** * * After computing an input, the returned function caches both the input and * the output. Calling it with either reference returns the output without * invoking the supplied function again. * * **Gotchas** * * The returned function treats each computed output as a fixed point. If * applying the supplied function to an output would produce an observably * different value, this memoization changes that behavior. * * @see {@link memoize} for memoizing functions without an idempotence requirement * @stability stable * @category caching * @since 4.0.0 */ export declare function memoizeIdempotent(f: (a: A) => A): (a: A) => A; //# sourceMappingURL=Function.d.ts.map