Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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 :: KnotVars (IORef 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_th_needed_deps :: TcRef ([Linkable], PkgsLoaded)
- 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 GhcRn
- 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 (LHsDoc GhcRn)
- tcg_hpc :: !AnyHpcUsage
- tcg_self_boot :: SelfBootInfo
- tcg_main :: Maybe Name
- tcg_safe_infer :: TcRef Bool
- tcg_safe_infer_reasons :: TcRef (Messages TcRnMessage)
- tcg_tc_plugin_solvers :: [TcPluginSolver]
- tcg_tc_plugin_rewriters :: UniqFM TyCon [TcPluginRewriter]
- tcg_defaulting_plugins :: [FillDefaulting]
- tcg_hf_plugins :: [HoleFitPlugin]
- tcg_top_loc :: RealSrcSpan
- tcg_static_wc :: TcRef WantedConstraints
- tcg_complete_matches :: !CompleteMatches
- tcg_cc_st :: TcRef CostCentreState
- tcg_next_wrapper_num :: TcRef (ModuleEnv Int)
- 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 TcRnMessage)
- setLclEnvTcLevel :: TcLclEnv -> TcLevel -> TcLclEnv
- getLclEnvTcLevel :: TcLclEnv -> TcLevel
- setLclEnvLoc :: TcLclEnv -> RealSrcSpan -> TcLclEnv
- getLclEnvLoc :: TcLclEnv -> RealSrcSpan
- lclEnvInGeneratedCode :: TcLclEnv -> Bool
- data IfGblEnv = IfGblEnv {}
- data IfLclEnv = IfLclEnv {}
- tcVisibleOrphanMods :: TcGblEnv -> ModuleSet
- data RewriteEnv = RE {
- re_loc :: !CtLoc
- re_flavour :: !CtFlavour
- re_eq_rel :: !EqRel
- re_rewriters :: !(TcRef RewriterSet)
- 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 :: Set (UnitId, ModuleNameWithIsBoot) -> InstalledModuleEnv 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
- tcTyThingTyCon_maybe :: TcTyThing -> Maybe TyCon
- 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
- bootExports :: SelfBootInfo -> 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 (HsDoc GhcRn)
- data DocLoc
- type ThBindEnv = NameEnv (TopLevelFlag, ThLevel)
- 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 :: TcRnIf a b Platform
- data TcPlugin = forall s.TcPlugin {
- tcPluginInit :: TcPluginM s
- tcPluginSolve :: s -> TcPluginSolver
- tcPluginRewrite :: s -> UniqFM TyCon TcPluginRewriter
- tcPluginStop :: s -> TcPluginM ()
- data TcPluginSolveResult where
- TcPluginSolveResult {
- tcPluginInsolubleCts :: [Ct]
- tcPluginSolvedCts :: [(EvTerm, Ct)]
- tcPluginNewCts :: [Ct]
- pattern TcPluginContradiction :: [Ct] -> TcPluginSolveResult
- pattern TcPluginOk :: [(EvTerm, Ct)] -> [Ct] -> TcPluginSolveResult
- TcPluginSolveResult {
- data TcPluginRewriteResult
- type TcPluginSolver = EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult
- type TcPluginRewriter = RewriteEnv -> [Ct] -> [TcType] -> TcPluginM TcPluginRewriteResult
- data TcPluginM a
- unsafeTcPluginTcM :: TcM a -> TcPluginM a
- data DefaultingPlugin = forall s.DefaultingPlugin {
- dePluginInit :: TcPluginM s
- dePluginRun :: s -> FillDefaulting
- dePluginStop :: s -> TcPluginM ()
- data DefaultingProposal = DefaultingProposal {
- deProposalTyVar :: TcTyVar
- deProposalCandidates :: [Type]
- deProposalCts :: [Ct]
- type FillDefaulting = WantedConstraints -> TcPluginM [DefaultingProposal]
- type DefaultingPluginResult = [DefaultingProposal]
- 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 ()
- data TcRnMessage
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
).
TcGblEnv | |
|
Instances
TcLclEnv | |
|
Instances
getLclEnvTcLevel :: TcLclEnv -> TcLevel Source #
setLclEnvLoc :: TcLclEnv -> RealSrcSpan -> TcLclEnv Source #
getLclEnvLoc :: TcLclEnv -> RealSrcSpan Source #
lclEnvInGeneratedCode :: TcLclEnv -> Bool Source #
IfLclEnv | |
|
data RewriteEnv Source #
A RewriteEnv
carries the necessary context for performing rewrites
(i.e. type family reductions and following filled-in metavariables)
in the solver.
RE | |
|
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.
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
ImportAvails | |
|
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.
Instances
type TcBinderStack = [TcBinder] Source #
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
.
AGlobal TyThing | |
ATcId | |
| |
ATyVar Name TcTyVar | |
ATcTyCon TyCon | |
APromotionErr PromotionErr |
Instances
data PromotionErr Source #
TyConPE | |
ClassPE | |
FamDataConPE | |
ConstrainedDataConPE PredType | |
PatSynPE | |
RecDataConPE | |
TermVariablePE | |
NoDataKindsDC |
Instances
Outputable PromotionErr Source # | |
Defined in GHC.Tc.Errors.Types 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
.
Instances
Outputable IdBindingInfo Source # | |
Defined in GHC.Tc.Types ppr :: IdBindingInfo -> SDoc Source # |
type ClosedTypeId = Bool Source #
data IsGroupClosed Source #
IsGroupClosed describes a group of mutually-recursive bindings
data SelfBootInfo Source #
bootExports :: SelfBootInfo -> NameSet Source #
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 Source # | |
Defined in GHC.Types.CompleteMatch ppr :: CompleteMatch -> SDoc Source # |
type CompleteMatches = [CompleteMatch] Source #
Splice SpliceType | |
RunSplice (TcRef [ForeignRef (Q ())]) | |
Comp | |
Brack ThStage PendingStuff |
Instances
data SpliceType Source #
data PendingStuff Source #
outerLevel :: ThLevel Source #
data ForeignSrcLang #
Instances
type THDocs = Map DocLoc (HsDoc GhcRn) 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.
Instances
data TcIdSigInfo Source #
CompleteSig | |
PartialSig | |
|
Instances
Outputable TcIdSigInfo Source # | |
Defined in GHC.Tc.Types ppr :: TcIdSigInfo -> SDoc Source # |
data TcIdSigInst Source #
TISI | |
|
Instances
Outputable TcIdSigInst Source # | |
Defined in GHC.Tc.Types ppr :: TcIdSigInst -> SDoc Source # |
data TcPatSynInfo Source #
Instances
Outputable TcPatSynInfo Source # | |
Defined in GHC.Tc.Types 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 intriguing 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.
NameShape | |
|
removeBindingShadowing :: HasOccName a => [a] -> [a] Source #
getPlatform :: TcRnIf a b Platform Source #
Get target platform
forall s. TcPlugin | |
|
data TcPluginSolveResult Source #
Result of running a solver plugin.
TcPluginSolveResult | |
|
pattern TcPluginContradiction :: [Ct] -> TcPluginSolveResult | The plugin found a contradiction. The returned constraints are removed from the inert set, and recorded as insoluble. The returned list of constraints should never be empty. |
pattern TcPluginOk :: [(EvTerm, Ct)] -> [Ct] -> TcPluginSolveResult | The plugin has not found any contradictions, The first field is for constraints that were solved. The second field contains new work, that should be processed by the constraint solver. |
data TcPluginRewriteResult Source #
TcPluginNoRewrite | The plugin does not rewrite the type family application. |
TcPluginRewriteTo | The plugin rewrites the type family application
providing a rewriting together with evidence: a The plugin can also emit additional Wanted constraints. |
|
type TcPluginSolver Source #
= EvBindsVar | |
-> [Ct] | Givens |
-> [Ct] | Wanteds |
-> TcPluginM TcPluginSolveResult |
The solve
function of a type-checking plugin takes in Given
and Wanted constraints, and should return a TcPluginSolveResult
indicating which Wanted constraints it could solve, or whether any are
insoluble.
type TcPluginRewriter Source #
= RewriteEnv | Rewriter environment |
-> [Ct] | Givens |
-> [TcType] | type family arguments |
-> TcPluginM TcPluginRewriteResult |
For rewriting type family applications, a type-checking plugin provides
a function of this type for each type family TyCon
.
The function is provided with the current set of Given constraints, together with the arguments to the type family. The type family application will always be fully saturated.
TcPluginM
is the monad in which type-checking plugins operate.
unsafeTcPluginTcM :: TcM a -> TcPluginM a Source #
data DefaultingPlugin Source #
A plugin for controlling defaulting.
forall s. DefaultingPlugin | |
|
data DefaultingProposal Source #
A collection of candidate default types for a type variable.
DefaultingProposal | |
|
Instances
Outputable DefaultingProposal Source # | |
Defined in GHC.Tc.Types ppr :: DefaultingProposal -> SDoc Source # |
type FillDefaulting = WantedConstraints -> TcPluginM [DefaultingProposal] Source #
type DefaultingPluginResult = [DefaultingProposal] Source #
type RoleAnnotEnv = NameEnv (LRoleAnnotDecl GhcRn) Source #
mkRoleAnnotEnv :: [LRoleAnnotDecl GhcRn] -> RoleAnnotEnv Source #
lookupRoleAnnot :: RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn) Source #
getRoleAnnots :: [Name] -> RoleAnnotEnv -> [LRoleAnnotDecl GhcRn] Source #
lintGblEnv :: Logger -> DynFlags -> TcGblEnv -> TcM () Source #
Check the TcGblEnv
for consistency. Currently, only checks
axioms, but should check other aspects, too.
data TcRnMessage Source #
An error which might arise during typechecking/renaming.