Safe Haskell | None |
---|---|
Language | Haskell2010 |
GHC.Tc.Types.Origin
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
- 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
- | FamInstSkol
- | PatSkol ConLike (HsMatchContext GhcTc)
- | IPSkol [HsIPName]
- | RuleSkol RuleName
- | InferSkol [(Name, TcType)]
- | BracketSkol
- | UnifyForAllSkol TcType
- | TyConSkol TyConFlavour Name
- | DataConSkol Name
- | ReifySkol
- | QuantCtxtSkol
- | 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
- data CtOrigin
- = GivenOrigin SkolemInfoAnon
- | InstSCOrigin ScDepth TypeSize
- | OtherSCOrigin ScDepth SkolemInfoAnon
- | OccurrenceOf Name
- | OccurrenceOfRecSel RdrName
- | AppOrigin
- | SpecPragOrigin UserTypeCtxt
- | TypeEqOrigin { }
- | 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 TypeSize
- | 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
- | ExprHoleOrigin OccName
- | TypeHoleOrigin OccName
- | PatCheckOrigin
- | ListOrigin
- | IfThenElseOrigin
- | BracketOrigin
- | StaticOrigin
- | Shouldn'tHappenOrigin String
- | InstProvidedOrigin Module ClsInst
- | NonLinearPatternOrigin
- | UsageEnvironmentOf Name
- | CycleBreakerOrigin CtOrigin
- | FixedRuntimeRepOrigin !Type !FRROrigin
- 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
- data TypedThing
- data TyVarBndrs = forall flag.OutputableBndrFlag flag 'Renamed => HsTyVarBndrsRn [HsTyVarBndr flag GhcRn]
- isPushCallStackOrigin :: CtOrigin -> Bool
- callStackOriginFS :: CtOrigin -> FastString
- data FRROrigin
- = FRRApp !(HsExpr GhcRn)
- | FRRRecordUpdate !RdrName !(HsExpr GhcRn)
- | FRRBinder !Name
- | FRRMatch !(HsMatchContext GhcTc) !Int
- | FRRDataConArg !DataCon !Int
- | FRRNoBindingResArg !Id !Int
- | FRRTupleArg !Int
- | FRRTupleSection !Int
- | FRRUnboxedSum
- | FRRBodyStmt !StmtOrigin !Int
- | FRRBodyStmtGuard
- | FRRBindStmt !StmtOrigin
- | FRRBindStmtGuard
- | FRRArrow !FRRArrowOrigin
- | FRRWpFun !WpFunOrigin
- pprFRROrigin :: FRROrigin -> SDoc
- data StmtOrigin
- data FRRArrowOrigin
- = ArrowCmdResTy !(HsCmd GhcRn)
- | ArrowCmdApp !(HsCmd GhcRn) !(HsExpr GhcRn)
- | ArrowCmdArrApp !(HsExpr GhcRn) !(HsExpr GhcRn) !HsArrAppType
- | ArrowCmdLam !Int
- | ArrowFun !(HsExpr GhcRn)
- pprFRRArrowOrigin :: FRRArrowOrigin -> SDoc
- data WpFunOrigin
- pprWpFunOrigin :: WpFunOrigin -> SDoc
Documentation
data UserTypeCtxt Source #
UserTypeCtxt describes the origin of the polymorphic type in the places where we need an expression to have that type
Constructors
Instances
Eq UserTypeCtxt Source # | |
Defined in GHC.Tc.Types.Origin |
pprUserTypeCtxt :: UserTypeCtxt -> SDoc Source #
isSigMaybe :: UserTypeCtxt -> Maybe Name Source #
data ReportRedundantConstraints Source #
Report Redundant Constraints.
Constructors
NoRRC | Don't report redundant constraints |
WantRRC SrcSpan | Report redundant constraints, and here is the SrcSpan for the constraints E.g. f :: (Eq a, Ord b) => blah The span is for the (Eq a, Ord b) |
Instances
Eq ReportRedundantConstraints Source # | |
Defined in GHC.Tc.Types.Origin Methods (==) :: ReportRedundantConstraints -> ReportRedundantConstraints -> Bool # (/=) :: ReportRedundantConstraints -> ReportRedundantConstraints -> Bool # |
data SkolemInfo Source #
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
|
Instances
Outputable SkolemInfo Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: SkolemInfo -> SDoc Source # | |
Uniquable SkolemInfo Source # | |
Defined in GHC.Tc.Types.Origin Methods getUnique :: SkolemInfo -> Unique Source # |
data SkolemInfoAnon Source #
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 matchk
withl
"
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
Instances
Outputable SkolemInfoAnon Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: SkolemInfoAnon -> SDoc Source # |
mkSkolemInfo :: MonadIO m => SkolemInfoAnon -> m SkolemInfo Source #
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
.
pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc Source #
pprSkolInfo :: SkolemInfoAnon -> SDoc Source #
unkSkol :: HasCallStack => SkolemInfo Source #
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.
Constructors
GivenOrigin SkolemInfoAnon | A given constraint from a user-written type signature. The
|
InstSCOrigin |
|
Fields
| |
OtherSCOrigin |
|
Fields
| |
OccurrenceOf Name | |
OccurrenceOfRecSel RdrName | |
AppOrigin | |
SpecPragOrigin UserTypeCtxt | |
TypeEqOrigin | |
Fields
| |
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 TypeSize |
|
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 | |
ExprHoleOrigin OccName | |
TypeHoleOrigin OccName | |
PatCheckOrigin | |
ListOrigin | |
IfThenElseOrigin | |
BracketOrigin | |
StaticOrigin | |
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 |
NonLinearPatternOrigin | |
UsageEnvironmentOf Name | |
CycleBreakerOrigin CtOrigin | |
FixedRuntimeRepOrigin | |
Instances
matchesCtOrigin :: MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin Source #
Extract a suitable CtOrigin from a MatchGroup
grhssCtOrigin :: GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin Source #
Extract a suitable CtOrigin from guarded RHSs
isVisibleOrigin :: CtOrigin -> Bool Source #
toInvisibleOrigin :: CtOrigin -> CtOrigin Source #
pprCtOrigin :: CtOrigin -> SDoc Source #
isGivenOrigin :: CtOrigin -> Bool Source #
data TypedThing Source #
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) | |
NameThing Name |
Instances
Outputable TypedThing Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: TypedThing -> SDoc Source # |
data TyVarBndrs Source #
Some kind of type variable binder.
Used for reporting errors, in SkolemInfo
and TcReportMsg
.
Constructors
forall flag.OutputableBndrFlag flag 'Renamed => HsTyVarBndrsRn [HsTyVarBndr flag GhcRn] |
Instances
Outputable TyVarBndrs Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: TyVarBndrs -> SDoc Source # |
isPushCallStackOrigin :: CtOrigin -> Bool Source #
Where are we checking that a type has a fixed runtime representation? Equivalently: what is the origin of an emitted 'Concrete#' constraint?
Constructors
FRRApp !(HsExpr GhcRn) | Function arguments must have a fixed runtime representation. Test case: RepPolyApp. |
FRRRecordUpdate !RdrName !(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. |
FRRMatch !(HsMatchContext GhcTc) !Int | The type of a pattern in a match group must have a fixed runtime representation. This rules out: - individual patterns which don't have a fixed runtime representation, - a representation-polymorphic empty case statement, - representation-polymorphic GADT pattern matches in which individual pattern types have a fixed runtime representation. Test cases: RepPolyRecordPattern, RepPolyUnboxedPatterns, RepPolyBinder, RepPolyWildcardPattern, RepPolyMatch, RepPolyNPlusK, RepPolyPatBind, T20426. |
FRRDataConArg !DataCon !Int | An instantiation of a newtype/data constructor in which one of the remaining arguments types does not have a fixed runtime representation. Test case: UnliftedNewtypesLevityBinder. |
FRRNoBindingResArg !Id !Int | An instantiation of an Test cases: RepPolyWrappedVar, T14561, UnliftedNewtypesCoerceFail. |
FRRTupleArg !Int | Arguments to unboxed tuples must have fixed runtime representations. Test case: RepPolyTuple. |
FRRTupleSection !Int | Tuple sections must have a fixed runtime representation. Test case: RepPolyTupleSection. |
FRRUnboxedSum | Unboxed sums must have a fixed runtime representation. Test cases: RepPolySum. |
FRRBodyStmt !StmtOrigin !Int | The body of a Test cases: RepPolyDoBody{1,2}, RepPolyMcBody. |
FRRBodyStmtGuard | Arguments to a guard in a monad comprehesion must have a fixed runtime representation. Test case: RepPolyMcGuard. |
FRRBindStmt !StmtOrigin | Arguments to Test cases: RepPolyDoBind, RepPolyMcBind. |
FRRBindStmtGuard | A value bound by a pattern guard must have a fixed runtime representation. Test cases: none. |
FRRArrow !FRRArrowOrigin | A representation-polymorphism check arising from arrow notation. See |
FRRWpFun !WpFunOrigin | A representation-polymorphic check arising from an See |
Instances
pprFRROrigin :: FRROrigin -> SDoc Source #
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 added by mkFRRErr
.
data StmtOrigin Source #
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
Outputable StmtOrigin Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: StmtOrigin -> SDoc Source # |
data FRRArrowOrigin Source #
While typechecking arrow notation, in which context did a representation polymorphism check arise?
See FRROrigin
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. |
ArrowCmdLam !Int | A pattern in an arrow command abstraction 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
Outputable FRRArrowOrigin Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: FRRArrowOrigin -> SDoc Source # |
data WpFunOrigin Source #
While typechecking a WpFun
HsWrapper
, in which context
did a representation polymorphism check arise?
See FRROrigin
for more general origins of representation polymorphism checks.
Constructors
WpFunSyntaxOp !CtOrigin | |
WpFunViewPat !(HsExpr GhcRn) | |
WpFunFunTy !Type | |
WpFunFunExpTy !ExpType |
Instances
Outputable WpFunOrigin Source # | |
Defined in GHC.Tc.Types.Origin Methods ppr :: WpFunOrigin -> SDoc Source # |
pprWpFunOrigin :: WpFunOrigin -> SDoc Source #