(_: A): voidFunction-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
}export type type Contravariant<A> = (_: A) => voidFunction-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
}
Namespace for
Contravariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Contravariant.
Contravariant<function (type parameter) A in type Contravariant<A>A> = (_: A_: function (type parameter) A in type Contravariant<A>A) => void
/**
* Namespace for {@link Contravariant}-related utilities.
*
* **When to use**
*
* Use when referring to type-level helpers nested under `Contravariant`.
*
* @since 3.9.0
*/
export declare namespace Contravariant {
/**
* Extracts the type parameter `A` from a `Contravariant<A>`.
*
* **When to use**
*
* Use to recover the carried type from a contravariant phantom marker.
*
* **Example** (Extracting the inner type)
*
* ```ts
* import type { Types } from "effect"
*
* type Inner = Types.Contravariant.Type<Types.Contravariant<string>>
* // string
* ```
*
* @see {@link Contravariant}
*
* @category models
* @since 3.9.0
*/
export type type Contravariant<A>.Type<A> = A extends Contravariant<infer U> ? U : neverExtracts the type parameter A from a Contravariant<A>.
When to use
Use to recover the carried type from a contravariant phantom marker.
Example (Extracting the inner type)
import type { Types } from "effect"
type Inner = Types.Contravariant.Type<Types.Contravariant<string>>
// string
Type<function (type parameter) A in type Contravariant<A>.Type<A>A> = function (type parameter) A in type Contravariant<A>.Type<A>A extends type Contravariant<A> = (_: A) => voidFunction-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
}
Namespace for
Contravariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Contravariant.
Contravariant<infer function (type parameter) UU> ? function (type parameter) UU : never
}