<A, B>(a: A): BReturns 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.
utility typessatisfies
Source effect/Function.ts:2991 lines
export const const cast: <A, B>(a: A) => BReturns 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.
cast: <function (type parameter) A in <A, B>(a: A): BA, function (type parameter) B in <A, B>(a: A): BB>(a: Aa: function (type parameter) A in <A, B>(a: A): BA) => function (type parameter) B in <A, B>(a: A): BB = const identity: <A>(a: A) => AReturns its input argument unchanged.
When to use
Use to return a value unchanged where a function is required.
Example (Returning the same value)
import { identity } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(identity(5), 5)
identity as anyReferenced by 7 symbols