Safe Haskell | None |
---|---|
Language | GHC2021 |
GHC.Tc.Module
Description
Typechecking a whole module
https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/type-checker
Synopsis
- tcRnStmt :: HscEnv -> GhciLStmt GhcPs -> IO (Messages TcRnMessage, Maybe ([Id], LHsExpr GhcTc, FixityEnv))
- tcRnExpr :: HscEnv -> TcRnExprMode -> LHsExpr GhcPs -> IO (Messages TcRnMessage, Maybe Type)
- data TcRnExprMode
- tcRnType :: HscEnv -> ZonkFlexi -> Bool -> LHsType GhcPs -> IO (Messages TcRnMessage, Maybe (Type, Kind))
- tcRnImportDecls :: HscEnv -> [LImportDecl GhcPs] -> IO (Messages TcRnMessage, Maybe GlobalRdrEnv)
- tcRnLookupRdrName :: HscEnv -> LocatedN RdrName -> IO (Messages TcRnMessage, Maybe [Name])
- getModuleInterface :: HscEnv -> Module -> IO (Messages TcRnMessage, Maybe ModIface)
- tcRnDeclsi :: HscEnv -> [LHsDecl GhcPs] -> IO (Messages TcRnMessage, Maybe TcGblEnv)
- isGHCiMonad :: HscEnv -> String -> IO (Messages TcRnMessage, Maybe Name)
- runTcInteractive :: HscEnv -> TcRn a -> IO (Messages TcRnMessage, Maybe a)
- withTcPlugins :: HscEnv -> TcM a -> TcM a
- withHoleFitPlugins :: HscEnv -> TcM a -> TcM a
- tcRnLookupName :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe TyThing)
- tcRnGetInfo :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc))
- tcRnModule :: HscEnv -> ModSummary -> Bool -> HsParsedModule -> IO (Messages TcRnMessage, Maybe TcGblEnv)
- tcRnModuleTcRnM :: HscEnv -> ModSummary -> HsParsedModule -> (Module, SrcSpan) -> TcRn TcGblEnv
- tcTopSrcDecls :: HsGroup GhcRn -> TcM (TcGblEnv, TcLclEnv)
- rnTopSrcDecls :: HsGroup GhcPs -> TcM (TcGblEnv, HsGroup GhcRn)
- checkBootDecl :: HsBootOrSig -> TyThing -> TyThing -> BootErrsM BootMismatchWhat
- checkHiBootIface' :: [ClsInst] -> TypeEnv -> [AvailInfo] -> ModDetails -> TcM [(Id, Id)]
- findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [ModuleName]
- implicitRequirements :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO [ModuleName]
- checkUnit :: Unit -> TcM ()
- mergeSignatures :: HasDebugCallStack => HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv
- tcRnMergeSignatures :: HscEnv -> HsParsedModule -> TcGblEnv -> ModIface -> IO (Messages TcRnMessage, Maybe TcGblEnv)
- instantiateSignature :: TcRn TcGblEnv
- tcRnInstantiateSignature :: HscEnv -> Module -> RealSrcSpan -> IO (Messages TcRnMessage, Maybe TcGblEnv)
- loadUnqualIfaces :: HscEnv -> InteractiveContext -> TcM ()
- checkBootDeclM :: HsBootOrSig -> TyThing -> TyThing -> TcM ()
- getRenamedStuff :: TcGblEnv -> RenamedStuff
- type RenamedStuff = Maybe (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], Maybe (LHsDoc GhcRn), Maybe (XRec GhcRn ModuleName))
Documentation
tcRnStmt :: HscEnv -> GhciLStmt GhcPs -> IO (Messages TcRnMessage, Maybe ([Id], LHsExpr GhcTc, FixityEnv)) Source #
The returned [Id] is the list of new Ids bound by this statement. It can be used to extend the InteractiveContext via extendInteractiveContext.
The returned TypecheckedHsExpr is of type IO [ Any ], a list of the bound values, coerced to Any.
tcRnExpr :: HscEnv -> TcRnExprMode -> LHsExpr GhcPs -> IO (Messages TcRnMessage, Maybe Type) Source #
tcRnExpr just finds the type of an expression for :type
data TcRnExprMode Source #
How should we infer a type? See Note [TcRnExprMode]
Constructors
TM_Inst | Instantiate inferred quantifiers only (:type) |
TM_Default | Instantiate all quantifiers, and do eager defaulting (:type +d) |
tcRnType :: HscEnv -> ZonkFlexi -> Bool -> LHsType GhcPs -> IO (Messages TcRnMessage, Maybe (Type, Kind)) Source #
tcRnImportDecls :: HscEnv -> [LImportDecl GhcPs] -> IO (Messages TcRnMessage, Maybe GlobalRdrEnv) Source #
tcRnLookupRdrName :: HscEnv -> LocatedN RdrName -> IO (Messages TcRnMessage, Maybe [Name]) Source #
Find all the Names that this RdrName could mean, in GHCi
getModuleInterface :: HscEnv -> Module -> IO (Messages TcRnMessage, Maybe ModIface) Source #
ASSUMES that the module is either in the HomePackageTable
or is a package module with an interface on disk. If neither of these is true, then the result will be an error indicating the interface could not be found.
isGHCiMonad :: HscEnv -> String -> IO (Messages TcRnMessage, Maybe Name) Source #
runTcInteractive :: HscEnv -> TcRn a -> IO (Messages TcRnMessage, Maybe a) Source #
tcRnLookupName :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe TyThing) Source #
tcRnGetInfo :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) Source #
tcRnModule :: HscEnv -> ModSummary -> Bool -> HsParsedModule -> IO (Messages TcRnMessage, Maybe TcGblEnv) Source #
Top level entry point for typechecker and renamer
tcRnModuleTcRnM :: HscEnv -> ModSummary -> HsParsedModule -> (Module, SrcSpan) -> TcRn TcGblEnv Source #
checkBootDecl :: HsBootOrSig -> TyThing -> TyThing -> BootErrsM BootMismatchWhat Source #
Compares the two things for equivalence between boot-file and normal code. Returns Nothing
on success or Just "some helpful info for user"
failure. If the difference will be apparent to the user, Just empty
is perfectly suitable.
checkHiBootIface' :: [ClsInst] -> TypeEnv -> [AvailInfo] -> ModDetails -> TcM [(Id, Id)] Source #
findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [ModuleName] Source #
For a module modname
of type HscSource
, determine the list of extra "imports" of other requirements which should be considered part of the import of the requirement, because it transitively depends on those requirements by imports of modules from other packages. The situation is something like this:
unit p where signature X signature Y import X
unit q where dependency p[X=<A>,Y=<B>] signature A signature B
Although q's B does not directly import A, we still have to make sure we process A first, because the merging process will cause B to indirectly import A. This function finds the TRANSITIVE closure of all such imports we need to make.
implicitRequirements :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO [ModuleName] Source #
checkUnit :: Unit -> TcM () Source #
Given a Unit
, make sure it is well typed. This is because unit IDs come from Cabal, which does not know if things are well-typed or not; a component may have been filled with implementations for the holes that don't actually fulfill the requirements.
mergeSignatures :: HasDebugCallStack => HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv Source #
Given a local ModIface
, merge all inherited requirements from requirementMerges
into this signature, producing a final TcGblEnv
that matches the local signature and all required signatures.
tcRnMergeSignatures :: HscEnv -> HsParsedModule -> TcGblEnv -> ModIface -> IO (Messages TcRnMessage, Maybe TcGblEnv) Source #
Top-level driver for signature merging (run after typechecking an hsig
file).
tcRnInstantiateSignature :: HscEnv -> Module -> RealSrcSpan -> IO (Messages TcRnMessage, Maybe TcGblEnv) Source #
Top-level driver for signature instantiation (run when compiling an hsig
file.)
loadUnqualIfaces :: HscEnv -> InteractiveContext -> TcM () Source #
Arguments
:: HsBootOrSig | |
-> TyThing | boot thing |
-> TyThing | real thing |
-> TcM () |
Compares two things for equivalence between boot-file and normal code, reporting an error if they don't match up.
getRenamedStuff :: TcGblEnv -> RenamedStuff Source #
Extract the renamed information from TcGblEnv.