effect-io-ai

Package: effect
Module: Types

Types.Invariant

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

Signature

type Invariant<A> = (_: A) => A

Source

Since v2.0.0