effect-io-ai

Package: effect
Module: Types

Types.Contravariant

Function-type alias encoding contravariant variance for a phantom type parameter.

When to use

Use as a phantom field type to make a type parameter contravariant in input position.

Details

Contravariant<A> is assignable to Contravariant<B> when B extends A, following the supertype direction.

Example (Defining a contravariant phantom type)

import type { Types } from "effect"

interface Consumer<T> {
  readonly _phantom: Types.Contravariant<T>
  readonly accept: (value: T) => void
}

See

Signature

type Contravariant<A> = (_: A) => void

Source

Since v2.0.0