GHC.Tc.Types.Origin

ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Tc.Types.Origin

Contents

- UserTypeCtxt
- SkolemInfo
- CtOrigin
- CallStack
- FixedRuntimeRep origin
  - FixedRuntimeRep origin for rep-poly `Id`s
  - Arrow command FixedRuntimeRep origin
  - ExpectedFunTy FixedRuntimeRepOrigin
- InstanceWhat

Description

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

Synopsis

- data UserTypeCtxt
  - = FunSigCtxt Name ReportRedundantConstraints
  - | InfSigCtxt Name
  - | ExprSigCtxt ReportRedundantConstraints
  - | KindSigCtxt
  - | StandaloneKindSigCtxt Name
  - | TypeAppCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt FastString Name
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt Bool
  - | SpecInstCtxt
  - | GenSigCtxt
  - | GhciCtxt Bool
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
  - | DerivClauseCtxt
  - | TyVarBndrKindCtxt Name
  - | DataKindCtxt Name
  - | TySynKindCtxt Name
  - | TyFamResKindCtxt Name
- pprUserTypeCtxt :: UserTypeCtxt -> SDoc
- isSigMaybe :: UserTypeCtxt -> Maybe Name
- data ReportRedundantConstraints
  - = NoRRC
  - | WantRRC SrcSpan
- reportRedundantConstraints :: ReportRedundantConstraints -> Bool
- redundantConstraintsSpan :: UserTypeCtxt -> SrcSpan
- data SkolemInfo = SkolemInfo Unique SkolemInfoAnon
- data SkolemInfoAnon
  - = SigSkol UserTypeCtxt TcType [(Name, TcTyVar)]
  - | SigTypeSkol UserTypeCtxt
  - | ForAllSkol TyVarBndrs
  - | DerivSkol Type
  - | InstSkol ClsInstOrQC PatersonSize
  - | FamInstSkol
  - | PatSkol ConLike HsMatchContextRn
  - | IPSkol [HsIPName]
  - | RuleSkol RuleName
  - | InferSkol [(Name, TcType)]
  - | BracketSkol
  - | UnifyForAllSkol TcType
  - | TyConSkol (TyConFlavour TyCon) Name
  - | DataConSkol Name
  - | ReifySkol
  - | RuntimeUnkSkol
  - | ArrowReboundIfSkol
  - | UnkSkol CallStack
- mkSkolemInfo :: MonadIO m => SkolemInfoAnon -> m SkolemInfo
- getSkolemInfo :: SkolemInfo -> SkolemInfoAnon
- pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc
- pprSkolInfo :: SkolemInfoAnon -> SDoc
- unkSkol :: HasCallStack => SkolemInfo
- unkSkolAnon :: HasCallStack => SkolemInfoAnon
- mkClsInstSkol :: Class -> [Type] -> SkolemInfoAnon
- data CtOrigin
  - = GivenOrigin SkolemInfoAnon
  - | GivenSCOrigin SkolemInfoAnon ScDepth Bool
  - | OccurrenceOf Name
  - | OccurrenceOfRecSel RdrName
  - | AppOrigin
  - | SpecPragOrigin UserTypeCtxt
  - | TypeEqOrigin {
    - uo_actual :: TcType
    - uo_expected :: TcType
    - uo_thing :: Maybe TypedThing
    - uo_visible :: Bool
    }
  - | KindEqOrigin TcType TcType CtOrigin (Maybe TypeOrKind)
  - | IPOccOrigin HsIPName
  - | OverLabelOrigin FastString
  - | LiteralOrigin (HsOverLit GhcRn)
  - | NegateOrigin
  - | ArithSeqOrigin (ArithSeqInfo GhcRn)
  - | AssocFamPatOrigin
  - | SectionOrigin
  - | HasFieldOrigin FastString
  - | TupleOrigin
  - | ExprSigOrigin
  - | PatSigOrigin
  - | PatOrigin
  - | ProvCtxtOrigin (PatSynBind GhcRn GhcRn)
  - | RecordUpdOrigin
  - | ViewPatOrigin
  - | ScOrigin ClsInstOrQC NakedScFlag
  - | DerivClauseOrigin
  - | DerivOriginDC DataCon Int Bool
  - | DerivOriginCoerce Id Type Type Bool
  - | StandAloneDerivOrigin
  - | DefaultOrigin
  - | DoOrigin
  - | DoPatOrigin (LPat GhcRn)
  - | MCompOrigin
  - | MCompPatOrigin (LPat GhcRn)
  - | ProcOrigin
  - | ArrowCmdOrigin
  - | AnnOrigin
  - | FunDepOrigin1 PredType CtOrigin RealSrcSpan PredType CtOrigin RealSrcSpan
  - | FunDepOrigin2 PredType CtOrigin PredType SrcSpan
  - | InjTFOrigin1 PredType CtOrigin RealSrcSpan PredType CtOrigin RealSrcSpan
  - | ExprHoleOrigin (Maybe RdrName)
  - | TypeHoleOrigin OccName
  - | PatCheckOrigin
  - | ListOrigin
  - | IfThenElseOrigin
  - | BracketOrigin
  - | StaticOrigin
  - | ImpedanceMatching Id
  - | Shouldn'tHappenOrigin String
  - | InstProvidedOrigin Module ClsInst
  - | NonLinearPatternOrigin NonLinearPatternReason (LPat GhcRn)
  - | UsageEnvironmentOf Name
  - | CycleBreakerOrigin CtOrigin
  - | FRROrigin FixedRuntimeRepOrigin
  - | WantedSuperclassOrigin PredType CtOrigin
  - | InstanceSigOrigin Name Type Type
  - | AmbiguityCheckOrigin UserTypeCtxt
- exprCtOrigin :: HsExpr GhcRn -> CtOrigin
- lexprCtOrigin :: LHsExpr GhcRn -> CtOrigin
- matchesCtOrigin :: MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
- grhssCtOrigin :: GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin
- isVisibleOrigin :: CtOrigin -> Bool
- toInvisibleOrigin :: CtOrigin -> CtOrigin
- pprCtOrigin :: CtOrigin -> SDoc
- isGivenOrigin :: CtOrigin -> Bool
- isWantedWantedFunDepOrigin :: CtOrigin -> Bool
- isWantedSuperclassOrigin :: CtOrigin -> Bool
- data ClsInstOrQC
  - = IsClsInst
  - | IsQC CtOrigin
- data NakedScFlag
  - = NakedSc
  - | NotNakedSc
- data NonLinearPatternReason
  - = LazyPatternReason
  - | GeneralisedPatternReason
  - | PatternSynonymReason
  - | ViewPatternReason
  - | OtherPatternReason
- data TypedThing
  - = HsTypeRnThing (HsType GhcRn)
  - | TypeThing Type
  - | HsExprRnThing (HsExpr GhcRn)
  - | HsExprTcThing (HsExpr GhcTc)
  - | NameThing Name
- data TyVarBndrs = OutputableBndrFlag flag 'Renamed => HsTyVarBndrsRn [HsTyVarBndr flag GhcRn]
- isPushCallStackOrigin :: CtOrigin -> Bool
- callStackOriginFS :: CtOrigin -> FastString
- data FixedRuntimeRepOrigin = FixedRuntimeRepOrigin {
  - frr_type :: Type
  - frr_context :: FixedRuntimeRepContext
  }
- data FixedRuntimeRepContext
  - = FRRRecordCon !RdrName !(HsExpr GhcTc)
  - | FRRRecordUpdate !Name !(HsExpr GhcRn)
  - | FRRBinder !Name
  - | FRRRepPolyId !Name !RepPolyId !(Position 'Neg)
  - | FRRRepPolyUnliftedNewtype !DataCon
  - | FRRPatBind
  - | FRRPatSynArg
  - | FRRCase
  - | FRRDataConPatArg !DataCon !Int
  - | FRRUnboxedTuple !Int
  - | FRRUnboxedTupleSection !Int
  - | FRRUnboxedSum !(Maybe Int)
  - | FRRBodyStmt !StmtOrigin !Int
  - | FRRBodyStmtGuard
  - | FRRBindStmt !StmtOrigin
  - | FRRBindStmtGuard
  - | FRRArrow !FRRArrowContext
  - | FRRExpectedFunTy !ExpectedFunTyOrigin !Int
- pprFixedRuntimeRepContext :: FixedRuntimeRepContext -> SDoc
- data StmtOrigin
  - = MonadComprehension
  - | DoNotation
- data ArgPos
  - = ArgPosInvis
  - | ArgPosVis !Int
- mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext
- mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext
- data RepPolyId
  - = RepPolyPrimOp
  - | RepPolyTuple
  - | RepPolySum
  - | RepPolyFunction
- data Polarity
  - = Pos
  - | Neg
- data Position (p :: Polarity) where
  - Argument :: forall (p :: Polarity). Int -> Position (FlipPolarity p) -> Position p
  - Result :: forall (p :: Polarity). Position p -> Position p
  - Top :: Position 'Pos
- data FRRArrowContext
  - = ArrowCmdResTy !(HsCmd GhcRn)
  - | ArrowCmdApp !(HsCmd GhcRn) !(HsExpr GhcRn)
  - | ArrowCmdArrApp !(HsExpr GhcRn) !(HsExpr GhcRn) !HsArrAppType
  - | ArrowCmdCase
  - | ArrowFun !(HsExpr GhcRn)
- pprFRRArrowContext :: FRRArrowContext -> SDoc
- data ExpectedFunTyOrigin
  - = OutputableBndrId p => ExpectedFunTySyntaxOp !CtOrigin !(HsExpr (GhcPass p))
  - | ExpectedFunTyViewPat !(HsExpr GhcRn)
  - | Outputable (HsExpr (GhcPass p)) => ExpectedFunTyArg !TypedThing !(HsExpr (GhcPass p))
  - | ExpectedFunTyMatches !TypedThing !(MatchGroup GhcRn (LHsExpr GhcRn))
  - | ExpectedFunTyLam HsLamVariant !(HsExpr GhcRn)
- pprExpectedFunTyOrigin :: ExpectedFunTyOrigin -> Int -> SDoc
- pprExpectedFunTyHerald :: ExpectedFunTyOrigin -> SDoc
- data InstanceWhat
  - = BuiltinEqInstance
  - | BuiltinTypeableInstance TyCon
  - | BuiltinInstance
  - | LocalInstance
  - | TopLevInstance {
    - iw_dfun_id :: DFunId
    - iw_safe_over :: SafeOverlapping
    - iw_warn :: Maybe (WarningTxt GhcRn)
    }
- type SafeOverlapping = Bool

# UserTypeCtxt

data UserTypeCtxt #

UserTypeCtxt describes the origin of the polymorphic type in the places where we need an expression to have that type

Constructors

FunSigCtxt Name ReportRedundantConstraints |
InfSigCtxt Name |
ExprSigCtxt ReportRedundantConstraints |
KindSigCtxt |
StandaloneKindSigCtxt Name |
TypeAppCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSynCtxt Name |
PatSigCtxt |
RuleSigCtxt FastString Name |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt Bool |
SpecInstCtxt |
GenSigCtxt |
GhciCtxt Bool |
ClassSCCtxt Name |
SigmaCtxt |
DataTyCtxt Name |
DerivClauseCtxt |
TyVarBndrKindCtxt Name |
DataKindCtxt Name |
TySynKindCtxt Name |
TyFamResKindCtxt Name |

#### Instances

Instances details

Eq UserTypeCtxt # |
Instance details Defined in GHC.Tc.Types.Origin Methods (==) :: UserTypeCtxt -> UserTypeCtxt -> Bool # (/=) :: UserTypeCtxt -> UserTypeCtxt -> Bool #

pprUserTypeCtxt :: UserTypeCtxt -> SDoc #

isSigMaybe :: UserTypeCtxt -> Maybe Name #

data ReportRedundantConstraints #

Report Redundant Constraints.

Constructors

NoRRC | Don't report redundant constraints
WantRRC SrcSpan | Report redundant constraints The SrcSpan is for the constraints E.g. f :: (Eq a, Ord b) => blah The span is for the (Eq a, Ord b) We need to record the span here because we have long since discarded the HsType in favour of a Type

#### Instances

Instances details

Eq ReportRedundantConstraints # |
Instance details Defined in GHC.Tc.Types.Origin Methods (==) :: ReportRedundantConstraints -> ReportRedundantConstraints -> Bool # (/=) :: ReportRedundantConstraints -> ReportRedundantConstraints -> Bool #

reportRedundantConstraints :: ReportRedundantConstraints -> Bool #

redundantConstraintsSpan :: UserTypeCtxt -> SrcSpan #

# SkolemInfo

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

Constructors

SkolemInfo |
Fields Unique The Unique is used to common up skolem variables bound at the same location (only used in pprSkols) SkolemInfoAnon The information about the origin of the skolem type variable

#### Instances

Instances details

Uniquable SkolemInfo # |
Instance details Defined in GHC.Tc.Types.Origin Methods getUnique :: SkolemInfo -> Unique #
Outputable SkolemInfo # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: SkolemInfo -> SDoc #

data 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

Constructors

SigSkol UserTypeCtxt TcType [(Name, TcTyVar)] |
SigTypeSkol UserTypeCtxt |
ForAllSkol TyVarBndrs |
DerivSkol Type |
InstSkol ClsInstOrQC PatersonSize |
FamInstSkol |
PatSkol ConLike HsMatchContextRn |
IPSkol [HsIPName] |
RuleSkol RuleName |
InferSkol [(Name, TcType)] |
BracketSkol |
UnifyForAllSkol TcType |
TyConSkol (TyConFlavour TyCon) Name |
DataConSkol Name |
ReifySkol |
RuntimeUnkSkol |
ArrowReboundIfSkol |
UnkSkol CallStack |

#### Instances

Instances details

Outputable SkolemInfoAnon # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: SkolemInfoAnon -> SDoc #

mkSkolemInfo :: MonadIO m => SkolemInfoAnon -> m SkolemInfo #

Wrap up the origin of a skolem type variable with a new `Unique`, so that we can common up skolem type variables whose `SkolemInfo` shares a certain `Unique`.

getSkolemInfo :: SkolemInfo -> SkolemInfoAnon #

pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc #

pprSkolInfo :: SkolemInfoAnon -> SDoc #

unkSkol :: HasCallStack => SkolemInfo #

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.

unkSkolAnon :: HasCallStack => SkolemInfoAnon #

mkClsInstSkol :: Class -> [Type] -> SkolemInfoAnon #

# CtOrigin

data CtOrigin #

Constructors

GivenOrigin SkolemInfoAnon | A given constraint from a user-written type signature. The `SkolemInfo` inside gives more information.
GivenSCOrigin | `GivenSCOrigin` is used for a Given constraint obtained by superclass selection from the context of an instance declaration. E.g. instance `(Foo a, Bar a) => C [a]` where ... When typechecking the instance decl itself, including producing evidence for the superclasses of `C`, the superclasses of `(Foo a)` and `(Bar a)` will have `GivenSCOrigin` origin.
Fields SkolemInfoAnon Just like GivenOrigin ScDepth The number of superclass selections necessary to get this constraint; see Note [Replacement vs keeping] in GHC.Tc.Solver.Dict Bool True => "blocked": cannot use this to solve naked superclass Wanteds i.e. ones with (ScOrigin _ NakedSc) False => can use this to solve all Wanted constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance
OccurrenceOf Name |
OccurrenceOfRecSel RdrName |
AppOrigin |
SpecPragOrigin UserTypeCtxt |
TypeEqOrigin |
Fields uo_actual :: TcType uo_expected :: TcType uo_thing :: Maybe TypedThing The thing that has type "actual" uo_visible :: Bool Is at least one of the three elements above visible? (Errors from the polymorphic subsumption check are considered visible.) Only used for prioritizing error messages.
KindEqOrigin TcType TcType CtOrigin (Maybe TypeOrKind) |
IPOccOrigin HsIPName |
OverLabelOrigin FastString |
LiteralOrigin (HsOverLit GhcRn) |
NegateOrigin |
ArithSeqOrigin (ArithSeqInfo GhcRn) |
AssocFamPatOrigin |
SectionOrigin |
HasFieldOrigin FastString |
TupleOrigin |
ExprSigOrigin |
PatSigOrigin |
PatOrigin |
ProvCtxtOrigin (PatSynBind GhcRn GhcRn) |
RecordUpdOrigin |
ViewPatOrigin |
ScOrigin ClsInstOrQC NakedScFlag | `ScOrigin` is used only for the Wanted constraints for the superclasses of an instance declaration.
DerivClauseOrigin |
DerivOriginDC DataCon Int Bool |
DerivOriginCoerce Id Type Type Bool |
StandAloneDerivOrigin |
DefaultOrigin |
DoOrigin |
DoPatOrigin (LPat GhcRn) |
MCompOrigin |
MCompPatOrigin (LPat GhcRn) |
ProcOrigin |
ArrowCmdOrigin |
AnnOrigin |
FunDepOrigin1 PredType CtOrigin RealSrcSpan PredType CtOrigin RealSrcSpan |
FunDepOrigin2 PredType CtOrigin PredType SrcSpan |
InjTFOrigin1 PredType CtOrigin RealSrcSpan PredType CtOrigin RealSrcSpan |
ExprHoleOrigin (Maybe RdrName) |
TypeHoleOrigin OccName |
PatCheckOrigin |
ListOrigin |
IfThenElseOrigin |
BracketOrigin |
StaticOrigin |
ImpedanceMatching Id |
Shouldn'tHappenOrigin String |
InstProvidedOrigin | Testing whether the constraint associated with an instance declaration in a signature file is satisfied upon instantiation. Test cases: backpackshould_failbkpfail{11,43}.bkp
Fields Module Module in which the instance was declared ClsInst The declared typeclass instance
NonLinearPatternOrigin NonLinearPatternReason (LPat GhcRn) |
UsageEnvironmentOf Name |
CycleBreakerOrigin CtOrigin |
FRROrigin FixedRuntimeRepOrigin |
WantedSuperclassOrigin PredType CtOrigin |
InstanceSigOrigin Name Type Type |
AmbiguityCheckOrigin UserTypeCtxt |

#### Instances

Instances details

Outputable CtOrigin # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: CtOrigin -> SDoc #

exprCtOrigin :: HsExpr GhcRn -> CtOrigin #

lexprCtOrigin :: LHsExpr GhcRn -> CtOrigin #

Extract a suitable CtOrigin from a HsExpr

matchesCtOrigin :: MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin #

Extract a suitable CtOrigin from a MatchGroup

grhssCtOrigin :: GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin #

Extract a suitable CtOrigin from guarded RHSs

isVisibleOrigin :: CtOrigin -> Bool #

toInvisibleOrigin :: CtOrigin -> CtOrigin #

pprCtOrigin :: CtOrigin -> SDoc #

isGivenOrigin :: CtOrigin -> Bool #

isWantedWantedFunDepOrigin :: CtOrigin -> Bool #

isWantedSuperclassOrigin :: CtOrigin -> Bool #

Did a constraint arise from expanding a Wanted constraint to look at superclasses?

data ClsInstOrQC #

Constructors

IsClsInst |
IsQC CtOrigin |

data NakedScFlag #

Constructors

NakedSc |
NotNakedSc |

#### Instances

Instances details

Outputable NakedScFlag # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: NakedScFlag -> SDoc #

data NonLinearPatternReason #

Constructors

LazyPatternReason |
GeneralisedPatternReason |
PatternSynonymReason |
ViewPatternReason |
OtherPatternReason |

data TypedThing #

Some thing which has a type.

This datatype is used when we want to report to the user that something has an unexpected type.

Constructors

HsTypeRnThing (HsType GhcRn) |
TypeThing Type |
HsExprRnThing (HsExpr GhcRn) |
HsExprTcThing (HsExpr GhcTc) |
NameThing Name |

#### Instances

Instances details

Outputable TypedThing # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: TypedThing -> SDoc #

data TyVarBndrs #

Some kind of type variable binder.

Used for reporting errors, in `SkolemInfo` and `TcSolverReportMsg`.

Constructors

OutputableBndrFlag flag 'Renamed => HsTyVarBndrsRn [HsTyVarBndr flag GhcRn] |

#### Instances

Instances details

Outputable TyVarBndrs # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: TyVarBndrs -> SDoc #

# CallStack

isPushCallStackOrigin :: CtOrigin -> Bool #

callStackOriginFS :: CtOrigin -> FastString #

# FixedRuntimeRep origin

data FixedRuntimeRepOrigin #

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

FixedRuntimeRepOrigin |
Fields frr_type :: Type What type are we checking? For example, `a[tau]` in `a[tau] :: TYPE rr[tau]`. frr_context :: FixedRuntimeRepContext What context requires a fixed runtime representation?

#### Instances

Instances details

Outputable FixedRuntimeRepOrigin # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: FixedRuntimeRepOrigin -> SDoc #

data FixedRuntimeRepContext #

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.
FRRRepPolyUnliftedNewtype !DataCon | A partial application of the constructor of a representation-polymorphic unlifted newtype in which the argument type does not have a fixed runtime representation. Test cases: UnliftedNewtypesLevityBinder, UnliftedNewtypesCoerceFail.
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 `RuntimeRep`s. 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 `RuntimeRep`s. 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 | A representation-polymorphic check arising from a call to `matchExpectedFunTys` or `matchActualFunTy`. See `ExpectedFunTyOrigin` for more details.
Fields !ExpectedFunTyOrigin !Int argument position (1-indexed)

#### Instances

Instances details

Outputable FixedRuntimeRepContext # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: FixedRuntimeRepContext -> SDoc #

pprFixedRuntimeRepContext :: FixedRuntimeRepContext -> SDoc #

Print the context for a `FixedRuntimeRep` representation-polymorphism check.

Note that this function does not include the specific `RuntimeRep` which is not fixed. That information is stored in `FixedRuntimeRepOrigin` and is reported separately.

data StmtOrigin #

Are we in a `do` expression or a monad comprehension?

This datatype is only used to report this context to the user in error messages.

Constructors

MonadComprehension |
DoNotation |

#### Instances

Instances details

Outputable StmtOrigin # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: StmtOrigin -> SDoc #

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

mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext #

A synonym for `FRRUnboxedTuple` exposed in the hs-boot file for GHC.Tc.Types.Origin.

mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext #

A synonym for `FRRUnboxedSum` exposed in the hs-boot file for GHC.Tc.Types.Origin.

## FixedRuntimeRep origin for rep-poly `Id`s

data RepPolyId #

The description of a representation-polymorphic `Id`.

Constructors

RepPolyPrimOp | A representation-polymorphic `PrimOp`.
RepPolyTuple | An unboxed tuple constructor.
RepPolySum | An unboxed sum constructor.
RepPolyFunction | An unspecified representation-polymorphic function, e.g. a pseudo-op such as `coerce`.

data Polarity #

Constructors

Pos |
Neg |

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

Constructors

Argument :: forall (p :: Polarity). Int -> Position (FlipPolarity p) -> Position p | In the `i`-th argument of a function arrow
Result :: forall (p :: Polarity). Position p -> Position p | In the result of a function arrow
Top :: Position 'Pos | At the top level of a type

## Arrow command FixedRuntimeRep origin

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

#### Instances

Instances details

Outputable FRRArrowContext # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: FRRArrowContext -> SDoc #

pprFRRArrowContext :: FRRArrowContext -> SDoc #

## ExpectedFunTy FixedRuntimeRepOrigin

data ExpectedFunTyOrigin #

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 `pprExpectedFunTyOrigin`. See `FixedRuntimeRepContext` for the situations in which representation-polymorphism checks are performed.

Constructors

OutputableBndrId p => ExpectedFunTySyntaxOp | A rebindable syntax operator is expected to have a function type. Test cases for representation-polymorphism checks: RepPolyDoBind, RepPolyDoBody{1,2}, RepPolyMc{Bind,Body,Guard}, RepPolyNPlusK
Fields !CtOrigin !(HsExpr (GhcPass p)) rebindable syntax operator
ExpectedFunTyViewPat | A view pattern must have a function type. Test cases for representation-polymorphism checks: RepPolyBinder
Fields !(HsExpr GhcRn) function used in the view pattern
Outputable (HsExpr (GhcPass p)) => ExpectedFunTyArg | Need to be able to extract an argument type from a function type. Test cases for representation-polymorphism checks: RepPolyApp
Fields !TypedThing function !(HsExpr (GhcPass p)) argument
ExpectedFunTyMatches | Ensure that a function defined by equations indeed has a function type with the appropriate number of arguments. Test cases for representation-polymorphism checks: RepPolyBinder, RepPolyRecordPattern, RepPolyWildcardPattern
Fields !TypedThing name of the function !(MatchGroup GhcRn (LHsExpr GhcRn)) equations
ExpectedFunTyLam | Ensure that a lambda abstraction has a function type. Test cases for representation-polymorphism checks: RepPolyLambda, RepPolyMatch
Fields HsLamVariant !(HsExpr GhcRn) the entire lambda-case expression

pprExpectedFunTyOrigin #

Arguments

:: ExpectedFunTyOrigin |
-> Int | argument position (starting at 1)
-> SDoc |

pprExpectedFunTyHerald :: ExpectedFunTyOrigin -> SDoc #

# InstanceWhat

data InstanceWhat #

Constructors

BuiltinEqInstance |
BuiltinTypeableInstance TyCon |
BuiltinInstance |
LocalInstance |
TopLevInstance |
Fields iw_dfun_id :: DFunId iw_safe_over :: SafeOverlapping iw_warn :: Maybe (WarningTxt GhcRn)

#### Instances

Instances details

Outputable InstanceWhat # |
Instance details Defined in GHC.Tc.Types.Origin Methods ppr :: InstanceWhat -> SDoc #

type 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