modInfoTopLevelScope,
modInfoPrintUnqualified,
modInfoExports,
+ modInfoInstances,
modInfoIsExportedName,
modInfoLookupName,
lookupGlobalName,
Class,
classSCTheta, classTvsFds,
+ -- ** Instances
+ Instance,
+
-- ** Types and Kinds
Type, dropForAlls,
Kind,
import DataCon ( DataCon )
import Name ( Name, nameModule )
import NameEnv ( nameEnvElts )
+import InstEnv ( Instance )
import SrcLoc ( Located(..) )
import DriverPipeline
import DriverPhases ( Phase(..), isHaskellSrcFilename, startPhase )
typecheckedSource :: Maybe TypecheckedSource,
checkedModuleInfo :: Maybe ModuleInfo
}
+ -- ToDo: improvements that could be made here:
+ -- if the module succeeded renaming but not typechecking,
+ -- we can still get back the GlobalRdrEnv and exports, so
+ -- perhaps the ModuleInfo should be split up into separate
+ -- fields within CheckedModule.
type ParsedSource = Located (HsModule RdrName)
type RenamedSource = HsGroup Name
HscChecked parsed renamed
(Just (tc_binds, rdr_env, details)) -> do
let minf = ModuleInfo {
- minf_type_env = md_types details,
- minf_exports = md_exports details,
- minf_rdr_env = Just rdr_env
+ minf_type_env = md_types details,
+ minf_exports = md_exports details,
+ minf_rdr_env = Just rdr_env,
+ minf_instances = md_insts details
}
return (Just (CheckedModule {
parsedSource = parsed,
-- | Container for information about a 'Module'.
data ModuleInfo = ModuleInfo {
- minf_type_env :: TypeEnv,
- minf_exports :: NameSet,
- minf_rdr_env :: Maybe GlobalRdrEnv
- }
+ minf_type_env :: TypeEnv,
+ minf_exports :: NameSet,
+ minf_rdr_env :: Maybe GlobalRdrEnv, -- Nothing for a compiled/package mod
+ minf_instances :: [Instance]
-- ToDo: this should really contain the ModIface too
+ }
-- We don't want HomeModInfo here, because a ModuleInfo applies
-- to package modules too.
Just ty <- [lookupTypeEnv pte name] ]
--
return (Just (ModuleInfo {
- minf_type_env = mkTypeEnv tys,
- minf_exports = names,
- minf_rdr_env = Just $! nameSetToGlobalRdrEnv names mdl
+ minf_type_env = mkTypeEnv tys,
+ minf_exports = names,
+ minf_rdr_env = Just $! nameSetToGlobalRdrEnv names mdl,
+ minf_instances = error "getModuleInfo: instances for package module unimplemented"
}))
#else
-- bogusly different for non-GHCI (ToDo)
Just hmi ->
let details = hm_details hmi in
return (Just (ModuleInfo {
- minf_type_env = md_types details,
- minf_exports = md_exports details,
- minf_rdr_env = mi_globals $! hm_iface hmi
+ minf_type_env = md_types details,
+ minf_exports = md_exports details,
+ minf_rdr_env = mi_globals $! hm_iface hmi,
+ minf_instances = md_insts details
}))
-- ToDo: we should be able to call getModuleInfo on a package module,
modInfoExports :: ModuleInfo -> [Name]
modInfoExports minf = nameSetToList $! minf_exports minf
+-- | Returns the instances defined by the specified module.
+-- Warning: currently unimplemented for package modules.
+modInfoInstances :: ModuleInfo -> [Instance]
+modInfoInstances = minf_instances
+
modInfoIsExportedName :: ModuleInfo -> Name -> Bool
modInfoIsExportedName minf name = elemNameSet name (minf_exports minf)