HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.Core.Reduction

  • 6 types
  • 29 values
  • Packageghc-9.10.3
  • Exports35
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceReduction.hs

Reductions

33 declarations
datadata Reduction
#

A Reduction is the result of an operation that rewrites a type ty_in. The Reduction includes the rewritten type ty_out and a Coercion co such that co :: ty_in ~ ty_out, where the role of the coercion is determined by the context. That is, the LHS type of the coercion is the original type ty_in, while its RHS type is the rewritten type ty_out.

A Reduction is always homogeneous, unless it is wrapped inside a HetReduction, which separately stores the kind coercion.

See Note [The Reduction type].

Instances1Outputable
datadata HetReduction
#

Stores a heterogeneous reduction.

The stored kind coercion must relate the kinds of the stored reduction. That is, in HetReduction (Reduction co xi) kco, we must have:

 co :: ty ~ xi
kco :: typeKind ty ~ typeKind xi
valuemkReductions :: [Coercion] -> [Type] -> Reductions
#

Create Reductions from individual lists of coercions and types.

The lists should be of the same length, and the RHS type of each coercion should match the specified type in the other list.

valuemkHetReduction
  1. :: Reduction

    heterogeneous reduction

  2. -> MCoercionN

    kind coercion

  3. -> HetReduction
#

Create a heterogeneous reduction.

Pre-condition: the provided kind coercion (second argument) relates the kinds of the stored reduction. That is, if the coercion stored in the Reduction is of the form

co :: ty ~ xi

Then the kind coercion supplied must be of the form:

kco :: typeKind ty ~ typeKind xi

Compose a reduction with a coercion on the left.

Pre-condition: the provided coercion's RHS type must match the LHS type of the coercion that is stored in the reduction.

valuemkCastRedn1
  1. :: Role
  2. -> Type

    original type

  3. -> CoercionN

    coercion to cast with

  4. -> Reduction

    rewritten type, with rewriting coercion

  5. -> Reduction
#

Apply a cast to a Reduction, casting both the original and the reduced type.

Given cast_co and Reduction ty ~co~> xi, this function returns the Reduction (ty |> cast_co) ~return_co~> (xi |> cast_co) of the given Role (which must match the role of the coercion stored in the Reduction argument).

Pre-condition: the Type passed in is the same as the LHS type of the coercion stored in the Reduction.

Homogenise a heterogeneous reduction.

Given HetReduction (Reduction co xi) kco, with

 co :: ty ~ xi
kco :: typeKind(ty) ~ typeKind(xi)

this returns the homogeneous reduction:

hco :: ty ~ ( xi |> sym kco )

Rewriting type arguments

2 declarations
datadata ArgsReductions
#

Stores Reductions as well as a kind coercion.

Used when rewriting arguments to a type function f.

Invariant: when the stored reductions are of the form co_i :: ty_i ~ xi_i, the kind coercion is of the form kco :: typeKind (f ty_1 ... ty_n) ~ typeKind (f xi_1 ... xi_n)

The type function f depends on context.