HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Core.Multiplicity

This module defines the semi-ring of multiplicities, and associated functions. Multiplicities annotate arrow types to indicate the linearity of the arrow (in the sense of linear types).

Mult is a type synonym for Type, used only when its kind is Multiplicity. To simplify dealing with multiplicities, functions such as mkMultMul perform simplifications such as Many * x = Many on the fly.

  • 4 types
  • 16 values
typetype Mult = Type
#

Mult is a type alias for Type.

Mult must contain Type because multiplicity variables are mere type variables (of kind Multiplicity) in Haskell. So the simplest implementation is to make Mult be Type.

Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) - Many: GHC.Types.Many (= manyDataCon) - Multiplication: GHC.Types.MultMul (= multMulTyCon)

So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these.

valuemkMultSup :: Mult -> Mult -> Mult
#

mkMultSup w1 w2 returns a multiplicity such that mkMultSup w1 w2 >= w1 and mkMultSup w1 w2 >= w2. See Note [Overapproximating multiplicities].

datadata Scaled a
#

A shorthand for data with an attached Mult element (the multiplicity).

Constructors

Instances2Data, Outputable
valuetymult :: a -> Scaled a
#

Scale a payload by Many; used for type arguments in core

valuesubmult :: Mult -> Mult -> IsSubmult
#

submult w1 w2 check whether a value of multiplicity w1 is allowed where a value of multiplicity w2 is expected. This is a partial order.

valuepprArrowWithModifiers
  1. :: [SDoc]

    Modifiers.

  2. -> FunTyFlag

    Is this ->/⊸ or =>? See Note [FunTyFlag].

  3. -> Multiplicity

    Is this -> or ⊸?

  4. -> SDoc
#

Pretty print a function arrow, with modifiers preceding it.

Each modifier is prefixed with %, but it's the caller's responsibility to ensure they're parenthesized correctly if not atomic.