effect-io-ai

Package: effect
Module: Function

Function.constant

Creates a constant value that never changes.

This is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument) and want that inner function to always use the same value, no matter how many times it is called.

Example

import * as assert from "node:assert"
import { constant } from "effect/Function"

const constNull = constant(null)

assert.deepStrictEqual(constNull(), null)
assert.deepStrictEqual(constNull(), null)

Signature

declare const constant: <A>(value: A) => LazyArg<A>

Source

Since v2.0.0