Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
GHC.Tc.Types
Description
Various types used during typechecking.
Please see GHC.Tc.Utils.Monad as well for operations on these types. You probably want to import it, instead of this module.
All the monads exported here are built on top of the same IOEnv monad. The monad functions like a Reader monad in the way it passes the environment around. This is done to allow the environment to be manipulated in a stack like fashion when entering expressions... etc.
For state that is global and should be returned at the end (e.g not part of the stack mechanism), you should use a TcRef (= IORef) to store them.
Synopsis
- type TcRnIf a b = IOEnv (Env a b)
- type TcRn = TcRnIf TcGblEnv TcLclEnv
- type TcM = TcRn
- type RnM = TcRn
- type IfM lcl = TcRnIf IfGblEnv lcl
- type IfL = IfM IfLclEnv
- type IfG = IfM ()
- type TcRef a = IORef a
- data Env gbl lcl = Env {}
- data TcGblEnv = TcGblEnv {
- tcg_mod :: Module
- tcg_semantic_mod :: Module
- tcg_src :: HscSource
- tcg_rdr_env :: GlobalRdrEnv
- tcg_default :: Maybe [Type]
- tcg_fix_env :: FixityEnv
- tcg_field_env :: RecFieldEnv
- tcg_type_env :: TypeEnv
- tcg_type_env_var :: TcRef TypeEnv
- tcg_inst_env :: !InstEnv
- tcg_fam_inst_env :: !FamInstEnv
- tcg_ann_env :: AnnEnv
- tcg_exports :: [AvailInfo]
- tcg_imports :: ImportAvails
- tcg_dus :: DefUses
- tcg_used_gres :: TcRef [GlobalRdrElt]
- tcg_keep :: TcRef NameSet
- tcg_th_used :: TcRef Bool
- tcg_th_splice_used :: TcRef Bool
- tcg_dfun_n :: TcRef OccSet
- tcg_merged :: [(Module, Fingerprint)]
- tcg_rn_exports :: Maybe [(LIE GhcRn, Avails)]
- tcg_rn_imports :: [LImportDecl GhcRn]
- tcg_rn_decls :: Maybe (HsGroup GhcRn)
- tcg_dependent_files :: TcRef [FilePath]
- tcg_th_topdecls :: TcRef [LHsDecl GhcPs]
- tcg_th_foreign_files :: TcRef [(ForeignSrcLang, FilePath)]
- tcg_th_topnames :: TcRef NameSet
- tcg_th_modfinalizers :: TcRef [(TcLclEnv, ThModFinalizers)]
- tcg_th_coreplugins :: TcRef [String]
- tcg_th_state :: TcRef (Map TypeRep Dynamic)
- tcg_th_remote_state :: TcRef (Maybe (ForeignRef (IORef QState)))
- tcg_th_docs :: TcRef THDocs
- tcg_ev_binds :: Bag EvBind
- tcg_tr_module :: Maybe Id
- tcg_binds :: LHsBinds GhcTc
- tcg_sigs :: NameSet
- tcg_imp_specs :: [LTcSpecPrag]
- tcg_warns :: Warnings
- tcg_anns :: [Annotation]
- tcg_tcs :: [TyCon]
- tcg_ksigs :: NameSet
- tcg_insts :: [ClsInst]
- tcg_fam_insts :: [FamInst]
- tcg_rules :: [LRuleDecl GhcTc]
- tcg_fords :: [LForeignDecl GhcTc]
- tcg_patsyns :: [PatSyn]
- tcg_doc_hdr :: Maybe LHsDocString
- tcg_hpc :: !AnyHpcUsage
- tcg_self_boot :: SelfBootInfo
- tcg_main :: Maybe Name
- tcg_safeInfer :: TcRef (Bool, WarningMessages)
- tcg_tc_plugins :: [TcPluginSolver]
- tcg_hf_plugins :: [HoleFitPlugin]
- tcg_top_loc :: RealSrcSpan
- tcg_static_wc :: TcRef WantedConstraints
- tcg_complete_matches :: !CompleteMatches
- tcg_cc_st :: TcRef CostCentreState
- data TcLclEnv = TcLclEnv {
- tcl_loc :: RealSrcSpan
- tcl_ctxt :: [ErrCtxt]
- tcl_in_gen_code :: Bool
- tcl_tclvl :: TcLevel
- tcl_th_ctxt :: ThStage
- tcl_th_bndrs :: ThBindEnv
- tcl_arrow_ctxt :: ArrowCtxt
- tcl_rdr :: LocalRdrEnv
- tcl_env :: TcTypeEnv
- tcl_usage :: TcRef UsageEnv
- tcl_bndrs :: TcBinderStack
- tcl_lie :: TcRef WantedConstraints
- tcl_errs :: TcRef (Messages DecoratedSDoc)
- setLclEnvTcLevel :: TcLclEnv -> TcLevel -> TcLclEnv
- getLclEnvTcLevel :: TcLclEnv -> TcLevel
- setLclEnvLoc :: TcLclEnv -> RealSrcSpan -> TcLclEnv
- getLclEnvLoc :: TcLclEnv -> RealSrcSpan
- data IfGblEnv = IfGblEnv {}
- data IfLclEnv = IfLclEnv {}
- tcVisibleOrphanMods :: TcGblEnv -> ModuleSet
- data FrontendResult = FrontendTypecheck TcGblEnv
- type ErrCtxt = (Bool, TidyEnv -> TcM (TidyEnv, SDoc))
- type RecFieldEnv = NameEnv [FieldLabel]
- pushErrCtxt :: CtOrigin -> ErrCtxt -> CtLoc -> CtLoc
- pushErrCtxtSameOrigin :: ErrCtxt -> CtLoc -> CtLoc
- data ImportAvails = ImportAvails {}
- emptyImportAvails :: ImportAvails
- plusImportAvails :: ImportAvails -> ImportAvails -> ImportAvails
- data WhereFrom
- mkModDeps :: [ModuleNameWithIsBoot] -> ModuleNameEnv ModuleNameWithIsBoot
- modDepsElts :: ModuleNameEnv ModuleNameWithIsBoot -> [ModuleNameWithIsBoot]
- type TcTypeEnv = NameEnv TcTyThing
- type TcBinderStack = [TcBinder]
- data TcBinder
- data TcTyThing
- = AGlobal TyThing
- | ATcId {
- tct_id :: TcId
- tct_info :: IdBindingInfo
- | ATyVar Name TcTyVar
- | ATcTyCon TyCon
- | APromotionErr PromotionErr
- data PromotionErr
- data IdBindingInfo
- type ClosedTypeId = Bool
- type RhsNames = NameSet
- data IsGroupClosed = IsGroupClosed (NameEnv RhsNames) ClosedTypeId
- data SelfBootInfo
- = NoSelfBoot
- | SelfBoot {
- sb_mds :: ModDetails
- sb_tcs :: NameSet
- tcTyThingCategory :: TcTyThing -> String
- pprTcTyThingCategory :: TcTyThing -> SDoc
- peCategory :: PromotionErr -> String
- pprPECategory :: PromotionErr -> SDoc
- data CompleteMatch
- type CompleteMatches = [CompleteMatch]
- data ThStage
- = Splice SpliceType
- | RunSplice (TcRef [ForeignRef (Q ())])
- | Comp
- | Brack ThStage PendingStuff
- data SpliceType
- data PendingStuff
- topStage :: ThStage
- topAnnStage :: ThStage
- topSpliceStage :: ThStage
- type ThLevel = Int
- impLevel :: ThLevel
- outerLevel :: ThLevel
- thLevel :: ThStage -> ThLevel
- data ForeignSrcLang
- type THDocs = Map DocLoc String
- data DocLoc
- data ArrowCtxt
- type TcSigFun = Name -> Maybe TcSigInfo
- data TcSigInfo
- data TcIdSigInfo
- = CompleteSig { }
- | PartialSig { }
- data TcIdSigInst = TISI {
- sig_inst_sig :: TcIdSigInfo
- sig_inst_skols :: [(Name, InvisTVBinder)]
- sig_inst_theta :: TcThetaType
- sig_inst_tau :: TcSigmaType
- sig_inst_wcs :: [(Name, TcTyVar)]
- sig_inst_wcx :: Maybe TcType
- data TcPatSynInfo = TPSI {}
- isPartialSig :: TcIdSigInst -> Bool
- hasCompleteSig :: TcSigFun -> Name -> Bool
- type TcId = Id
- type TcIdSet = IdSet
- data NameShape = NameShape {
- ns_mod_name :: ModuleName
- ns_exports :: [AvailInfo]
- ns_map :: OccEnv Name
- removeBindingShadowing :: HasOccName a => [a] -> [a]
- getPlatform :: TcM Platform
- data TcPlugin = forall s.TcPlugin {
- tcPluginInit :: TcPluginM s
- tcPluginSolve :: s -> TcPluginSolver
- tcPluginStop :: s -> TcPluginM ()
- data TcPluginResult
- = TcPluginContradiction [Ct]
- | TcPluginOk [(EvTerm, Ct)] [Ct]
- type TcPluginSolver = [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginResult
- data TcPluginM a
- runTcPluginM :: TcPluginM a -> EvBindsVar -> TcM a
- unsafeTcPluginTcM :: TcM a -> TcPluginM a
- getEvBindsTcPluginM :: TcPluginM EvBindsVar
- type RoleAnnotEnv = NameEnv (LRoleAnnotDecl GhcRn)
- emptyRoleAnnotEnv :: RoleAnnotEnv
- mkRoleAnnotEnv :: [LRoleAnnotDecl GhcRn] -> RoleAnnotEnv
- lookupRoleAnnot :: RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn)
- getRoleAnnots :: [Name] -> RoleAnnotEnv -> [LRoleAnnotDecl GhcRn]
- lintGblEnv :: Logger -> DynFlags -> TcGblEnv -> TcM ()
Documentation
Instances
TcGblEnv
describes the top-level of the module at the
point at which the typechecker is finished work.
It is this structure that is handed on to the desugarer
For state that needs to be updated during the typechecking
phase and returned at end, use a TcRef
(= IORef
).
Constructors
TcGblEnv | |
Fields
|
Instances
Constructors
TcLclEnv | |
Fields
|
Instances
getLclEnvTcLevel :: TcLclEnv -> TcLevel Source #
setLclEnvLoc :: TcLclEnv -> RealSrcSpan -> TcLclEnv Source #
getLclEnvLoc :: TcLclEnv -> RealSrcSpan Source #
Constructors
IfLclEnv | |
Fields
|
data FrontendResult Source #
FrontendResult
describes the result of running the frontend of a Haskell
module. Currently one always gets a FrontendTypecheck
, since running the
frontend involves typechecking a program. hs-sig merges are not handled here.
This data type really should be in GHC.Driver.Env, but it needs to have a TcGblEnv which is only defined here.
Constructors
FrontendTypecheck TcGblEnv |
type RecFieldEnv = NameEnv [FieldLabel] Source #
data ImportAvails Source #
ImportAvails
summarises what was imported from where, irrespective of
whether the imported things are actually used or not. It is used:
- when processing the export list,
- when constructing usage info for the interface file,
- to identify the list of directly imported modules for initialisation purposes and for optimised overlap checking of family instances,
- when figuring out what things are really unused
Constructors
ImportAvails | |
Fields
|
plusImportAvails :: ImportAvails -> ImportAvails -> ImportAvails Source #
Union two ImportAvails
This function is a key part of Import handling, basically for each import we create a separate ImportAvails structure and then union them all together with this function.
Constructors
ImportByUser IsBootInterface | |
ImportBySystem | |
ImportByPlugin |
Instances
type TcBinderStack = [TcBinder] Source #
Constructors
TcIdBndr TcId TopLevelFlag | |
TcIdBndr_ExpType Name ExpType TopLevelFlag | |
TcTvBndr Name TyVar |
Instances
A typecheckable thing available in a local context. Could be
AGlobal
TyThing
, but also lexically scoped variables, etc.
See GHC.Tc.Utils.Env for how to retrieve a TyThing
given a Name
.
Constructors
AGlobal TyThing | |
ATcId | |
Fields
| |
ATyVar Name TcTyVar | |
ATcTyCon TyCon | |
APromotionErr PromotionErr |
Instances
data PromotionErr Source #
Constructors
TyConPE | |
ClassPE | |
FamDataConPE | |
ConstrainedDataConPE PredType | |
PatSynPE | |
RecDataConPE | |
NoDataKindsTC | |
NoDataKindsDC |
Instances
Outputable PromotionErr # | |
Defined in GHC.Tc.Types Methods ppr :: PromotionErr -> SDoc Source # |
data IdBindingInfo Source #
IdBindingInfo describes how an Id is bound.
It is used for the following purposes:
a) for static forms in checkClosedInStaticForm
and
b) to figure out when a nested binding can be generalised,
in decideGeneralisationPlan
.
Constructors
NotLetBound | |
ClosedLet | |
NonClosedLet RhsNames ClosedTypeId |
Instances
Outputable IdBindingInfo # | |
Defined in GHC.Tc.Types Methods ppr :: IdBindingInfo -> SDoc Source # |
type ClosedTypeId = Bool Source #
data IsGroupClosed Source #
IsGroupClosed describes a group of mutually-recursive bindings
Constructors
IsGroupClosed (NameEnv RhsNames) ClosedTypeId |
data SelfBootInfo Source #
Constructors
NoSelfBoot | |
SelfBoot | |
Fields
|
tcTyThingCategory :: TcTyThing -> String Source #
pprTcTyThingCategory :: TcTyThing -> SDoc Source #
peCategory :: PromotionErr -> String Source #
pprPECategory :: PromotionErr -> SDoc Source #
data CompleteMatch Source #
A list of conlikes which represents a complete pattern match.
These arise from COMPLETE
signatures.
See also Note [Implementation of COMPLETE pragmas].
Instances
Outputable CompleteMatch # | |
Defined in GHC.Types.CompleteMatch Methods ppr :: CompleteMatch -> SDoc Source # |
type CompleteMatches = [CompleteMatch] Source #
Constructors
Splice SpliceType | |
RunSplice (TcRef [ForeignRef (Q ())]) | |
Comp | |
Brack ThStage PendingStuff |
Instances
data SpliceType Source #
data PendingStuff Source #
Constructors
RnPendingUntyped (TcRef [PendingRnSplice]) | |
RnPendingTyped | |
TcPending (TcRef [PendingTcSplice]) (TcRef WantedConstraints) QuoteWrapper |
outerLevel :: ThLevel Source #
data ForeignSrcLang #
Instances
Generic ForeignSrcLang | |
Defined in GHC.ForeignSrcLang.Type Methods from :: ForeignSrcLang -> Rep ForeignSrcLang x Source # to :: Rep ForeignSrcLang x -> ForeignSrcLang Source # | |
Show ForeignSrcLang | |
Defined in GHC.ForeignSrcLang.Type | |
Eq ForeignSrcLang | |
Defined in GHC.ForeignSrcLang.Type Methods (==) :: ForeignSrcLang -> ForeignSrcLang -> Bool # (/=) :: ForeignSrcLang -> ForeignSrcLang -> Bool # | |
type Rep ForeignSrcLang | |
Defined in GHC.ForeignSrcLang.Type type Rep ForeignSrcLang = D1 ('MetaData "ForeignSrcLang" "GHC.ForeignSrcLang.Type" "ghc-boot-th-9.2.0.20210422" 'False) ((C1 ('MetaCons "LangC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LangCxx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LangObjc" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "LangObjcxx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LangAsm" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RawObject" 'PrefixI 'False) (U1 :: Type -> Type)))) |
type THDocs = Map DocLoc String Source #
The current collection of docs that Template Haskell has built up via putDoc.
This is a mirror of Template Haskell's DocLoc, but the TH names are resolved to GHC names.
Constructors
NoArrowCtxt | |
ArrowCtxt LocalRdrEnv (TcRef WantedConstraints) |
Constructors
TcIdSig TcIdSigInfo | |
TcPatSynSig TcPatSynInfo |
Instances
data TcIdSigInfo Source #
Constructors
CompleteSig | |
PartialSig | |
Fields
|
Instances
Outputable TcIdSigInfo # | |
Defined in GHC.Tc.Types Methods ppr :: TcIdSigInfo -> SDoc Source # |
data TcIdSigInst Source #
Constructors
TISI | |
Fields
|
Instances
Outputable TcIdSigInst # | |
Defined in GHC.Tc.Types Methods ppr :: TcIdSigInst -> SDoc Source # |
data TcPatSynInfo Source #
Constructors
TPSI | |
Fields |
Instances
Outputable TcPatSynInfo # | |
Defined in GHC.Tc.Types Methods ppr :: TcPatSynInfo -> SDoc Source # |
isPartialSig :: TcIdSigInst -> Bool Source #
A NameShape
is a substitution on Name
s that can be used
to refine the identities of a hole while we are renaming interfaces
(see GHC.Iface.Rename). Specifically, a NameShape
for
ns_module_name
A
, defines a mapping from {A.T}
(for some OccName
T
) to some arbitrary other Name
.
The most intruiging thing about a NameShape
, however, is
how it's constructed. A NameShape
is *implied* by the
exported AvailInfo
s of the implementor of an interface:
if an implementor of signature <H>
exports M.T
, you implicitly
define a substitution from {H.T}
to M.T
. So a NameShape
is computed from the list of AvailInfo
s that are exported
by the implementation of a module, or successively merged
together by the export lists of signatures which are joining
together.
It's not the most obvious way to go about doing this, but it does seem to work!
NB: Can't boot this and put it in NameShape because then we start pulling in too many DynFlags things.
Constructors
NameShape | |
Fields
|
removeBindingShadowing :: HasOccName a => [a] -> [a] Source #
getPlatform :: TcM Platform Source #
Get target platform
Constructors
forall s. TcPlugin | |
Fields
|
data TcPluginResult Source #
Constructors
TcPluginContradiction [Ct] | The plugin found a contradiction. The returned constraints are removed from the inert set, and recorded as insoluble. |
TcPluginOk [(EvTerm, Ct)] [Ct] | The first field is for constraints that were solved. These are removed from the inert set, and the evidence for them is recorded. The second field contains new work, that should be processed by the constraint solver. |
type TcPluginSolver = [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginResult Source #
runTcPluginM :: TcPluginM a -> EvBindsVar -> TcM a Source #
unsafeTcPluginTcM :: TcM a -> TcPluginM a Source #
getEvBindsTcPluginM :: TcPluginM EvBindsVar Source #
Access the EvBindsVar
carried by the TcPluginM
during
constraint solving. Returns Nothing
if invoked during
tcPluginInit
or tcPluginStop
.
type RoleAnnotEnv = NameEnv (LRoleAnnotDecl GhcRn) Source #
mkRoleAnnotEnv :: [LRoleAnnotDecl GhcRn] -> RoleAnnotEnv Source #
lookupRoleAnnot :: RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn) Source #
getRoleAnnots :: [Name] -> RoleAnnotEnv -> [LRoleAnnotDecl GhcRn] Source #