HscTypes

ghc-8.10.1: The GHC API

Safe Haskell | None
Language | Haskell2010

HscTypes

Contents

- compilation state
- ModuleGraph
- Hsc monad
- Information about modules
- Information about the module being compiled
- State relating to modules in this package
- State relating to known packages
- Metaprogramming
- Annotations
- Interactive context
- Interfaces
- Fixity
- TyThings and type environments
- MonadThings
- Information on imports and exports
- Warnings
- Linker stuff
- Program coverage
- Breakpoints
- Safe Haskell information
- result of the parser
- Compilation errors and warnings
- COMPLETE signature

Description

Types for the per-module compiler

Synopsis

- data HscEnv = HscEnv {
  - hsc_dflags :: DynFlags
  - hsc_targets :: [Target]
  - hsc_mod_graph :: ModuleGraph
  - hsc_IC :: InteractiveContext
  - hsc_HPT :: HomePackageTable
  - hsc_EPS :: !(IORef ExternalPackageState)
  - hsc_NC :: !(IORef NameCache)
  - hsc_FC :: !(IORef FinderCache)
  - hsc_type_env_var :: Maybe (Module, IORef TypeEnv)
  - hsc_iserv :: MVar (Maybe IServ)
  - hsc_dynLinker :: DynLinker
  }
- hscEPS :: HscEnv -> IO ExternalPackageState
- type FinderCache = InstalledModuleEnv InstalledFindResult
- data FindResult
  - = Found ModLocation Module
  - | NoPackage UnitId
  - | FoundMultiple [(Module, ModuleOrigin)]
  - | NotFound {
    - fr_paths :: [FilePath]
    - fr_pkg :: Maybe UnitId
    - fr_mods_hidden :: [UnitId]
    - fr_pkgs_hidden :: [UnitId]
    - fr_unusables :: [(UnitId, UnusablePackageReason)]
    - fr_suggestions :: [ModuleSuggestion]
    }
- data InstalledFindResult
  - = InstalledFound ModLocation InstalledModule
  - | InstalledNoPackage InstalledUnitId
  - | InstalledNotFound [FilePath] (Maybe InstalledUnitId)
- data Target = Target {
  - targetId :: TargetId
  - targetAllowObjCode :: Bool
  - targetContents :: Maybe (InputFileBuffer, UTCTime)
  }
- data TargetId
  - = TargetModule ModuleName
  - | TargetFile FilePath (Maybe Phase)
- type InputFileBuffer = StringBuffer
- pprTarget :: Target -> SDoc
- pprTargetId :: TargetId -> SDoc
- data HscStatus
  - = HscNotGeneratingCode ModIface
  - | HscUpToDate ModIface
  - | HscUpdateBoot ModIface
  - | HscUpdateSig ModIface
  - | HscRecomp {
    - hscs_guts :: CgGuts
    - hscs_mod_location :: !ModLocation
    - hscs_partial_iface :: !PartialModIface
    - hscs_old_iface_hash :: !(Maybe Fingerprint)
    - hscs_iface_dflags :: !DynFlags
    }
- data IServ = IServ {
  - iservPipe :: Pipe
  - iservProcess :: ProcessHandle
  - iservLookupSymbolCache :: IORef (UniqFM (Ptr ()))
  - iservPendingFrees :: [HValueRef]
  }
- data ModuleGraph
- emptyMG :: ModuleGraph
- mkModuleGraph :: [ModSummary] -> ModuleGraph
- extendMG :: ModuleGraph -> ModSummary -> ModuleGraph
- mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
- mgModSummaries :: ModuleGraph -> [ModSummary]
- mgElemModule :: ModuleGraph -> Module -> Bool
- mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary
- needsTemplateHaskellOrQQ :: ModuleGraph -> Bool
- mgBootModules :: ModuleGraph -> ModuleSet
- newtype Hsc a = Hsc (HscEnv -> WarningMessages -> IO (a, WarningMessages))
- runHsc :: HscEnv -> Hsc a -> IO a
- mkInteractiveHscEnv :: HscEnv -> HscEnv
- runInteractiveHsc :: HscEnv -> Hsc a -> IO a
- data ModDetails = ModDetails {
  - md_exports :: [AvailInfo]
  - md_types :: !TypeEnv
  - md_insts :: ![ClsInst]
  - md_fam_insts :: ![FamInst]
  - md_rules :: ![CoreRule]
  - md_anns :: ![Annotation]
  - md_complete_sigs :: [CompleteMatch]
  }
- emptyModDetails :: ModDetails
- data ModGuts = ModGuts {
  - mg_module :: !Module
  - mg_hsc_src :: HscSource
  - mg_loc :: SrcSpan
  - mg_exports :: ![AvailInfo]
  - mg_deps :: !Dependencies
  - mg_usages :: ![Usage]
  - mg_used_th :: !Bool
  - mg_rdr_env :: !GlobalRdrEnv
  - mg_fix_env :: !FixityEnv
  - mg_tcs :: ![TyCon]
  - mg_insts :: ![ClsInst]
  - mg_fam_insts :: ![FamInst]
  - mg_patsyns :: ![PatSyn]
  - mg_rules :: ![CoreRule]
  - mg_binds :: !CoreProgram
  - mg_foreign :: !ForeignStubs
  - mg_foreign_files :: ![(ForeignSrcLang, FilePath)]
  - mg_warns :: !Warnings
  - mg_anns :: [Annotation]
  - mg_complete_sigs :: [CompleteMatch]
  - mg_hpc_info :: !HpcInfo
  - mg_modBreaks :: !(Maybe ModBreaks)
  - mg_inst_env :: InstEnv
  - mg_fam_inst_env :: FamInstEnv
  - mg_safe_haskell :: SafeHaskellMode
  - mg_trust_pkg :: Bool
  - mg_doc_hdr :: !(Maybe HsDocString)
  - mg_decl_docs :: !DeclDocMap
  - mg_arg_docs :: !ArgDocMap
  }
- data CgGuts = CgGuts {
  - cg_module :: !Module
  - cg_tycons :: [TyCon]
  - cg_binds :: CoreProgram
  - cg_foreign :: !ForeignStubs
  - cg_foreign_files :: ![(ForeignSrcLang, FilePath)]
  - cg_dep_pkgs :: ![InstalledUnitId]
  - cg_hpc_info :: !HpcInfo
  - cg_modBreaks :: !(Maybe ModBreaks)
  - cg_spt_entries :: [SptEntry]
  }
- data ForeignStubs
  - = NoStubs
  - | ForeignStubs SDoc SDoc
- appendStubC :: ForeignStubs -> SDoc -> ForeignStubs
- type ImportedMods = ModuleEnv [ImportedBy]
- data ImportedBy
  - = ImportedByUser ImportedModsVal
  - | ImportedBySystem
- importedByUser :: [ImportedBy] -> [ImportedModsVal]
- data ImportedModsVal = ImportedModsVal {
  - imv_name :: ModuleName
  - imv_span :: SrcSpan
  - imv_is_safe :: IsSafeImport
  - imv_is_hiding :: Bool
  - imv_all_exports :: !GlobalRdrEnv
  - imv_qualified :: Bool
  }
- data SptEntry = SptEntry Id Fingerprint
- data ForeignSrcLang
  - = LangC
  - | LangCxx
  - | LangObjc
  - | LangObjcxx
  - | LangAsm
  - | RawObject
- phaseForeignLanguage :: Phase -> Maybe ForeignSrcLang
- data ModSummary = ModSummary {
  - ms_mod :: Module
  - ms_hsc_src :: HscSource
  - ms_location :: ModLocation
  - ms_hs_date :: UTCTime
  - ms_obj_date :: Maybe UTCTime
  - ms_iface_date :: Maybe UTCTime
  - ms_hie_date :: Maybe UTCTime
  - ms_srcimps :: [(Maybe FastString, Located ModuleName)]
  - ms_textual_imps :: [(Maybe FastString, Located ModuleName)]
  - ms_parsed_mod :: Maybe HsParsedModule
  - ms_hspp_file :: FilePath
  - ms_hspp_opts :: DynFlags
  - ms_hspp_buf :: Maybe StringBuffer
  }
- ms_imps :: ModSummary -> [(Maybe FastString, Located ModuleName)]
- ms_installed_mod :: ModSummary -> InstalledModule
- ms_mod_name :: ModSummary -> ModuleName
- ms_home_imps :: ModSummary -> [Located ModuleName]
- home_imps :: [(Maybe FastString, Located ModuleName)] -> [Located ModuleName]
- ms_home_allimps :: ModSummary -> [ModuleName]
- ms_home_srcimps :: ModSummary -> [Located ModuleName]
- showModMsg :: DynFlags -> HscTarget -> Bool -> ModSummary -> String
- isBootSummary :: ModSummary -> Bool
- msHsFilePath :: ModSummary -> FilePath
- msHiFilePath :: ModSummary -> FilePath
- msObjFilePath :: ModSummary -> FilePath
- data SourceModified
  - = SourceModified
  - | SourceUnmodified
  - | SourceUnmodifiedAndStable
- isTemplateHaskellOrQQNonBoot :: ModSummary -> Bool
- data HscSource
  - = HsSrcFile
  - | HsBootFile
  - | HsigFile
- isHsBootOrSig :: HscSource -> Bool
- isHsigFile :: HscSource -> Bool
- hscSourceString :: HscSource -> String
- type HomePackageTable = DModuleNameEnv HomeModInfo
- data HomeModInfo = HomeModInfo {
  - hm_iface :: !ModIface
  - hm_details :: !ModDetails
  - hm_linkable :: !(Maybe Linkable)
  }
- emptyHomePackageTable :: HomePackageTable
- lookupHpt :: HomePackageTable -> ModuleName -> Maybe HomeModInfo
- eltsHpt :: HomePackageTable -> [HomeModInfo]
- filterHpt :: (HomeModInfo -> Bool) -> HomePackageTable -> HomePackageTable
- allHpt :: (HomeModInfo -> Bool) -> HomePackageTable -> Bool
- mapHpt :: (HomeModInfo -> HomeModInfo) -> HomePackageTable -> HomePackageTable
- delFromHpt :: HomePackageTable -> ModuleName -> HomePackageTable
- addToHpt :: HomePackageTable -> ModuleName -> HomeModInfo -> HomePackageTable
- addListToHpt :: HomePackageTable -> [(ModuleName, HomeModInfo)] -> HomePackageTable
- lookupHptDirectly :: HomePackageTable -> Unique -> Maybe HomeModInfo
- listToHpt :: [(ModuleName, HomeModInfo)] -> HomePackageTable
- hptCompleteSigs :: HscEnv -> [CompleteMatch]
- hptInstances :: HscEnv -> (ModuleName -> Bool) -> ([ClsInst], [FamInst])
- hptRules :: HscEnv -> [(ModuleName, IsBootInterface)] -> [CoreRule]
- pprHPT :: HomePackageTable -> SDoc
- data ExternalPackageState = EPS {
  - eps_is_boot :: !(ModuleNameEnv (ModuleName, IsBootInterface))
  - eps_PIT :: !PackageIfaceTable
  - eps_free_holes :: InstalledModuleEnv (UniqDSet ModuleName)
  - eps_PTE :: !PackageTypeEnv
  - eps_inst_env :: !PackageInstEnv
  - eps_fam_inst_env :: !PackageFamInstEnv
  - eps_rule_base :: !PackageRuleBase
  - eps_ann_env :: !PackageAnnEnv
  - eps_complete_matches :: !PackageCompleteMatchMap
  - eps_mod_fam_inst_env :: !(ModuleEnv FamInstEnv)
  - eps_stats :: !EpsStats
  }
- data EpsStats = EpsStats {
  - n_ifaces_in, n_decls_in, n_decls_out, n_rules_in, n_rules_out, n_insts_in, n_insts_out :: !Int
  }
- addEpsInStats :: EpsStats -> Int -> Int -> Int -> EpsStats
- type PackageTypeEnv = TypeEnv
- type PackageIfaceTable = ModuleEnv ModIface
- emptyPackageIfaceTable :: PackageIfaceTable
- lookupIfaceByModule :: HomePackageTable -> PackageIfaceTable -> Module -> Maybe ModIface
- emptyPartialModIface :: Module -> PartialModIface
- emptyFullModIface :: Module -> ModIface
- lookupHptByModule :: HomePackageTable -> Module -> Maybe HomeModInfo
- type PackageInstEnv = InstEnv
- type PackageFamInstEnv = FamInstEnv
- type PackageRuleBase = RuleBase
- type PackageCompleteMatchMap = CompleteMatchMap
- mkSOName :: Platform -> FilePath -> FilePath
- mkHsSOName :: Platform -> FilePath -> FilePath
- soExt :: Platform -> FilePath
- data MetaRequest
  - = MetaE (LHsExpr GhcPs -> MetaResult)
  - | MetaP (LPat GhcPs -> MetaResult)
  - | MetaT (LHsType GhcPs -> MetaResult)
  - | MetaD ([LHsDecl GhcPs] -> MetaResult)
  - | MetaAW (Serialized -> MetaResult)
- data MetaResult
- metaRequestE :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LHsExpr GhcPs)
- metaRequestP :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LPat GhcPs)
- metaRequestT :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LHsType GhcPs)
- metaRequestD :: Functor f => MetaHook f -> LHsExpr GhcTc -> f [LHsDecl GhcPs]
- metaRequestAW :: Functor f => MetaHook f -> LHsExpr GhcTc -> f Serialized
- type MetaHook f = MetaRequest -> LHsExpr GhcTc -> f MetaResult
- prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv
- data InteractiveContext = InteractiveContext {
  - ic_dflags :: DynFlags
  - ic_mod_index :: Int
  - ic_imports :: [InteractiveImport]
  - ic_tythings :: [TyThing]
  - ic_rn_gbl_env :: GlobalRdrEnv
  - ic_instances :: ([ClsInst], [FamInst])
  - ic_fix_env :: FixityEnv
  - ic_default :: Maybe [Type]
  - ic_resume :: [Resume]
  - ic_monad :: Name
  - ic_int_print :: Name
  - ic_cwd :: Maybe FilePath
  }
- emptyInteractiveContext :: DynFlags -> InteractiveContext
- icPrintUnqual :: DynFlags -> InteractiveContext -> PrintUnqualified
- icInScopeTTs :: InteractiveContext -> [TyThing]
- icExtendGblRdrEnv :: GlobalRdrEnv -> [TyThing] -> GlobalRdrEnv
- extendInteractiveContext :: InteractiveContext -> [TyThing] -> [ClsInst] -> [FamInst] -> Maybe [Type] -> FixityEnv -> InteractiveContext
- extendInteractiveContextWithIds :: InteractiveContext -> [Id] -> InteractiveContext
- substInteractiveContext :: InteractiveContext -> TCvSubst -> InteractiveContext
- setInteractivePrintName :: InteractiveContext -> Name -> InteractiveContext
- icInteractiveModule :: InteractiveContext -> Module
- data InteractiveImport
  - = IIDecl (ImportDecl GhcPs)
  - | IIModule ModuleName
- setInteractivePackage :: HscEnv -> HscEnv
- mkPrintUnqualified :: DynFlags -> GlobalRdrEnv -> PrintUnqualified
- pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc
- mkQualPackage :: DynFlags -> QueryQualifyPackage
- mkQualModule :: DynFlags -> QueryQualifyModule
- pkgQual :: DynFlags -> PrintUnqualified
- type ModIface = ModIface_ 'ModIfaceFinal
- type PartialModIface = ModIface_ 'ModIfaceCore
- data ModIface_ (phase :: ModIfacePhase) = ModIface {
  - mi_module :: !Module
  - mi_sig_of :: !(Maybe Module)
  - mi_hsc_src :: !HscSource
  - mi_deps :: Dependencies
  - mi_usages :: [Usage]
  - mi_exports :: ![IfaceExport]
  - mi_used_th :: !Bool
  - mi_fixities :: [(OccName, Fixity)]
  - mi_warns :: Warnings
  - mi_anns :: [IfaceAnnotation]
  - mi_decls :: [IfaceDeclExts phase]
  - mi_globals :: !(Maybe GlobalRdrEnv)
  - mi_insts :: [IfaceClsInst]
  - mi_fam_insts :: [IfaceFamInst]
  - mi_rules :: [IfaceRule]
  - mi_hpc :: !AnyHpcUsage
  - mi_trust :: !IfaceTrustInfo
  - mi_trust_pkg :: !Bool
  - mi_complete_sigs :: [IfaceCompleteMatch]
  - mi_doc_hdr :: Maybe HsDocString
  - mi_decl_docs :: DeclDocMap
  - mi_arg_docs :: ArgDocMap
  - mi_final_exts :: !(IfaceBackendExts phase)
  }
- data ModIfaceBackend = ModIfaceBackend {
  - mi_iface_hash :: !Fingerprint
  - mi_mod_hash :: !Fingerprint
  - mi_flag_hash :: !Fingerprint
  - mi_opt_hash :: !Fingerprint
  - mi_hpc_hash :: !Fingerprint
  - mi_plugin_hash :: !Fingerprint
  - mi_orphan :: !WhetherHasOrphans
  - mi_finsts :: !WhetherHasFamInst
  - mi_exp_hash :: !Fingerprint
  - mi_orphan_hash :: !Fingerprint
  - mi_warn_fn :: !(OccName -> Maybe WarningTxt)
  - mi_fix_fn :: !(OccName -> Maybe Fixity)
  - mi_hash_fn :: !(OccName -> Maybe (OccName, Fingerprint))
  }
- mkIfaceWarnCache :: Warnings -> OccName -> Maybe WarningTxt
- mkIfaceHashCache :: [(Fingerprint, IfaceDecl)] -> OccName -> Maybe (OccName, Fingerprint)
- mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Maybe Fixity
- emptyIfaceWarnCache :: OccName -> Maybe WarningTxt
- mi_boot :: ModIface -> Bool
- mi_fix :: ModIface -> OccName -> Fixity
- mi_semantic_module :: ModIface_ a -> Module
- mi_free_holes :: ModIface -> UniqDSet ModuleName
- renameFreeHoles :: UniqDSet ModuleName -> [(ModuleName, Module)] -> UniqDSet ModuleName
- type FixityEnv = NameEnv FixItem
- data FixItem = FixItem OccName Fixity
- lookupFixity :: FixityEnv -> Name -> Fixity
- emptyFixityEnv :: FixityEnv
- data TyThing
  - = AnId Id
  - | AConLike ConLike
  - | ATyCon TyCon
  - | ACoAxiom (CoAxiom Branched)
- tyThingAvailInfo :: TyThing -> [AvailInfo]
- tyThingTyCon :: TyThing -> TyCon
- tyThingDataCon :: TyThing -> DataCon
- tyThingConLike :: TyThing -> ConLike
- tyThingId :: TyThing -> Id
- tyThingCoAxiom :: TyThing -> CoAxiom Branched
- tyThingParent_maybe :: TyThing -> Maybe TyThing
- tyThingsTyCoVars :: [TyThing] -> TyCoVarSet
- implicitTyThings :: TyThing -> [TyThing]
- implicitTyConThings :: TyCon -> [TyThing]
- implicitClassThings :: Class -> [TyThing]
- isImplicitTyThing :: TyThing -> Bool
- type TypeEnv = NameEnv TyThing
- lookupType :: DynFlags -> HomePackageTable -> PackageTypeEnv -> Name -> Maybe TyThing
- lookupTypeHscEnv :: HscEnv -> Name -> IO (Maybe TyThing)
- mkTypeEnv :: [TyThing] -> TypeEnv
- emptyTypeEnv :: TypeEnv
- typeEnvFromEntities :: [Id] -> [TyCon] -> [FamInst] -> TypeEnv
- mkTypeEnvWithImplicits :: [TyThing] -> TypeEnv
- extendTypeEnv :: TypeEnv -> TyThing -> TypeEnv
- extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv
- extendTypeEnvWithIds :: TypeEnv -> [Id] -> TypeEnv
- plusTypeEnv :: TypeEnv -> TypeEnv -> TypeEnv
- lookupTypeEnv :: TypeEnv -> Name -> Maybe TyThing
- typeEnvElts :: TypeEnv -> [TyThing]
- typeEnvTyCons :: TypeEnv -> [TyCon]
- typeEnvIds :: TypeEnv -> [Id]
- typeEnvPatSyns :: TypeEnv -> [PatSyn]
- typeEnvDataCons :: TypeEnv -> [DataCon]
- typeEnvCoAxioms :: TypeEnv -> [CoAxiom Branched]
- typeEnvClasses :: TypeEnv -> [Class]
- class Monad m => MonadThings m where
  - lookupThing :: Name -> m TyThing
  - lookupId :: Name -> m Id
  - lookupDataCon :: Name -> m DataCon
  - lookupTyCon :: Name -> m TyCon
- type WhetherHasOrphans = Bool
- type IsBootInterface = Bool
- data Usage
  - = UsagePackageModule {
    - usg_mod :: Module
    - usg_mod_hash :: Fingerprint
    - usg_safe :: IsSafeImport
    }
  - | UsageHomeModule {
    - usg_mod_name :: ModuleName
    - usg_mod_hash :: Fingerprint
    - usg_entities :: [(OccName, Fingerprint)]
    - usg_exports :: Maybe Fingerprint
    - usg_safe :: IsSafeImport
    }
  - | UsageFile {
    - usg_file_path :: FilePath
    - usg_file_hash :: Fingerprint
    }
  - | UsageMergedRequirement {
    - usg_mod :: Module
    - usg_mod_hash :: Fingerprint
    }
- data Dependencies = Deps {
  - dep_mods :: [(ModuleName, IsBootInterface)]
  - dep_pkgs :: [(InstalledUnitId, Bool)]
  - dep_orphs :: [Module]
  - dep_finsts :: [Module]
  - dep_plgins :: [ModuleName]
  }
- noDependencies :: Dependencies
- updNameCache :: IORef NameCache -> (NameCache -> (NameCache, c)) -> IO c
- type IfaceExport = AvailInfo
- data Warnings
  - = NoWarnings
  - | WarnAll WarningTxt
  - | WarnSome [(OccName, WarningTxt)]
- data WarningTxt
  - = WarningTxt (Located SourceText) [Located StringLiteral]
  - | DeprecatedTxt (Located SourceText) [Located StringLiteral]
- plusWarns :: Warnings -> Warnings -> Warnings
- data Linkable = LM {
  - linkableTime :: UTCTime
  - linkableModule :: Module
  - linkableUnlinked :: [Unlinked]
  }
- isObjectLinkable :: Linkable -> Bool
- linkableObjs :: Linkable -> [FilePath]
- data Unlinked
  - = DotO FilePath
  - | DotA FilePath
  - | DotDLL FilePath
  - | BCOs CompiledByteCode [SptEntry]
- data CompiledByteCode
- isObject :: Unlinked -> Bool
- nameOfObject :: Unlinked -> FilePath
- isInterpretable :: Unlinked -> Bool
- byteCodeOfObject :: Unlinked -> CompiledByteCode
- data HpcInfo
  - = HpcInfo {
    - hpcInfoTickCount :: Int
    - hpcInfoHash :: Int
    }
  - | NoHpcInfo {
    - hpcUsed :: AnyHpcUsage
    }
- emptyHpcInfo :: AnyHpcUsage -> HpcInfo
- isHpcUsed :: HpcInfo -> AnyHpcUsage
- type AnyHpcUsage = Bool
- data ModBreaks = ModBreaks {
  - modBreaks_flags :: ForeignRef BreakArray
  - modBreaks_locs :: !(Array BreakIndex SrcSpan)
  - modBreaks_vars :: !(Array BreakIndex [OccName])
  - modBreaks_decls :: !(Array BreakIndex [String])
  - modBreaks_ccs :: !(Array BreakIndex (RemotePtr CostCentre))
  - modBreaks_breakInfo :: IntMap CgBreakInfo
  }
- emptyModBreaks :: ModBreaks
- data IfaceTrustInfo
- getSafeMode :: IfaceTrustInfo -> SafeHaskellMode
- setSafeMode :: SafeHaskellMode -> IfaceTrustInfo
- noIfaceTrustInfo :: IfaceTrustInfo
- trustInfoToNum :: IfaceTrustInfo -> Word8
- numToTrustInfo :: Word8 -> IfaceTrustInfo
- type IsSafeImport = Bool
- data HsParsedModule = HsParsedModule {
  - hpm_module :: Located (HsModule GhcPs)
  - hpm_src_files :: [FilePath]
  - hpm_annotations :: ApiAnns
  }
- data SourceError
- data GhcApiError
- mkSrcErr :: ErrorMessages -> SourceError
- srcErrorMessages :: SourceError -> ErrorMessages
- mkApiErr :: DynFlags -> SDoc -> GhcApiError
- throwOneError :: MonadIO io => ErrMsg -> io a
- throwErrors :: MonadIO io => ErrorMessages -> io a
- handleSourceError :: ExceptionMonad m => (SourceError -> m a) -> m a -> m a
- handleFlagWarnings :: DynFlags -> [Warn] -> IO ()
- printOrThrowWarnings :: DynFlags -> Bag WarnMsg -> IO ()
- data CompleteMatch = CompleteMatch {
  - completeMatchConLikes :: [Name]
  - completeMatchTyCon :: Name
  }
- type CompleteMatchMap = UniqFM [CompleteMatch]
- mkCompleteMatchMap :: [CompleteMatch] -> CompleteMatchMap
- extendCompleteMatchMap :: CompleteMatchMap -> [CompleteMatch] -> CompleteMatchMap

# compilation state

data HscEnv #

HscEnv is like `Session`, except that some of the fields are immutable. An HscEnv is used to compile a single module from plain Haskell source code (after preprocessing) to either C, assembly or C--. It's also used to store the dynamic linker state to allow for multiple linkers in the same address space. Things like the module graph don't change during a single compilation.

Historical note: "hsc" used to be the name of the compiler binary, when there was a separate driver and compiler. To compile a single module, the driver would invoke hsc on the source code... so nowadays we think of hsc as the layer of the compiler that deals with compiling a single module.

Constructors

HscEnv |
Fields hsc_dflags :: DynFlags The dynamic flag settings hsc_targets :: [Target] The targets (or roots) of the current session hsc_mod_graph :: ModuleGraph The module graph of the current session hsc_IC :: InteractiveContext The context for evaluating interactive statements hsc_HPT :: HomePackageTable The home package table describes already-compiled home-package modules, excluding the module we are compiling right now. (In one-shot mode the current module is the only home-package module, so hsc_HPT is empty. All other modules count as "external-package" modules. However, even in GHCi mode, hi-boot interfaces are demand-loaded into the external-package table.) `hsc_HPT` is not mutable because we only demand-load external packages; the home package is eagerly loaded, module by module, by the compilation manager. The HPT may contain modules compiled earlier by `--make` but not actually below the current module in the dependency graph. (This changes a previous invariant: changed Jan 05.) hsc_EPS :: !(IORef ExternalPackageState) Information about the currently loaded external packages. This is mutable because packages will be demand-loaded during a compilation run as required. hsc_NC :: !(IORef NameCache) As with `hsc_EPS`, this is side-effected by compiling to reflect sucking in interface files. They cache the state of external interface files, in effect. hsc_FC :: !(IORef FinderCache) The cached result of performing finding in the file system hsc_type_env_var :: Maybe (Module, IORef TypeEnv) Used for one-shot compilation only, to initialise the `IfGblEnv`. See `tcg_type_env_var` for `TcGblEnv`. See also Note [hsc_type_env_var hack] hsc_iserv :: MVar (Maybe IServ) interactive server process. Created the first time it is needed. hsc_dynLinker :: DynLinker dynamic linker.

hscEPS :: HscEnv -> IO ExternalPackageState #

Retrieve the ExternalPackageState cache.

type FinderCache = InstalledModuleEnv InstalledFindResult #

The `FinderCache` maps modules to the result of searching for that module. It records the results of searching for modules along the search path. On `:load`, we flush the entire contents of this cache.

data FindResult #

The result of searching for an imported module.

NB: FindResult manages both user source-import lookups (which can result in `Module`) as well as direct imports for interfaces (which always result in `InstalledModule`).

Constructors

Found ModLocation Module | The module was found
NoPackage UnitId | The requested package was not found
FoundMultiple [(Module, ModuleOrigin)] | _Error_: both in multiple packages
NotFound | Not found
Fields fr_paths :: [FilePath] fr_pkg :: Maybe UnitId fr_mods_hidden :: [UnitId] fr_pkgs_hidden :: [UnitId] fr_unusables :: [(UnitId, UnusablePackageReason)] fr_suggestions :: [ModuleSuggestion]

data InstalledFindResult #

Constructors

InstalledFound ModLocation InstalledModule |
InstalledNoPackage InstalledUnitId |
InstalledNotFound [FilePath] (Maybe InstalledUnitId) |

data Target #

A compilation target.

A target may be supplied with the actual text of the module. If so, use this instead of the file contents (this is for use in an IDE where the file hasn't been saved by the user yet).

Constructors

Target |
Fields targetId :: TargetId module or filename targetAllowObjCode :: Bool object code allowed? targetContents :: Maybe (InputFileBuffer, UTCTime) Optional in-memory buffer containing the source code GHC should use for this target instead of reading it from disk. Since GHC version 8.10 modules which require preprocessors such as Literate Haskell or CPP to run are also supported. If a corresponding source file does not exist on disk this will result in a `SourceError` exception if `targetId = TargetModule _` is used. However together with `targetId = TargetFile _` GHC will not complain about the file missing.

#### Instances

Instances details

Outputable Target # |
Instance details Defined in HscTypes Methods ppr :: Target -> SDoc # pprPrec :: Rational -> Target -> SDoc #

data TargetId #

Constructors

TargetModule ModuleName | A module name: search for the file
TargetFile FilePath (Maybe Phase) | A filename: preprocess & parse it to find the module name. If specified, the Phase indicates how to compile this file (which phase to start from). Nothing indicates the starting phase should be determined from the suffix of the filename.

#### Instances

Instances details

Eq TargetId # |
Instance details Defined in HscTypes Methods (==) :: TargetId -> TargetId -> Bool # (/=) :: TargetId -> TargetId -> Bool #
Outputable TargetId # |
Instance details Defined in HscTypes Methods ppr :: TargetId -> SDoc # pprPrec :: Rational -> TargetId -> SDoc #

type InputFileBuffer = StringBuffer #

pprTarget :: Target -> SDoc #

pprTargetId :: TargetId -> SDoc #

data HscStatus #

Status of a compilation to hard-code

Constructors

HscNotGeneratingCode ModIface | Nothing to do.
HscUpToDate ModIface | Nothing to do because code already exists.
HscUpdateBoot ModIface | Update boot file result.
HscUpdateSig ModIface | Generate signature file (backpack)
HscRecomp | Recompile this module.
Fields hscs_guts :: CgGuts Information for the code generator. hscs_mod_location :: !ModLocation Module info hscs_partial_iface :: !PartialModIface Partial interface hscs_old_iface_hash :: !(Maybe Fingerprint) Old interface hash for this compilation, if an old interface file exists. Pass to `hscMaybeWriteIface` when writing the interface to avoid updating the existing interface when the interface isn't changed. hscs_iface_dflags :: !DynFlags Generate final iface using this DynFlags. FIXME (osa): I don't understand why this is necessary, but I spent almost two days trying to figure this out and I couldn't .. perhaps someone who understands this code better will remove this later.

data IServ #

Constructors

IServ |
Fields iservPipe :: Pipe iservProcess :: ProcessHandle iservLookupSymbolCache :: IORef (UniqFM (Ptr ())) iservPendingFrees :: [HValueRef]

# ModuleGraph

data ModuleGraph #

A ModuleGraph contains all the nodes from the home package (only). There will be a node for each source module, plus a node for each hi-boot module.

The graph is not necessarily stored in topologically-sorted order. Use `topSortModuleGraph` and `flattenSCC` to achieve this.

emptyMG :: ModuleGraph #

mkModuleGraph :: [ModSummary] -> ModuleGraph #

extendMG :: ModuleGraph -> ModSummary -> ModuleGraph #

Add a ModSummary to ModuleGraph. Assumes that the new ModSummary is not an element of the ModuleGraph.

mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph #

Map a function `f` over all the `ModSummaries`. To preserve invariants `f` can't change the isBoot status.

mgModSummaries :: ModuleGraph -> [ModSummary] #

mgElemModule :: ModuleGraph -> Module -> Bool #

mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary #

Look up a ModSummary in the ModuleGraph

needsTemplateHaskellOrQQ :: ModuleGraph -> Bool #

Determines whether a set of modules requires Template Haskell or Quasi Quotes

Note that if the session's `DynFlags` enabled Template Haskell when `depanal` was called, then each module in the returned module graph will have Template Haskell enabled whether it is actually needed or not.

mgBootModules :: ModuleGraph -> ModuleSet #

# Hsc monad

newtype Hsc a #

Constructors

Hsc (HscEnv -> WarningMessages -> IO (a, WarningMessages)) |

#### Instances

Instances details

Monad Hsc # |
Instance details Defined in HscTypes Methods (>>=) :: Hsc a -> (a -> Hsc b) -> Hsc b Source # (>>) :: Hsc a -> Hsc b -> Hsc b Source # return :: a -> Hsc a Source #
Functor Hsc # |
Instance details Defined in HscTypes Methods fmap :: (a -> b) -> Hsc a -> Hsc b Source # (<$) :: a -> Hsc b -> Hsc a Source #
Applicative Hsc # |
Instance details Defined in HscTypes Methods pure :: a -> Hsc a Source # (<*>) :: Hsc (a -> b) -> Hsc a -> Hsc b Source # liftA2 :: (a -> b -> c) -> Hsc a -> Hsc b -> Hsc c Source # (*>) :: Hsc a -> Hsc b -> Hsc b Source # (<*) :: Hsc a -> Hsc b -> Hsc a Source #
MonadIO Hsc # |
Instance details Defined in HscTypes Methods liftIO :: IO a -> Hsc a Source #
HasDynFlags Hsc # |
Instance details Defined in HscTypes Methods getDynFlags :: Hsc DynFlags #

runHsc :: HscEnv -> Hsc a -> IO a #

mkInteractiveHscEnv :: HscEnv -> HscEnv #

runInteractiveHsc :: HscEnv -> Hsc a -> IO a #

# Information about modules

data ModDetails #

The `ModDetails` is essentially a cache for information in the `ModIface` for home modules only. Information relating to packages will be loaded into global environments in `ExternalPackageState`.

Constructors

ModDetails |
Fields md_exports :: [AvailInfo] md_types :: !TypeEnv Local type environment for this particular module Includes Ids, TyCons, PatSyns md_insts :: ![ClsInst] `DFunId`s for the instances in this module md_fam_insts :: ![FamInst] md_rules :: ![CoreRule] Domain may include `Id`s from other modules md_anns :: ![Annotation] Annotations present in this module: currently they only annotate things also declared in this module md_complete_sigs :: [CompleteMatch] Complete match pragmas for this module

emptyModDetails :: ModDetails #

Constructs an empty ModDetails

data ModGuts #

A ModGuts is carried through the compiler, accumulating stuff as it goes There is only one ModGuts at any time, the one for the module being compiled right now. Once it is compiled, a `ModIface` and `ModDetails` are extracted and the ModGuts is discarded.

Constructors

ModGuts |
Fields mg_module :: !Module Module being compiled mg_hsc_src :: HscSource Whether it's an hs-boot module mg_loc :: SrcSpan For error messages from inner passes mg_exports :: ![AvailInfo] What it exports mg_deps :: !Dependencies What it depends on, directly or otherwise mg_usages :: ![Usage] What was used? Used for interfaces. mg_used_th :: !Bool Did we run a TH splice? mg_rdr_env :: !GlobalRdrEnv Top-level lexical environment mg_fix_env :: !FixityEnv Fixities declared in this module. Used for creating interface files. mg_tcs :: ![TyCon] TyCons declared in this module (includes TyCons for classes) mg_insts :: ![ClsInst] Class instances declared in this module mg_fam_insts :: ![FamInst] Family instances declared in this module mg_patsyns :: ![PatSyn] Pattern synonyms declared in this module mg_rules :: ![CoreRule] Before the core pipeline starts, contains See Note [Overall plumbing for rules] in Rules.hs mg_binds :: !CoreProgram Bindings for this module mg_foreign :: !ForeignStubs Foreign exports declared in this module mg_foreign_files :: ![(ForeignSrcLang, FilePath)] Files to be compiled with the C compiler mg_warns :: !Warnings Warnings declared in the module mg_anns :: [Annotation] Annotations declared in this module mg_complete_sigs :: [CompleteMatch] Complete Matches mg_hpc_info :: !HpcInfo Coverage tick boxes in the module mg_modBreaks :: !(Maybe ModBreaks) Breakpoints for the module mg_inst_env :: InstEnv Class instance environment for home-package modules (including this one); c.f. `tcg_inst_env` mg_fam_inst_env :: FamInstEnv Type-family instance environment for home-package modules (including this one); c.f. `tcg_fam_inst_env` mg_safe_haskell :: SafeHaskellMode Safe Haskell mode mg_trust_pkg :: Bool Do we need to trust our own package for Safe Haskell? See Note [RnNames . Trust Own Package] mg_doc_hdr :: !(Maybe HsDocString) Module header. mg_decl_docs :: !DeclDocMap Docs on declarations. mg_arg_docs :: !ArgDocMap Docs on arguments.

data CgGuts #

A restricted form of `ModGuts` for code generation purposes

Constructors

CgGuts |
Fields cg_module :: !Module Module being compiled cg_tycons :: [TyCon] Algebraic data types (including ones that started life as classes); generate constructors and info tables. Includes newtypes, just for the benefit of External Core cg_binds :: CoreProgram The tidied main bindings, including previously-implicit bindings for record and class selectors, and data constructor wrappers. But *not* data constructor workers; reason: we regard them as part of the code-gen of tycons cg_foreign :: !ForeignStubs Foreign export stubs cg_foreign_files :: ![(ForeignSrcLang, FilePath)] cg_dep_pkgs :: ![InstalledUnitId] Dependent packages, used to generate #includes for C code gen cg_hpc_info :: !HpcInfo Program coverage tick box information cg_modBreaks :: !(Maybe ModBreaks) Module breakpoints cg_spt_entries :: [SptEntry] Static pointer table entries for static forms defined in the module. See Note [Grand plan for static forms] in StaticPtrTable

data ForeignStubs #

Foreign export stubs

Constructors

NoStubs | We don't have any stubs
ForeignStubs SDoc SDoc | There are some stubs. Parameters: 1) Header file prototypes for "foreign exported" functions 2) C stubs to use when calling "foreign exported" functions

appendStubC :: ForeignStubs -> SDoc -> ForeignStubs #

type ImportedMods = ModuleEnv [ImportedBy] #

Records the modules directly imported by a module for extracting e.g. usage information, and also to give better error message

data ImportedBy #

If a module was "imported" by the user, we associate it with more detailed usage information `ImportedModsVal`; a module imported by the system only gets used for usage information.

Constructors

ImportedByUser ImportedModsVal |
ImportedBySystem |

importedByUser :: [ImportedBy] -> [ImportedModsVal] #

data ImportedModsVal #

Constructors

ImportedModsVal |
Fields imv_name :: ModuleName The name the module is imported with imv_span :: SrcSpan the source span of the whole import imv_is_safe :: IsSafeImport whether this is a safe import imv_is_hiding :: Bool whether this is an "hiding" import imv_all_exports :: !GlobalRdrEnv all the things the module could provide NB. BangPattern here: otherwise this leaks. (#15111) imv_qualified :: Bool whether this is a qualified import

data SptEntry #

An entry to be inserted into a module's static pointer table. See Note [Grand plan for static forms] in StaticPtrTable.

Constructors

SptEntry Id Fingerprint |

#### Instances

Instances details

Outputable SptEntry # |
Instance details Defined in LinkerTypes Methods ppr :: SptEntry -> SDoc # pprPrec :: Rational -> SptEntry -> SDoc #

data ForeignSrcLang Source #

Foreign formats supported by GHC via TH

Constructors

LangC | C
LangCxx | C++
LangObjc | Objective C
LangObjcxx | Objective C++
LangAsm | Assembly language (.s)
RawObject | Object (.o)

#### Instances

Instances details

Eq ForeignSrcLang |
Instance details Defined in GHC.ForeignSrcLang.Type Methods (==) :: ForeignSrcLang -> ForeignSrcLang -> Bool # (/=) :: ForeignSrcLang -> ForeignSrcLang -> Bool #
Show ForeignSrcLang |
Instance details Defined in GHC.ForeignSrcLang.Type Methods showsPrec :: Int -> ForeignSrcLang -> ShowS Source # show :: ForeignSrcLang -> String Source # showList :: [ForeignSrcLang] -> ShowS Source #
Generic ForeignSrcLang |
Instance details Defined in GHC.ForeignSrcLang.Type Associated Types type Rep ForeignSrcLang :: Type -> Type Source # Methods from :: ForeignSrcLang -> Rep ForeignSrcLang x Source # to :: Rep ForeignSrcLang x -> ForeignSrcLang Source #
type Rep ForeignSrcLang |
Instance details Defined in GHC.ForeignSrcLang.Type type Rep ForeignSrcLang = D1 ('MetaData "ForeignSrcLang" "GHC.ForeignSrcLang.Type" "ghc-boot-th-8.10.1" '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))))

phaseForeignLanguage :: Phase -> Maybe ForeignSrcLang #

Foreign language of the phase if the phase deals with a foreign code

data ModSummary #

A single node in a `ModuleGraph`. The nodes of the module graph are one of:

- A regular Haskell source module
- A hi-boot source module

Constructors

ModSummary |
Fields ms_mod :: Module Identity of the module ms_hsc_src :: HscSource The module source either plain Haskell or hs-boot ms_location :: ModLocation Location of the various files belonging to the module ms_hs_date :: UTCTime Timestamp of source file ms_obj_date :: Maybe UTCTime Timestamp of object, if we have one ms_iface_date :: Maybe UTCTime Timestamp of hi file, if we *only* are typechecking (it is `Nothing` otherwise. See Note [Recompilation checking in -fno-code mode] and #9243 ms_hie_date :: Maybe UTCTime Timestamp of hie file, if we have one ms_srcimps :: [(Maybe FastString, Located ModuleName)] Source imports of the module ms_textual_imps :: [(Maybe FastString, Located ModuleName)] Non-source imports of the module from the module *text* ms_parsed_mod :: Maybe HsParsedModule The parsed, nonrenamed source, if we have it. This is also used to support "inline module syntax" in Backpack files. ms_hspp_file :: FilePath Filename of preprocessed source file ms_hspp_opts :: DynFlags Cached flags from `OPTIONS`, `INCLUDE` and `LANGUAGE` pragmas in the modules source code ms_hspp_buf :: Maybe StringBuffer The actual preprocessed source, if we have it

#### Instances

Instances details

Outputable ModSummary # |
Instance details Defined in HscTypes Methods ppr :: ModSummary -> SDoc # pprPrec :: Rational -> ModSummary -> SDoc #

ms_imps :: ModSummary -> [(Maybe FastString, Located ModuleName)] #

ms_installed_mod :: ModSummary -> InstalledModule #

ms_mod_name :: ModSummary -> ModuleName #

ms_home_imps :: ModSummary -> [Located ModuleName] #

All of the (possibly) home module imports from a `ModSummary`; that is to say, each of these module names could be a home import if an appropriately named file existed. (This is in contrast to package qualified imports, which are guaranteed not to be home imports.)

home_imps :: [(Maybe FastString, Located ModuleName)] -> [Located ModuleName] #

ms_home_allimps :: ModSummary -> [ModuleName] #

ms_home_srcimps :: ModSummary -> [Located ModuleName] #

Like `ms_home_imps`, but for SOURCE imports.

showModMsg :: DynFlags -> HscTarget -> Bool -> ModSummary -> String #

isBootSummary :: ModSummary -> Bool #

Did this `ModSummary` originate from a hs-boot file?

msHsFilePath :: ModSummary -> FilePath #

msHiFilePath :: ModSummary -> FilePath #

msObjFilePath :: ModSummary -> FilePath #

data SourceModified #

Indicates whether a given module's source has been modified since it was last compiled.

Constructors

SourceModified | the source has been modified
SourceUnmodified | the source has not been modified. Compilation may or may not be necessary, depending on whether any dependencies have changed since we last compiled.
SourceUnmodifiedAndStable | the source has not been modified, and furthermore all of its (transitive) dependencies are up to date; it definitely does not need to be recompiled. This is important for two reasons: (a) we can omit the version check in checkOldIface, and (b) if the module used TH splices we don't need to force recompilation.

isTemplateHaskellOrQQNonBoot :: ModSummary -> Bool #

# Information about the module being compiled

data HscSource #

Constructors

HsSrcFile |
HsBootFile |
HsigFile |

#### Instances

Instances details

Eq HscSource # |
Instance details Defined in DriverPhases Methods (==) :: HscSource -> HscSource -> Bool # (/=) :: HscSource -> HscSource -> Bool #
Ord HscSource # |
Instance details Defined in DriverPhases Methods compare :: HscSource -> HscSource -> Ordering # (<) :: HscSource -> HscSource -> Bool # (<=) :: HscSource -> HscSource -> Bool # (>) :: HscSource -> HscSource -> Bool # (>=) :: HscSource -> HscSource -> Bool # max :: HscSource -> HscSource -> HscSource # min :: HscSource -> HscSource -> HscSource #
Show HscSource # |
Instance details Defined in DriverPhases Methods showsPrec :: Int -> HscSource -> ShowS Source # show :: HscSource -> String Source # showList :: [HscSource] -> ShowS Source #
Binary HscSource # |
Instance details Defined in DriverPhases Methods put_ :: BinHandle -> HscSource -> IO () # put :: BinHandle -> HscSource -> IO (Bin HscSource) # get :: BinHandle -> IO HscSource #

isHsBootOrSig :: HscSource -> Bool #

isHsigFile :: HscSource -> Bool #

hscSourceString :: HscSource -> String #

# State relating to modules in this package

type HomePackageTable = DModuleNameEnv HomeModInfo #

Helps us find information about modules in the home package

data HomeModInfo #

Information about modules in the package being compiled

Constructors

HomeModInfo |
Fields hm_iface :: !ModIface The basic loaded interface file: every loaded module has one of these, even if it is imported from another package hm_details :: !ModDetails Extra information that has been created from the `ModIface` for the module, typically during typechecking hm_linkable :: !(Maybe Linkable) The actual artifact we would like to link to access things in this module. `hm_linkable` might be Nothing: If this is an .hs-boot module Temporarily during compilation if we pruned away the old linkable because it was out of date. After a complete compilation (`load`), all `hm_linkable` fields in the `HomePackageTable` will be `Just`. When re-linking a module (`HscNoRecomp`), we construct the `HomeModInfo` by building a new `ModDetails` from the old `ModIface` (only).

emptyHomePackageTable :: HomePackageTable #

Constructs an empty HomePackageTable

lookupHpt :: HomePackageTable -> ModuleName -> Maybe HomeModInfo #

eltsHpt :: HomePackageTable -> [HomeModInfo] #

filterHpt :: (HomeModInfo -> Bool) -> HomePackageTable -> HomePackageTable #

allHpt :: (HomeModInfo -> Bool) -> HomePackageTable -> Bool #

mapHpt :: (HomeModInfo -> HomeModInfo) -> HomePackageTable -> HomePackageTable #

delFromHpt :: HomePackageTable -> ModuleName -> HomePackageTable #

addToHpt :: HomePackageTable -> ModuleName -> HomeModInfo -> HomePackageTable #

addListToHpt :: HomePackageTable -> [(ModuleName, HomeModInfo)] -> HomePackageTable #

lookupHptDirectly :: HomePackageTable -> Unique -> Maybe HomeModInfo #

listToHpt :: [(ModuleName, HomeModInfo)] -> HomePackageTable #

hptCompleteSigs :: HscEnv -> [CompleteMatch] #

hptInstances :: HscEnv -> (ModuleName -> Bool) -> ([ClsInst], [FamInst]) #

Find all the instance declarations (of classes and families) from the Home Package Table filtered by the provided predicate function. Used in `tcRnImports`, to select the instances that are in the transitive closure of imports from the currently compiled module.

hptRules :: HscEnv -> [(ModuleName, IsBootInterface)] -> [CoreRule] #

Get rules from modules "below" this one (in the dependency sense)

pprHPT :: HomePackageTable -> SDoc #

# State relating to known packages

data ExternalPackageState #

Information about other packages that we have slurped in by reading their interface files

Constructors

EPS |
Fields eps_is_boot :: !(ModuleNameEnv (ModuleName, IsBootInterface)) In OneShot mode (only), home-package modules accumulate in the external package state, and are sucked in lazily. For these home-pkg modules (only) we need to record which are boot modules. We set this field after loading all the explicitly-imported interfaces, but before doing anything else The `ModuleName` part is not necessary, but it's useful for debug prints, and it's convenient because this field comes direct from `imp_dep_mods` eps_PIT :: !PackageIfaceTable The `ModIface`s for modules in external packages whose interfaces we have opened. The declarations in these interface files are held in the `eps_decls`, `eps_inst_env`, `eps_fam_inst_env` and `eps_rules` fields of this record, not in the `mi_decls` fields of the interface we have sucked in. What is in the PIT is: The Module Fingerprint info Its exports Fixities Deprecations and warnings eps_free_holes :: InstalledModuleEnv (UniqDSet ModuleName) Cache for `mi_free_holes`. Ordinarily, we can rely on the `eps_PIT` for this information, EXCEPT that when we do dependency analysis, we need to look at the `Dependencies` of our imports to determine what their precise free holes are (`moduleFreeHolesPrecise`). We don't want to repeatedly reread in the interface for every import, so cache it here. When the PIT gets filled in we can drop these entries. eps_PTE :: !PackageTypeEnv Result of typechecking all the external package interface files we have sucked in. The domain of the mapping is external-package modules eps_inst_env :: !PackageInstEnv The total `InstEnv` accumulated from all the external-package modules eps_fam_inst_env :: !PackageFamInstEnv The total `FamInstEnv` accumulated from all the external-package modules eps_rule_base :: !PackageRuleBase The total `RuleEnv` accumulated from all the external-package modules eps_ann_env :: !PackageAnnEnv The total `AnnEnv` accumulated from all the external-package modules eps_complete_matches :: !PackageCompleteMatchMap The total `CompleteMatchMap` accumulated from all the external-package modules eps_mod_fam_inst_env :: !(ModuleEnv FamInstEnv) The family instances accumulated from external packages, keyed off the module that declared them eps_stats :: !EpsStats Stastics about what was loaded from external packages

data EpsStats #

Accumulated statistics about what we are putting into the `ExternalPackageState`. "In" means stuff that is just read from interface files, "Out" means actually sucked in and type-checked

Constructors

EpsStats |
Fields n_ifaces_in, n_decls_in, n_decls_out, n_rules_in, n_rules_out, n_insts_in, n_insts_out :: !Int

addEpsInStats :: EpsStats -> Int -> Int -> Int -> EpsStats #

Add stats for one newly-read interface

type PackageTypeEnv = TypeEnv #

type PackageIfaceTable = ModuleEnv ModIface #

Helps us find information about modules in the imported packages

emptyPackageIfaceTable :: PackageIfaceTable #

Constructs an empty PackageIfaceTable

lookupIfaceByModule :: HomePackageTable -> PackageIfaceTable -> Module -> Maybe ModIface #

Find the `ModIface` for a `Module`, searching in both the loaded home and external package module information

emptyPartialModIface :: Module -> PartialModIface #

emptyFullModIface :: Module -> ModIface #

lookupHptByModule :: HomePackageTable -> Module -> Maybe HomeModInfo #

type PackageInstEnv = InstEnv #

type PackageFamInstEnv = FamInstEnv #

type PackageRuleBase = RuleBase #

type PackageCompleteMatchMap = CompleteMatchMap #

mkSOName :: Platform -> FilePath -> FilePath #

mkHsSOName :: Platform -> FilePath -> FilePath #

soExt :: Platform -> FilePath #

# Metaprogramming

data MetaRequest #

The supported metaprogramming result types

Constructors

MetaE (LHsExpr GhcPs -> MetaResult) |
MetaP (LPat GhcPs -> MetaResult) |
MetaT (LHsType GhcPs -> MetaResult) |
MetaD ([LHsDecl GhcPs] -> MetaResult) |
MetaAW (Serialized -> MetaResult) |

data MetaResult #

data constructors not exported to ensure correct result type

metaRequestE :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LHsExpr GhcPs) #

metaRequestP :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LPat GhcPs) #

metaRequestT :: Functor f => MetaHook f -> LHsExpr GhcTc -> f (LHsType GhcPs) #

metaRequestD :: Functor f => MetaHook f -> LHsExpr GhcTc -> f [LHsDecl GhcPs] #

metaRequestAW :: Functor f => MetaHook f -> LHsExpr GhcTc -> f Serialized #

type MetaHook f = MetaRequest -> LHsExpr GhcTc -> f MetaResult #

# Annotations

prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv #

Deal with gathering annotations in from all possible places and combining them into a single `AnnEnv`

# Interactive context

data InteractiveContext #

Interactive context, recording information about the state of the context in which statements are executed in a GHCi session.

Constructors

InteractiveContext |
Fields ic_dflags :: DynFlags The `DynFlags` used to evaluate interative expressions and statements. ic_mod_index :: Int Each GHCi stmt or declaration brings some new things into scope. We give them names like interactive:Ghci9.T, where the ic_index is the '9'. The ic_mod_index is incremented whenever we add something to ic_tythings See Note [The interactive package] ic_imports :: [InteractiveImport] The GHCi top-level scope (ic_rn_gbl_env) is extended with these imports This field is only stored here so that the client can retrieve it with GHC.getContext. GHC itself doesn't use it, but does reset it to empty sometimes (such as before a GHC.load). The context is set with GHC.setContext. ic_tythings :: [TyThing] TyThings defined by the user, in reverse order of definition (ie most recent at the front) See Note [ic_tythings] ic_rn_gbl_env :: GlobalRdrEnv The cached `GlobalRdrEnv`, built by `setContext` and updated regularly It contains everything in scope at the command line, including everything in ic_tythings ic_instances :: ([ClsInst], [FamInst]) All instances and family instances created during this session. These are grabbed en masse after each update to be sure that proper overlapping is retained. That is, rather than re-check the overlapping each time we update the context, we just take the results from the instance code that already does that. ic_fix_env :: FixityEnv Fixities declared in let statements ic_default :: Maybe [Type] The current default types, set by a 'default' declaration ic_resume :: [Resume] The stack of breakpoint contexts ic_monad :: Name The monad that GHCi is executing in ic_int_print :: Name The function that is used for printing results of expressions in ghci and -e mode. ic_cwd :: Maybe FilePath

emptyInteractiveContext :: DynFlags -> InteractiveContext #

Constructs an empty InteractiveContext.

icPrintUnqual :: DynFlags -> InteractiveContext -> PrintUnqualified #

Get the PrintUnqualified function based on the flags and this InteractiveContext

icInScopeTTs :: InteractiveContext -> [TyThing] #

This function returns the list of visible TyThings (useful for e.g. showBindings)

icExtendGblRdrEnv :: GlobalRdrEnv -> [TyThing] -> GlobalRdrEnv #

Add TyThings to the GlobalRdrEnv, earlier ones in the list shadowing later ones, and shadowing existing entries in the GlobalRdrEnv.

extendInteractiveContext :: InteractiveContext -> [TyThing] -> [ClsInst] -> [FamInst] -> Maybe [Type] -> FixityEnv -> InteractiveContext #

extendInteractiveContext is called with new TyThings recently defined to update the InteractiveContext to include them. Ids are easily removed when shadowed, but Classes and TyCons are not. Some work could be done to determine whether they are entirely shadowed, but as you could still have references to them (e.g. instances for classes or values of the type for TyCons), it's not clear whether removing them is even the appropriate behavior.

extendInteractiveContextWithIds :: InteractiveContext -> [Id] -> InteractiveContext #

substInteractiveContext :: InteractiveContext -> TCvSubst -> InteractiveContext #

setInteractivePrintName :: InteractiveContext -> Name -> InteractiveContext #

icInteractiveModule :: InteractiveContext -> Module #

data InteractiveImport #

Constructors

IIDecl (ImportDecl GhcPs) | Bring the exports of a particular module (filtered by an import decl) into scope
IIModule ModuleName | Bring into scope the entire top-level envt of of this module, including the things imported into it.

#### Instances

Instances details

Outputable InteractiveImport # |
Instance details Defined in HscTypes Methods ppr :: InteractiveImport -> SDoc # pprPrec :: Rational -> InteractiveImport -> SDoc #

setInteractivePackage :: HscEnv -> HscEnv #

mkPrintUnqualified :: DynFlags -> GlobalRdrEnv -> PrintUnqualified #

Creates some functions that work out the best ways to format names for the user according to a set of heuristics.

pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc #

mkQualPackage :: DynFlags -> QueryQualifyPackage #

Creates a function for formatting packages based on two heuristics: (1) don't qualify if the package in question is "main", and (2) only qualify with a unit id if the package ID would be ambiguous.

mkQualModule :: DynFlags -> QueryQualifyModule #

Creates a function for formatting modules based on two heuristics: (1) if the module is the current module, don't qualify, and (2) if there is only one exposed package which exports this module, don't qualify.

pkgQual :: DynFlags -> PrintUnqualified #

A function which only qualifies package names if necessary; but qualifies all other identifiers.

# Interfaces

type ModIface = ModIface_ 'ModIfaceFinal #

type PartialModIface = ModIface_ 'ModIfaceCore #

data ModIface_ (phase :: ModIfacePhase) #

A `ModIface` plus a `ModDetails` summarises everything we know about a compiled module. The `ModIface` is the stuff *before* linking, and can be written out to an interface file. The 'ModDetails is after linking and can be completely recovered from just the `ModIface`.

When we read an interface file, we also construct a `ModIface` from it, except that we explicitly make the `mi_decls` and a few other fields empty; as when reading we consolidate the declarations etc. into a number of indexed maps and environments in the `ExternalPackageState`.

Constructors

ModIface |
Fields mi_module :: !Module Name of the module we are for mi_sig_of :: !(Maybe Module) Are we a sig of another mod? mi_hsc_src :: !HscSource Boot? Signature? mi_deps :: Dependencies The dependencies of the module. This is consulted for directly-imported modules, but not for anything else (hence lazy) mi_usages :: [Usage] Usages; kept sorted so that it's easy to decide whether to write a new iface file (changing usages doesn't affect the hash of this module) NOT STRICT! we read this field lazily from the interface file It is *only* consulted by the recompilation checker mi_exports :: ![IfaceExport] Exports Kept sorted by (mod,occ), to make version comparisons easier Records the modules that are the declaration points for things exported by this module, and the `OccName`s of those things mi_used_th :: !Bool Module required TH splices when it was compiled. This disables recompilation avoidance (see #481). mi_fixities :: [(OccName, Fixity)] Fixities NOT STRICT! we read this field lazily from the interface file mi_warns :: Warnings Warnings NOT STRICT! we read this field lazily from the interface file mi_anns :: [IfaceAnnotation] Annotations NOT STRICT! we read this field lazily from the interface file mi_decls :: [IfaceDeclExts phase] Type, class and variable declarations The hash of an Id changes if its fixity or deprecations change (as well as its type of course) Ditto data constructors, class operations, except that the hash of the parent class/tycon changes mi_globals :: !(Maybe GlobalRdrEnv) Binds all the things defined at the top level in the original source code for this module. which is NOT the same as mi_exports, nor mi_decls (which may contains declarations for things not actually defined by the user). Used for GHCi and for inspecting the contents of modules via the GHC API only. (We need the source file to figure out the top-level environment, if we didn't compile this module from source then this field contains `Nothing`). Strictly speaking this field should live in the `HomeModInfo`, but that leads to more plumbing. mi_insts :: [IfaceClsInst] Sorted class instance mi_fam_insts :: [IfaceFamInst] Sorted family instances mi_rules :: [IfaceRule] Sorted rules mi_hpc :: !AnyHpcUsage True if this program uses Hpc at any point in the program. mi_trust :: !IfaceTrustInfo Safe Haskell Trust information for this module. mi_trust_pkg :: !Bool Do we require the package this module resides in be trusted to trust this module? This is used for the situation where a module is Safe (so doesn't require the package be trusted itself) but imports some trustworthy modules from its own package (which does require its own package be trusted). See Note [RnNames . Trust Own Package] mi_complete_sigs :: [IfaceCompleteMatch] mi_doc_hdr :: Maybe HsDocString Module header. mi_decl_docs :: DeclDocMap Docs on declarations. mi_arg_docs :: ArgDocMap Docs on arguments. mi_final_exts :: !(IfaceBackendExts phase) Either `()` or `ModIfaceBackend` for a fully instantiated interface.

#### Instances

Instances details

Binary ModIface # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> ModIface -> IO () # put :: BinHandle -> ModIface -> IO (Bin ModIface) # get :: BinHandle -> IO ModIface #
(NFData (IfaceBackendExts phase), NFData (IfaceDeclExts phase)) => NFData (ModIface_ phase) # |
Instance details Defined in HscTypes Methods rnf :: ModIface_ phase -> () Source #

data ModIfaceBackend #

Extends a PartialModIface with information which is either: * Computed after codegen * Or computed just before writing the iface to disk. (Hashes) In order to fully instantiate it.

Constructors

ModIfaceBackend |
Fields mi_iface_hash :: !Fingerprint Hash of the whole interface mi_mod_hash :: !Fingerprint Hash of the ABI only mi_flag_hash :: !Fingerprint Hash of the important flags used when compiling the module, excluding optimisation flags mi_opt_hash :: !Fingerprint Hash of optimisation flags mi_hpc_hash :: !Fingerprint Hash of hpc flags mi_plugin_hash :: !Fingerprint Hash of plugins mi_orphan :: !WhetherHasOrphans Whether this module has orphans mi_finsts :: !WhetherHasFamInst Whether this module has family instances. See Note [The type family instance consistency story]. mi_exp_hash :: !Fingerprint Hash of export list mi_orphan_hash :: !Fingerprint Hash for orphan rules, class and family instances combined mi_warn_fn :: !(OccName -> Maybe WarningTxt) Cached lookup for `mi_warns` mi_fix_fn :: !(OccName -> Maybe Fixity) Cached lookup for `mi_fixities` mi_hash_fn :: !(OccName -> Maybe (OccName, Fingerprint)) Cached lookup for `mi_decls`. The `Nothing` in `mi_hash_fn` means that the thing isn't in decls. It's useful to know that when seeing if we are up to date wrt. the old interface. The `OccName` is the parent of the name, if it has one.

mkIfaceWarnCache :: Warnings -> OccName -> Maybe WarningTxt #

Constructs the cache for the `mi_warn_fn` field of a `ModIface`

mkIfaceHashCache :: [(Fingerprint, IfaceDecl)] -> OccName -> Maybe (OccName, Fingerprint) #

Constructs cache for the `mi_hash_fn` field of a `ModIface`

mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Maybe Fixity #

Creates cached lookup for the `mi_fix_fn` field of `ModIface`

emptyIfaceWarnCache :: OccName -> Maybe WarningTxt #

mi_boot :: ModIface -> Bool #

Old-style accessor for whether or not the ModIface came from an hs-boot file.

mi_fix :: ModIface -> OccName -> Fixity #

Lookups up a (possibly cached) fixity from a `ModIface`. If one cannot be found, `defaultFixity` is returned instead.

mi_semantic_module :: ModIface_ a -> Module #

The semantic module for this interface; e.g., if it's a interface for a signature, if `mi_module` is `p[A=A]:A`, `mi_semantic_module` will be `A`.

mi_free_holes :: ModIface -> UniqDSet ModuleName #

The "precise" free holes, e.g., the signatures that this `ModIface` depends on.

renameFreeHoles :: UniqDSet ModuleName -> [(ModuleName, Module)] -> UniqDSet ModuleName #

Given a set of free holes, and a unit identifier, rename the free holes according to the instantiation of the unit identifier. For example, if we have A and B free, and our unit identity is `p[A=C,B=impl:B]`, the renamed free holes are just C.

# Fixity

type FixityEnv = NameEnv FixItem #

Fixity environment mapping names to their fixities

data FixItem #

Fixity information for an `Name`. We keep the OccName in the range so that we can generate an interface from it

Constructors

FixItem OccName Fixity |

#### Instances

Instances details

Outputable FixItem # |
Instance details Defined in HscTypes Methods ppr :: FixItem -> SDoc # pprPrec :: Rational -> FixItem -> SDoc #

lookupFixity :: FixityEnv -> Name -> Fixity #

emptyFixityEnv :: FixityEnv #

# TyThings and type environments

data TyThing #

A global typecheckable-thing, essentially anything that has a name. Not to be confused with a `TcTyThing`, which is also a typecheckable thing but in the *local* context. See `TcEnv` for how to retrieve a `TyThing` given a `Name`.

Constructors

AnId Id |
AConLike ConLike |
ATyCon TyCon |
ACoAxiom (CoAxiom Branched) |

#### Instances

Instances details

Outputable TyThing # |
Instance details Defined in TyCoRep Methods ppr :: TyThing -> SDoc # pprPrec :: Rational -> TyThing -> SDoc #
NamedThing TyThing # |
Instance details Defined in TyCoRep Methods getOccName :: TyThing -> OccName # getName :: TyThing -> Name #

tyThingAvailInfo :: TyThing -> [AvailInfo] #

The Names that a TyThing should bring into scope. Used to build the GlobalRdrEnv for the InteractiveContext.

tyThingTyCon :: TyThing -> TyCon #

Get the `TyCon` from a `TyThing` if it is a type constructor thing. Panics otherwise

tyThingDataCon :: TyThing -> DataCon #

Get the `DataCon` from a `TyThing` if it is a data constructor thing. Panics otherwise

tyThingConLike :: TyThing -> ConLike #

Get the `ConLike` from a `TyThing` if it is a data constructor thing. Panics otherwise

tyThingId :: TyThing -> Id #

Get the `Id` from a `TyThing` if it is a id *or* data constructor thing. Panics otherwise

tyThingCoAxiom :: TyThing -> CoAxiom Branched #

Get the `CoAxiom` from a `TyThing` if it is a coercion axiom thing. Panics otherwise

tyThingParent_maybe :: TyThing -> Maybe TyThing #

tyThingParent_maybe x returns (Just p) when pprTyThingInContext should print a declaration for p (albeit with some "..." in it) when asked to show x It returns the *immediate* parent. So a datacon returns its tycon but the tycon could be the associated type of a class, so it in turn might have a parent.

tyThingsTyCoVars :: [TyThing] -> TyCoVarSet #

implicitTyThings :: TyThing -> [TyThing] #

Determine the `TyThing`s brought into scope by another `TyThing` other than itself. For example, Id's don't have any implicit TyThings as they just bring themselves into scope, but classes bring their dictionary datatype, type constructor and some selector functions into scope, just for a start!

implicitTyConThings :: TyCon -> [TyThing] #

implicitClassThings :: Class -> [TyThing] #

isImplicitTyThing :: TyThing -> Bool #

Returns `True` if there should be no interface-file declaration for this thing on its own: either it is built-in, or it is part of some other declaration, or it is generated implicitly by some other declaration.

type TypeEnv = NameEnv TyThing #

A map from `Name`s to `TyThing`s, constructed by typechecking local declarations or interface files

lookupType :: DynFlags -> HomePackageTable -> PackageTypeEnv -> Name -> Maybe TyThing #

Find the `TyThing` for the given `Name` by using all the resources at our disposal: the compiled modules in the `HomePackageTable` and the compiled modules in other packages that live in `PackageTypeEnv`. Note that this does NOT look up the `TyThing` in the module being compiled: you have to do that yourself, if desired

lookupTypeHscEnv :: HscEnv -> Name -> IO (Maybe TyThing) #

As `lookupType`, but with a marginally easier-to-use interface if you have a `HscEnv`

mkTypeEnv :: [TyThing] -> TypeEnv #

emptyTypeEnv :: TypeEnv #

typeEnvFromEntities :: [Id] -> [TyCon] -> [FamInst] -> TypeEnv #

mkTypeEnvWithImplicits :: [TyThing] -> TypeEnv #

extendTypeEnv :: TypeEnv -> TyThing -> TypeEnv #

extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv #

extendTypeEnvWithIds :: TypeEnv -> [Id] -> TypeEnv #

plusTypeEnv :: TypeEnv -> TypeEnv -> TypeEnv #

lookupTypeEnv :: TypeEnv -> Name -> Maybe TyThing #

typeEnvElts :: TypeEnv -> [TyThing] #

typeEnvTyCons :: TypeEnv -> [TyCon] #

typeEnvIds :: TypeEnv -> [Id] #

typeEnvPatSyns :: TypeEnv -> [PatSyn] #

typeEnvDataCons :: TypeEnv -> [DataCon] #

typeEnvCoAxioms :: TypeEnv -> [CoAxiom Branched] #

typeEnvClasses :: TypeEnv -> [Class] #

# MonadThings

class Monad m => MonadThings m where #

Class that abstracts out the common ability of the monads in GHC to lookup a `TyThing` in the monadic environment by `Name`. Provides a number of related convenience functions for accessing particular kinds of `TyThing`

Minimal complete definition

lookupThing

Methods

lookupThing :: Name -> m TyThing #

lookupId :: Name -> m Id #

lookupDataCon :: Name -> m DataCon #

lookupTyCon :: Name -> m TyCon #

#### Instances

Instances details

MonadThings CoreM # |
Instance details Defined in GhcPlugins Methods lookupThing :: Name -> CoreM TyThing # lookupId :: Name -> CoreM Id # lookupDataCon :: Name -> CoreM DataCon # lookupTyCon :: Name -> CoreM TyCon #
MonadThings TcS # |
Instance details Defined in TcSMonad Methods lookupThing :: Name -> TcS TyThing # lookupId :: Name -> TcS Id # lookupDataCon :: Name -> TcS DataCon # lookupTyCon :: Name -> TcS TyCon #
MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) # |
Instance details Defined in TcEnv Methods lookupThing :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyThing # lookupId :: Name -> IOEnv (Env TcGblEnv TcLclEnv) Id # lookupDataCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) DataCon # lookupTyCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyCon #
MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) # |
Instance details Defined in DsMonad Methods lookupThing :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyThing # lookupId :: Name -> IOEnv (Env DsGblEnv DsLclEnv) Id # lookupDataCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) DataCon # lookupTyCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyCon #

# Information on imports and exports

type WhetherHasOrphans = Bool #

Records whether a module has orphans. An "orphan" is one of:

- An instance declaration in a module other than the definition module for one of the type constructors or classes in the instance head
- A transformation rule in a module other than the one defining the function in the head of the rule

type IsBootInterface = Bool #

Did this module originate from a *-boot file?

data Usage #

Records modules for which changes may force recompilation of this module See wiki: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/recompilation-avoidance

This differs from Dependencies. A module X may be in the dep_mods of this module (via an import chain) but if we don't use anything from X it won't appear in our Usage

Constructors

UsagePackageModule | Module from another package
Fields usg_mod :: Module External package module depended on usg_mod_hash :: Fingerprint Cached module fingerprint usg_safe :: IsSafeImport Was this module imported as a safe import
UsageHomeModule | Module from the current package | A file upon which the module depends, e.g. a CPP #include, or using TH's `addDependentFile`
Fields usg_mod_name :: ModuleName Name of the module usg_mod_hash :: Fingerprint Cached module fingerprint usg_entities :: [(OccName, Fingerprint)] Entities we depend on, sorted by occurrence name and fingerprinted. NB: usages are for parent names only, e.g. type constructors but not the associated data constructors. usg_exports :: Maybe Fingerprint Fingerprint for the export list of this module, if we directly imported it (and hence we depend on its export list) usg_safe :: IsSafeImport Was this module imported as a safe import
UsageFile |
Fields usg_file_path :: FilePath External file dependency. From a CPP #include or TH addDependentFile. Should be absolute. usg_file_hash :: Fingerprint `Fingerprint` of the file contents.
UsageMergedRequirement | A requirement which was merged into this one.
Fields usg_mod :: Module External package module depended on usg_mod_hash :: Fingerprint Cached module fingerprint

#### Instances

Instances details

Eq Usage # |
Instance details Defined in HscTypes Methods (==) :: Usage -> Usage -> Bool # (/=) :: Usage -> Usage -> Bool #
Binary Usage # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> Usage -> IO () # put :: BinHandle -> Usage -> IO (Bin Usage) # get :: BinHandle -> IO Usage #

data Dependencies #

Dependency information about ALL modules and packages below this one in the import hierarchy.

Invariant: the dependencies of a module `M` never includes `M`.

Invariant: none of the lists contain duplicates.

Constructors

Deps |
Fields dep_mods :: [(ModuleName, IsBootInterface)] All home-package modules transitively below this one I.e. modules that this one imports, or that are in the dep_mods of those directly-imported modules dep_pkgs :: [(InstalledUnitId, Bool)] All packages transitively below this module I.e. packages to which this module's direct imports belong, or that are in the dep_pkgs of those modules The bool indicates if the package is required to be trusted when the module is imported as a safe import (Safe Haskell). See Note [RnNames . Tracking Trust Transitively] dep_orphs :: [Module] Transitive closure of orphan modules (whether home or external pkg). (Possible optimization: don't include family instance orphans as they are anyway included in `dep_finsts`. But then be careful about code which relies on dep_orphs having the complete list!) This does NOT include us, unlike `imp_orphs`. dep_finsts :: [Module] Transitive closure of depended upon modules which contain family instances (whether home or external). This is used by `checkFamInstConsistency`. This does NOT include us, unlike `imp_finsts`. See Note [The type family instance consistency story]. dep_plgins :: [ModuleName] All the plugins used while compiling this module.

#### Instances

Instances details

Eq Dependencies # |
Instance details Defined in HscTypes Methods (==) :: Dependencies -> Dependencies -> Bool # (/=) :: Dependencies -> Dependencies -> Bool #
Binary Dependencies # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> Dependencies -> IO () # put :: BinHandle -> Dependencies -> IO (Bin Dependencies) # get :: BinHandle -> IO Dependencies #

noDependencies :: Dependencies #

updNameCache :: IORef NameCache -> (NameCache -> (NameCache, c)) -> IO c #

type IfaceExport = AvailInfo #

The original names declared of a certain module that are exported

# Warnings

data Warnings #

Warning information for a module

Constructors

NoWarnings | Nothing deprecated
WarnAll WarningTxt | Whole module deprecated
WarnSome [(OccName, WarningTxt)] | Some specific things deprecated

#### Instances

Instances details

Eq Warnings # |
Instance details Defined in HscTypes Methods (==) :: Warnings -> Warnings -> Bool # (/=) :: Warnings -> Warnings -> Bool #
Outputable Warnings # |
Instance details Defined in LoadIface Methods ppr :: Warnings -> SDoc # pprPrec :: Rational -> Warnings -> SDoc #
Binary Warnings # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> Warnings -> IO () # put :: BinHandle -> Warnings -> IO (Bin Warnings) # get :: BinHandle -> IO Warnings #

data WarningTxt #

Warning Text

reason/explanation from a WARNING or DEPRECATED pragma

Constructors

WarningTxt (Located SourceText) [Located StringLiteral] |
DeprecatedTxt (Located SourceText) [Located StringLiteral] |

#### Instances

Instances details

Eq WarningTxt # |
Instance details Defined in BasicTypes Methods (==) :: WarningTxt -> WarningTxt -> Bool # (/=) :: WarningTxt -> WarningTxt -> Bool #
Data WarningTxt # |
Instance details Defined in BasicTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WarningTxt -> c WarningTxt Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WarningTxt Source # toConstr :: WarningTxt -> Constr Source # dataTypeOf :: WarningTxt -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WarningTxt) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WarningTxt) Source # gmapT :: (forall b. Data b => b -> b) -> WarningTxt -> WarningTxt Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WarningTxt -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WarningTxt -> r Source # gmapQ :: (forall d. Data d => d -> u) -> WarningTxt -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> WarningTxt -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> WarningTxt -> m WarningTxt Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WarningTxt -> m WarningTxt Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WarningTxt -> m WarningTxt Source #
Outputable WarningTxt # |
Instance details Defined in BasicTypes Methods ppr :: WarningTxt -> SDoc # pprPrec :: Rational -> WarningTxt -> SDoc #
Binary WarningTxt # |
Instance details Defined in Binary Methods put_ :: BinHandle -> WarningTxt -> IO () # put :: BinHandle -> WarningTxt -> IO (Bin WarningTxt) # get :: BinHandle -> IO WarningTxt #

plusWarns :: Warnings -> Warnings -> Warnings #

# Linker stuff

data Linkable #

Information we can use to dynamically link modules into the compiler

Constructors

LM |
Fields linkableTime :: UTCTime Time at which this linkable was built (i.e. when the bytecodes were produced, or the mod date on the files) linkableModule :: Module The linkable module itself linkableUnlinked :: [Unlinked] Those files and chunks of code we have yet to link. INVARIANT: A valid linkable always has at least one `Unlinked` item. If this list is empty, the Linkable represents a fake linkable, which is generated in HscNothing mode to avoid recompiling modules. ToDo: Do items get removed from this list when they get linked?

#### Instances

Instances details

Outputable Linkable # |
Instance details Defined in LinkerTypes Methods ppr :: Linkable -> SDoc # pprPrec :: Rational -> Linkable -> SDoc #

isObjectLinkable :: Linkable -> Bool #

linkableObjs :: Linkable -> [FilePath] #

data Unlinked #

Objects which have yet to be linked by the compiler

Constructors

DotO FilePath | An object file (.o)
DotA FilePath | Static archive file (.a)
DotDLL FilePath | Dynamically linked library file (.so, .dll, .dylib)
BCOs CompiledByteCode [SptEntry] | A byte-code object, lives only in memory. Also carries some static pointer table entries which should be loaded along with the BCOs. See Note [Grant plan for static forms] in StaticPtrTable.

#### Instances

Instances details

Outputable Unlinked # |
Instance details Defined in LinkerTypes Methods ppr :: Unlinked -> SDoc # pprPrec :: Rational -> Unlinked -> SDoc #

data CompiledByteCode #

#### Instances

Instances details

Outputable CompiledByteCode # |
Instance details Defined in ByteCodeTypes Methods ppr :: CompiledByteCode -> SDoc # pprPrec :: Rational -> CompiledByteCode -> SDoc #

isObject :: Unlinked -> Bool #

Is this an actual file on disk we can link in somehow?

nameOfObject :: Unlinked -> FilePath #

Retrieve the filename of the linkable if possible. Panic if it is a byte-code object

isInterpretable :: Unlinked -> Bool #

Is this a bytecode linkable with no file on disk?

byteCodeOfObject :: Unlinked -> CompiledByteCode #

Retrieve the compiled byte-code if possible. Panic if it is a file-based linkable

# Program coverage

data HpcInfo #

Information about a modules use of Haskell Program Coverage

Constructors

HpcInfo |
Fields hpcInfoTickCount :: Int hpcInfoHash :: Int
NoHpcInfo |
Fields hpcUsed :: AnyHpcUsage Is hpc used anywhere on the module *tree*?

emptyHpcInfo :: AnyHpcUsage -> HpcInfo #

isHpcUsed :: HpcInfo -> AnyHpcUsage #

Find out if HPC is used by this module or any of the modules it depends upon

type AnyHpcUsage = Bool #

This is used to signal if one of my imports used HPC instrumentation even if there is no module-local HPC usage

# Breakpoints

data ModBreaks #

All the information about the breakpoints for a module

Constructors

ModBreaks |
Fields modBreaks_flags :: ForeignRef BreakArray The array of flags, one per breakpoint, indicating which breakpoints are enabled. modBreaks_locs :: !(Array BreakIndex SrcSpan) An array giving the source span of each breakpoint. modBreaks_vars :: !(Array BreakIndex [OccName]) An array giving the names of the free variables at each breakpoint. modBreaks_decls :: !(Array BreakIndex [String]) An array giving the names of the declarations enclosing each breakpoint. modBreaks_ccs :: !(Array BreakIndex (RemotePtr CostCentre)) Array pointing to cost centre for each breakpoint modBreaks_breakInfo :: IntMap CgBreakInfo info about each breakpoint from the bytecode generator

emptyModBreaks :: ModBreaks #

Construct an empty ModBreaks

# Safe Haskell information

data IfaceTrustInfo #

Safe Haskell information for `ModIface` Simply a wrapper around SafeHaskellMode to sepperate iface and flags

#### Instances

Instances details

Outputable IfaceTrustInfo # |
Instance details Defined in HscTypes Methods ppr :: IfaceTrustInfo -> SDoc # pprPrec :: Rational -> IfaceTrustInfo -> SDoc #
Binary IfaceTrustInfo # |
Instance details Defined in HscTypes Methods put_ :: BinHandle -> IfaceTrustInfo -> IO () # put :: BinHandle -> IfaceTrustInfo -> IO (Bin IfaceTrustInfo) # get :: BinHandle -> IO IfaceTrustInfo #

getSafeMode :: IfaceTrustInfo -> SafeHaskellMode #

setSafeMode :: SafeHaskellMode -> IfaceTrustInfo #

noIfaceTrustInfo :: IfaceTrustInfo #

trustInfoToNum :: IfaceTrustInfo -> Word8 #

numToTrustInfo :: Word8 -> IfaceTrustInfo #

type IsSafeImport = Bool #

Is an import a safe import?

# result of the parser

data HsParsedModule #

Constructors

HsParsedModule |
Fields hpm_module :: Located (HsModule GhcPs) hpm_src_files :: [FilePath] extra source files (e.g. from #includes). The lexer collects these from '# file line' pragmas, which the C preprocessor leaves behind. These files and their timestamps are stored in the .hi file, so that we can force recompilation if any of them change (#3589) hpm_annotations :: ApiAnns

# Compilation errors and warnings

data SourceError #

A source error is an error that is caused by one or more errors in the source code. A `SourceError` is thrown by many functions in the compilation pipeline. Inside GHC these errors are merely printed via `log_action`, but API clients may treat them differently, for example, insert them into a list box. If you want the default behaviour, use the idiom:

    handleSourceError printExceptionAndWarnings $ do
      ... api calls that may fail ...

The `SourceError`s error messages can be accessed via `srcErrorMessages`. This list may be empty if the compiler failed due to `-Werror` (`Opt_WarnIsError`).

See `printExceptionAndWarnings` for more information on what to take care of when writing a custom error handler.

#### Instances

Instances details

Show SourceError # |
Instance details Defined in HscTypes Methods showsPrec :: Int -> SourceError -> ShowS Source # show :: SourceError -> String Source # showList :: [SourceError] -> ShowS Source #
Exception SourceError # |
Instance details Defined in HscTypes Methods toException :: SourceError -> SomeException Source # fromException :: SomeException -> Maybe SourceError Source # displayException :: SourceError -> String Source #

data GhcApiError #

An error thrown if the GHC API is used in an incorrect fashion.

#### Instances

Instances details

Show GhcApiError # |
Instance details Defined in HscTypes Methods showsPrec :: Int -> GhcApiError -> ShowS Source # show :: GhcApiError -> String Source # showList :: [GhcApiError] -> ShowS Source #
Exception GhcApiError # |
Instance details Defined in HscTypes Methods toException :: GhcApiError -> SomeException Source # fromException :: SomeException -> Maybe GhcApiError Source # displayException :: GhcApiError -> String Source #

mkSrcErr :: ErrorMessages -> SourceError #

srcErrorMessages :: SourceError -> ErrorMessages #

mkApiErr :: DynFlags -> SDoc -> GhcApiError #

throwOneError :: MonadIO io => ErrMsg -> io a #

throwErrors :: MonadIO io => ErrorMessages -> io a #

handleSourceError #

Arguments

:: ExceptionMonad m |
=> (SourceError -> m a) | exception handler
-> m a | action to perform
-> m a |

Perform the given action and call the exception handler if the action throws a `SourceError`. See `SourceError` for more information.

handleFlagWarnings :: DynFlags -> [Warn] -> IO () #

printOrThrowWarnings :: DynFlags -> Bag WarnMsg -> IO () #

Given a bag of warnings, turn them into an exception if -Werror is enabled, or print them out otherwise.

# COMPLETE signature

data CompleteMatch #

A list of conlikes which represents a complete pattern match. These arise from `COMPLETE` signatures.

Constructors

CompleteMatch |
Fields completeMatchConLikes :: [Name] The ConLikes that form a covering family (e.g. Nothing, Just) completeMatchTyCon :: Name The TyCon that they cover (e.g. Maybe)

#### Instances

Instances details

Outputable CompleteMatch # |
Instance details Defined in HscTypes Methods ppr :: CompleteMatch -> SDoc # pprPrec :: Rational -> CompleteMatch -> SDoc #

type CompleteMatchMap = UniqFM [CompleteMatch] #

A map keyed by the `completeMatchTyCon`.

mkCompleteMatchMap :: [CompleteMatch] -> CompleteMatchMap #

extendCompleteMatchMap :: CompleteMatchMap -> [CompleteMatch] -> CompleteMatchMap #