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

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleghc-lib-parser-9.14.1.20251220GHC2021

GHC.Hs.Type

  • 52 types
  • 1 class
  • 89 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.

datadata HsMultAnnOf mult pass
#

Denotes multiplicity annotations in the surface language. The mult type argument is usually `LHsType (NoGhcTc pass)`, but when the annotation is part of a type used in a term, it is `LHsExpr pass`. See Note [Types in terms].

Constructors

Instances7Data, Outputable, …
datadata HsType pass
#
Instances13Outputable, DisambTD, HasHaddock, Data, Anno, …
datadata HsForAllTelescope pass
#

The type variable binders in an HsForAllTy. See also Note [Variable Specificity and Forall Visibility] in GHC.Tc.Gen.HsType.

Constructors

Instances4Data, Outputable
datadata HsTyVarBndr flag pass
#

Haskell Type Variable Binder See Note [Type variable binders]

Instances8Data, Outputable, Anno, …
datadata HsBndrVar pass
#

Constructors

Instances4Data, Outputable
datadata HsBndrVis pass
#
Instances4Data, OutputableBndrFlag
datadata LHsQTyVars pass
#

Located Haskell Quantified Type Variables

Instances4Data, Outputable
datadata HsOuterTyVarBndrs flag pass
#

The outermost type variables in a type that obeys the forall-or-nothing rule. See Note [forall-or-nothing rule].

Constructors

Instances5Data, Outputable, Anno
datadata HsWildCardBndrs pass thing
#

Haskell Wildcard Binders

Constructors

Instances5Data, Outputable, HasHaddock
datadata HsPatSigType pass
#

Types that can appear in pattern signatures, as well as the signatures for term-level binders in RULES. See Note [Pattern signature binders and scoping].

This is very similar to HsSigWcType, but with slightly different semantics: see Note [HsType binders]. See also Note [The wildcard story for types].

Constructors

Instances4Data, Outputable
datadata HsPSRn
#

The extension field for HsPatSigType, which is only used in the renamer onwards. See Note [Pattern signature binders and scoping].

Constructors

Instances1Data
  • Data HsPSRnDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Type
datadata HsTyPat pass
#

Constructors

Instances4Data, Outputable
datadata HsSigType pass
#

A type signature that obeys the forall-or-nothing rule. In other words, an LHsType that uses an HsOuterSigTyVarBndrs to represent its outermost type variable quantification. See Note [Representing type signatures].

Instances6Data, Outputable, HasHaddock, Anno
datadata HsTyLit pass
#

Haskell Type Literal

Instances4Data, Outputable
newtypenewtype HsIPName
#

These names are used early on to store the names of implicit parameters. They completely disappear after type-checking.

Constructors

Instances5Eq, Data, Outputable, OutputableBndr, Anno
  • Eq HsIPNameDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.Type
  • Data HsIPNameDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.Type
  • Outputable HsIPNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Type · orphan
  • OutputableBndr HsIPNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Type · orphan
  • type Anno HsIPName = EpAnnCODefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Type · orphan
datadata HsArg p tm ty
#

Arguments in an expression/type after splitting

Constructors

Instances4Data, Outputable
valuepprHsArgsApp
  1. :: (OutputableBndr id, Outputable tm, Outputable ty)
  2. => id
  3. -> LexicalFixity
  4. -> [HsArg (GhcPass p) tm ty]
  5. -> SDoc
#

pprHsArgsApp id fixity args pretty-prints an application of id to args, using the fixity to tell whether id should be printed prefix or infix. Examples:

pprHsArgsApp T Prefix [HsTypeArg Bool, HsValArg Int]                        = T @Bool Int
pprHsArgsApp T Prefix [HsTypeArg Bool, HsArgPar, HsValArg Int]              = (T @Bool) Int
pprHsArgsApp (++) Infix [HsValArg Char, HsValArg Double]                    = Char ++ Double
pprHsArgsApp (++) Infix [HsValArg Char, HsValArg Double, HsVarArg Ordering] = (Char ++ Double) Ordering
datadata HsSrcBang
#

Haskell Source Bang

Bangs on data constructor arguments as written by the user, including the source code for exact-printing.

(HsSrcBang _ SrcUnpack SrcLazy) and (HsSrcBang _ SrcUnpack NoSrcStrict) (without StrictData) makes no sense, we emit a warning (in checkValidDataCon) and treat it like (HsSrcBang _ NoSrcUnpack SrcLazy)

In the AST, the SourceText is hidden inside the extension point XConDeclField.

Instances2Data, Outputable
datadata HsImplBang
#

Haskell Implementation Bang

Bangs of data constructor arguments as generated by the compiler after consulting HsSrcBang, flags, etc.

Constructors

  • HsLazy

    Lazy field, or one with an unlifted type

  • HsStrict Bool

    Strict but not unpacked field True = we could have unpacked, but opted not to because of -O0. See Note [Detecting useless UNPACK pragmas]

  • HsUnpack (Maybe Coercion)

    Strict and unpacked field co :: arg-ty ~ product-ty HsBang

Instances2Data, Outputable
datadata SrcStrictness
#

Source Strictness

What strictness annotation the user wrote

Constructors

Instances5Eq, Data, NFData, Outputable, Binary
datadata SrcUnpackedness
#

Source Unpackedness

What unpackedness the user requested

Constructors

Instances5Eq, Data, NFData, Outputable, Binary
datadata HsConDeclRecField pass
#

Constructor Declaration Record Field

Instances7Data, Outputable, HasHaddock, Anno, …
datadata HsConDetails arg rec
#

Describes the arguments to a data constructor. This is a common representation for several constructor-related concepts, including:

  • The arguments in a Haskell98-style constructor declaration (see HsConDeclH98Details in GHC.Hs.Decls).

  • The arguments in constructor patterns in case/function definitions (see HsConPatDetails in GHC.Hs.Pat).

  • The left-hand side arguments in a pattern synonym binding (see HsPatSynDetails in GHC.Hs.Binds).

One notable exception is the arguments in a GADT constructor, which uses a separate data type entirely (see HsConDeclGADTDetails in GHC.Hs.Decls). This is because GADT constructors cannot be declared with infix syntax, unlike the concepts above (#18844).

Constructors

Instances2Data, Outputable
datadata HsConDeclField pass
#

Constructor declaration field specification, see Note [HsConDeclField on pass]

Constructors

Instances4Data, HasHaddock
datadata FieldOcc pass
#

Field Occurrence

Represents an *occurrence* of a field. This may or may not be a binding occurrence (e.g. this type is used in HsConDeclRecField and RecordPatSynField which bind their fields, but also in HsRecField for record construction and patterns, which do not).

We store both the RdrName the user originally wrote, and after the renamer we use the extension field to store the selector function. See note [FieldOcc pass]

There is a wrinkle in that update field occurances are sometimes ambiguous during the rename stage. See note [Ambiguous FieldOcc in record updates] to see how we currently handle this.

Constructors

Instances8Eq, Data, Outputable, OutputableBndr, Anno, …

Decompose a type class instance type (of the form forall tvs. context => instance_head) into its constituent parts. Note that the [Name]s returned correspond to either:

  • The implicitly bound type variables (if the type lacks an outermost forall), or

  • The explicitly bound type variables (if the type has an outermost forall).

This function is careful not to look through parentheses. See Note [No nested foralls or contexts in instance types] for why this is important.

Decompose a pattern synonym type signature into its constituent parts.

Note that this function looks through parentheses, so it will work on types such as (forall a. ...). The downside to this is that it is not generally possible to take the returned types and reconstruct the original type (parentheses and all) from them.

Decompose a type of the form forall tvs. body into its constituent parts. Only splits type variable binders that were quantified invisibly (e.g., forall a., with a dot).

This function is used to split apart certain types, such as instance declaration types, which disallow visible foralls. For instance, if GHC split apart the forall in instance forall a -> Show (Blah a), then that declaration would mistakenly be accepted!

Note that this function looks through parentheses, so it will work on types such as (forall a. ...). The downside to this is that it is not generally possible to take the returned types and reconstruct the original type (parentheses and all) from them. Unlike splitLHsSigmaTyInvis, this function does not look through parentheses, hence the suffix _KP (short for "Keep Parentheses").

Decompose a type of the form forall tvs. body into its constituent parts. Only splits type variable binders that were quantified invisibly (e.g., forall a., with a dot).

This function is used to split apart certain types, such as instance declaration types, which disallow visible foralls. For instance, if GHC split apart the forall in instance forall a -> Show (Blah a), then that declaration would mistakenly be accepted!

Unlike splitLHsForAllTyInvis, this function does not look through parentheses, hence the suffix _KP (short for "Keep Parentheses").

valuesplitLHsQualTy
  1. :: LHsType (GhcPass pass)
  2. -> (Maybe (LHsContext (GhcPass pass)), LHsType (GhcPass pass))
#

Decompose a type of the form context => body into its constituent parts.

Note that this function looks through parentheses, so it will work on types such as (context => ...). The downside to this is that it is not generally possible to take the returned types and reconstruct the original type (parentheses and all) from them.

Decompose a sigma type (of the form forall tvs. context => body) into its constituent parts. Only splits type variable binders that were quantified invisibly (e.g., forall a., with a dot).

This function is used to split apart certain types, such as instance declaration types, which disallow visible foralls. For instance, if GHC split apart the forall in instance forall a -> Show (Blah a), then that declaration would mistakenly be accepted!

Note that this function looks through parentheses, so it will work on types such as (forall a. ...). The downside to this is that it is not generally possible to take the returned types and reconstruct the original type (parentheses and all) from them.

Decompose a GADT type into its constituent parts. Returns (outer_bndrs, mb_ctxt, body), where:

  • outer_bndrs are HsOuterExplicit if the type has explicit, outermost type variable binders. Otherwise, they are HsOuterImplicit.

  • mb_ctxt is Just the context, if it is provided. Otherwise, it is Nothing.

  • body is the body of the type after the optional foralls and context.

This function is careful not to look through parentheses. See Note [GADT abstract syntax] (Wrinkle: No nested foralls or contexts) GHC.Hs.Decls for why this is important.

valuehsTyKindSig :: LHsType (GhcPass p) -> Maybe (LHsKind (GhcPass p))
#

Get the kind signature of a type, ignoring parentheses:

hsTyKindSig `Maybe ` = Nothing hsTyKindSig `Maybe :: Type -> Type ` = Just `Type -> Type` hsTyKindSig `Maybe :: ((Type -> Type))` = Just `Type -> Type`

This is used to extract the result kind of type synonyms with a CUSK:

type S = (F :: res_kind) ^^^^^^^^

Orphan instances

20 instances