<A>(a: A): <B>(self: (a: A) => B) => BApplies 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)
import { Function, pipe, String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(pipe(String.length, Function.apply("hello")), 5)combinatorspipe
Source effect/Function.ts:1841 lines
export const const apply: <A>(
a: A
) => <B>(self: (a: A) => B) => B
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)
import { Function, pipe, String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(pipe(String.length, Function.apply("hello")), 5)
apply = <function (type parameter) A in <A>(a: A): <B>(self: (a: A) => B) => BA>(a: Aa: function (type parameter) A in <A>(a: A): <B>(self: (a: A) => B) => BA) => <function (type parameter) B in <B>(self: (a: A) => B): BB>(self: (a: A) => Bself: (a: Aa: function (type parameter) A in <A>(a: A): <B>(self: (a: A) => B) => BA) => function (type parameter) B in <B>(self: (a: A) => B): BB): function (type parameter) B in <B>(self: (a: A) => B): BB => self: (a: A) => Bself(a: Aa)