HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Hs.Type

  • 49 types
  • 1 class
  • 90 values
  • Packageghc-9.10.3
  • Exports140
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceRep.hs
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 HsScaled pass a
#

This is used in the syntax. In constructor declaration. It must keep the arrow representation.

Constructors

Instances5Data, ToHie, HasHaddock
  • Data thing => Data (HsScaled GhcPs thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data thing => Data (HsScaled GhcRn thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • Data thing => Data (HsScaled GhcTc thing)Defined in ghc-9.10.3 · GHC.Hs.Instances · orphan
  • ToHie a => ToHie (HsScaled GhcRn a)Defined in ghc-9.10.3 · GHC.Iface.Ext.Ast
  • HasHaddock a => HasHaddock (HsScaled GhcPs a)Defined in ghc-9.10.3 · GHC.Parser.PostProcess.Haddock
datadata HsArrow pass
#

Denotes the type of arrows in the surface language

Constructors

Instances4Data, Outputable

Convert an arrow into its corresponding multiplicity. In essence this erases the information of whether the programmer wrote an explicit multiplicity or a shorthand.

datadata HsType pass
#

Haskell Type

Constructors

Instances15Data, Outputable, ToHie, DisambTD, HasHaddock, 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 The flag annotates the binder. It is Specificity in places where explicit specificity is allowed (e.g. x :: forall {a} b. ...) or () in other places.

Constructors

Instances10ToHie, Data, NamedThing, Outputable, Anno, …
datadata HsBndrVis pass
#
Instances6CvtFlag, Data, OutputableBndrFlag, RepTV
datadata LHsQTyVars pass
#

Located Haskell Quantified Type Variables

Instances5Data, Outputable, ToHie
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

Instances6ToHie, Data, Outputable, Anno
datadata HsWildCardBndrs pass thing
#

Haskell Wildcard Binders

Constructors

Instances7ToHie, Data, 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

Instances5Data, Outputable, ToHie
datadata HsTyPat pass
#

Constructors

Instances5Data, Outputable, ToHie
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].

Instances8Data, Outputable, ToHie, 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

Instances6Eq, Data, Outputable, OutputableBndr, ToHie, Anno
datadata HsArg p tm ty
#

Arguments in an expression/type after splitting

Constructors

Instances6Data, HasLoc, Outputable, ToHie
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
typetype BangType pass = HsType pass
#

Bang Type

In the parser, strictness and packedness annotations bind more tightly than docstrings. This means that when consuming a BangType (and looking for HsBangTy) we must be ready to peer behind a potential layer of HsDocTy. See #15206 for motivation and getBangType for an example.

datadata HsSrcBang
#

Haskell Source Bang

Bangs on data constructor arguments as the user wrote them in the source code.

(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)

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 SrcUnpackedness
#

Source Unpackedness

What unpackedness the user requested

Constructors

Instances4Eq, Data, Outputable, Binary
datadata ConDeclField pass
#

Constructor Declaration Field

Instances8Data, Outputable, ToHie, Anno, …
datadata HsConDetails tyarg 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

Instances3Data, Outputable, ToHie
valuenoTypeArgs :: [Void]
#

An empty list that can be used to indicate that there are no type arguments allowed in cases where HsConDetails is applied to Void.

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 ConDeclField 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.

Constructors

Instances10Eq, Data, Outputable, ToHie, OutputableBndr, Anno, …
datadata AmbiguousFieldOcc pass
#

Ambiguous Field Occurrence

Represents an *occurrence* of a field that is potentially ambiguous after the renamer, with the ambiguity resolved by the typechecker. We always store the RdrName that the user originally wrote, and store the selector function after the renamer (for unambiguous occurrences) or the typechecker (for ambiguous occurrences).

See Note [HsRecField and HsRecUpdField] in GHC.Hs.Pat. See Note [Located RdrNames] in GHC.Hs.Expr.

Instances8Data, Outputable, OutputableBndr, ToHie, 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

23 instances