Variance<F, R, O, E>Type-level marker encoding the variance of a TypeLambda's type
parameters.
When to use
Use to define variance constraints for a higher-kinded type so that
Gen can correctly infer R, O, and E from yielded values.
Details
F is invariant and must match exactly. R is contravariant in the input
or environment position. O and E are covariant in the output and error
positions. This is a pure type-level construct with no runtime
representation.
Example (Declaring variance for a TypeLambda)
import type { Option, Utils } from "effect"
declare const variance: Utils.Variance<
Option.OptionTypeLambda,
never,
never,
never
>export interface interface Variance<in out F extends TypeLambda, in R, out O, out E>Type-level marker encoding the variance of a TypeLambda's type
parameters.
When to use
Use to define variance constraints for a higher-kinded type so that
Gen
can correctly infer R, O, and E from yielded values.
Details
F is invariant and must match exactly. R is contravariant in the input
or environment position. O and E are covariant in the output and error
positions. This is a pure type-level construct with no runtime
representation.
Example (Declaring variance for a TypeLambda)
import type { Option, Utils } from "effect"
declare const variance: Utils.Variance<
Option.OptionTypeLambda,
never,
never,
never
>
Variance<in out function (type parameter) F in Variance<in out F extends TypeLambda, in R, out O, out E>F extends TypeLambda, in function (type parameter) R in Variance<in out F extends TypeLambda, in R, out O, out E>R, out function (type parameter) O in Variance<in out F extends TypeLambda, in R, out O, out E>O, out function (type parameter) E in Variance<in out F extends TypeLambda, in R, out O, out E>E> {
readonly Variance<in out F extends TypeLambda, in R, out O, out E>._F: Types.Invariant<F>_F: import TypesTypes.type Invariant<A> = (_: A) => AFunction-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
}
Namespace for
Invariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Invariant.
Invariant<function (type parameter) F in Variance<in out F extends TypeLambda, in R, out O, out E>F>
readonly Variance<in out F extends TypeLambda, in R, out O, out E>._R: Types.Contravariant<R>_R: import TypesTypes.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) R in Variance<in out F extends TypeLambda, in R, out O, out E>R>
readonly Variance<in out F extends TypeLambda, in R, out O, out E>._O: Types.Covariant<O>_O: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) O in Variance<in out F extends TypeLambda, in R, out O, out E>O>
readonly Variance<in out F extends TypeLambda, in R, out O, out E>._E: Types.Covariant<E>_E: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) E in Variance<in out F extends TypeLambda, in R, out O, out E>E>
}