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

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

Moduleghc-10.0.0.20260917GHC2024

GHC.Tc.Types.Origin

Describes the provenance of types as they flow through the type-checker. The datatypes here are mainly used for error message generation.

  • 21 types
  • 30 values

SkolemInfo, SkolemInfoAnon

9 declarations
datadata SkolemInfo
#

SkolemInfo stores the origin of a skolem type variable, so that we can display this information to the user in case of a type error.

The Unique field allows us to report all skolem type variables bound in the same place in a single report.

Instances2Outputable, Uniquable
datadata SkolemInfoAnon
#

SkolemInfoAnon stores the origin of a skolem type variable (e.g. bound by a user-written forall, the header of a data declaration, a deriving clause, ...).

This information is displayed when reporting an error message, such as

"Couldn't match k with l"

This allows us to explain where the type variable came from.

When several skolem type variables are bound at once, prefer using SkolemInfo, which stores a Unique which allows these type variables to be reported

Instances1Outputable

Use this when you can't specify a helpful origin for some skolem type variable.

We're hoping to be able to get rid of this entirely, but for the moment it's still needed.

CtOrigin

23 declarations
datadata CtOrigin
#

Constructors

Instances1Outputable

Does this constraint arise from GHC internal mechanisms that desugar to usage of the HasField typeclass (e.g. OverloadedRecordDot, etc)?

Used in two places:

  • When reporting an unsolved HasField constraint, to decide whether to print an informative message to the user. See (H2e) in Note [Error messages for unsolved HasField constraints] in GHC.Tc.Errors.

  • To avoid emitting a poor "incomplete record selector" warning directly in typechecker, in cases when the desugarer will be able to emit a better error message, due to having better pattern match checking information. See (IRS7) in Note [Detecting incomplete record selectors] in GHC.HsToCore.Pmc

CallStack

1 declaration

FixedRuntimeRep origin

7 declarations

The context for a representation-polymorphism check.

For example, when typechecking (a :: k) -> ..., we are checking the type a because it's the type of a term variable bound in a lambda, so we use FRRBinder.

Constructors

Instances1Outputable

The context in which a representation-polymorphism check was performed.

Does not include the type on which the check was performed; see FixedRuntimeRepOrigin for that.

Constructors

  • FRRRecordCon !RdrName !(HsExpr GhcTc)

    Record fields in record construction must have a fixed runtime representation.

  • FRRRecordUpdate !Name !(HsExpr GhcRn)

    Record fields in record updates must have a fixed runtime representation.

    Test case: RepPolyRecordUpdate.

  • FRRBinder !Name

    Variable binders must have a fixed runtime representation.

    Test cases: LevPolyLet, RepPolyPatBind.

  • FRRRepPolyId !Name !RepPolyId !(Position 'Neg)

    Types appearing in negative position in the type of a representation-polymorphic Id must have a fixed runtime representation.

    This includes:

    • arguments,

    Test cases: RepPolyMagic, RepPolyRightSection, RepPolyWrappedVar, T14561b, T17817.

    • continuation result types, such as in catch#, keepAlive# and control0#.

    Test case: T21906.

  • FRRPatBind

    Pattern binds must have a fixed runtime representation.

    Test case: RepPolyInferPatBind.

  • FRRPatSynArg

    Pattern synonym arguments must have a fixed runtime representation.

    Test case: RepPolyInferPatSyn.

  • FRRCase

    The type of the scrutinee in a case statement must have a fixed runtime representation.

    Test cases: RepPolyCase{1,2}.

  • FRRDataConPatArg !DataCon !Int

    An instantiation of a newtype/data constructor pattern in which an argument type does not have a fixed runtime representation.

    Test case: T20363.

  • FRRUnboxedTuple !Int

    The RuntimeRep arguments to unboxed tuples must be concrete RuntimeReps.

    Test case: RepPolyTuple.

  • FRRUnboxedTupleSection !Int

    Tuple sections must have a fixed runtime representation.

    Test case: RepPolyTupleSection.

  • FRRUnboxedSum !(Maybe Int)

    The RuntimeRep arguments to unboxed sums must be concrete RuntimeReps.

    Test cases: RepPolySum.

  • FRRBodyStmt !StmtOrigin !Int

    The body of a do expression or a monad comprehension must have a fixed runtime representation.

    Test cases: RepPolyDoBody{1,2}, RepPolyMcBody.

  • FRRBodyStmtGuard

    Arguments to a guard in a monad comprehension must have a fixed runtime representation.

    Test case: RepPolyMcGuard.

  • FRRBindStmt !StmtOrigin

    Arguments to (>>=) arising from a do expression or a monad comprehension must have a fixed runtime representation.

    Test cases: RepPolyDoBind, RepPolyMcBind.

  • FRRBindStmtGuard

    A value bound by a pattern guard must have a fixed runtime representation.

    Test cases: none.

  • FRRArrow !FRRArrowContext

    A representation-polymorphism check arising from arrow notation.

    See FRRArrowContext for more details.

  • FRRExpectedFunTy !ExpectedFunTyCtxt !Int

    A representation-polymorphism check arising from a call to matchExpectedFunTys or matchActualFunTy.

    See ExpectedFunTyCtxt for more details.

  • forall p. FRRDeepSubsumption

    A representation-polymorphism check arising from eta-expansion performed as part of deep subsumption.

Instances1Outputable
datadata ArgPos
#

The position of an argument (to be reported in an error message).

Constructors

  • ArgPosInvis

    Invisible argument: don't report its position to the user.

  • ArgPosVis !Int

    Visible argument in i-th position.

FixedRuntimeRep origin for rep-poly Ids

datadata RepPolyId
#

The description of a representation-polymorphic Id.

Constructors

datadata Polarity
#

Are we in a positive (covariant) or negative (contravariant) position?

See Note [Positional information in representation-polymorphism errors].

datadata Position (p :: Polarity) where
#

A position in which a type variable appears in a type; in particular, whether it appears in a positive or a negative position.

See Note [Positional information in representation-polymorphism errors].

Constructors

Instances2Show, Outputable

Arrow command FixedRuntimeRep origin

datadata FRRArrowContext
#

While typechecking arrow notation, in which context did a representation polymorphism check arise?

See FixedRuntimeRepContext for more general origins of representation polymorphism checks.

Constructors

  • ArrowCmdResTy !(HsCmd GhcRn)

    The result of an arrow command does not have a fixed runtime representation.

    Test case: RepPolyArrowCmd.

  • ArrowCmdApp !(HsCmd GhcRn) !(HsExpr GhcRn)

    The argument to an arrow in an arrow command application does not have a fixed runtime representation.

    Test cases: none.

  • ArrowCmdArrApp !(HsExpr GhcRn) !(HsExpr GhcRn) !HsArrAppType

    A function in an arrow application does not have a fixed runtime representation.

    Test cases: none.

  • ArrowCmdCase

    The scrutinee type in an arrow command case statement does not have a fixed runtime representation.

    Test cases: none.

  • ArrowFun !(HsExpr GhcRn)

    The overall type of an arrow proc expression does not have a fixed runtime representation.

    Test case: RepPolyArrowFun.

Instances1Outputable

ExpectedFunTy FixedRuntimeRepOrigin

datadata ExpectedFunTyCtxt
#

In what context are we calling matchExpectedFunTys or matchActualFunTy?

Used for two things:

  1. Reporting error messages which explain that a function has been given an unexpected number of arguments. Uses pprExpectedFunTyHerald. See Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify.

  2. Reporting representation-polymorphism errors when a function argument doesn't have a fixed RuntimeRep as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete. Uses pprExpectedFunTyCtxt. See FixedRuntimeRepContext for the situations in which representation-polymorphism checks are performed.

Constructors

InstanceWhat

2 declarations
typetype SafeOverlapping = Bool
#

Indicates if Instance met the Safe Haskell overlapping instances safety check.

See Note [Safe Haskell Overlapping Instances] in GHC.Tc.Solver See Note [Safe Haskell Overlapping Instances Implementation] in GHC.Tc.Solver