Package: effect
Module: Types
Function-type alias encoding invariant variance for a phantom type parameter.
When to use
Use as a phantom field type to make a type parameter invariant, neither covariant nor contravariant.
Details
A value of type Invariant<A> cannot be assigned to Invariant<B> unless
A and B are the same type.
Example (Defining an invariant phantom type)
import type { Types } from "effect"
interface Container<T> {
readonly _phantom: Types.Invariant<T>
readonly value: T
}
See
Invariant.TypeCovariantContravariantSignature
type Invariant<A> = (_: A) => A
Since v2.0.0