+
+\begin{code}
+lookupTypeEnv :: SymbolTable -> Name -> Maybe TyThing
+lookupTypeEnv tbl name
+ = case lookupModuleEnv tbl (nameModule name) of
+ Just details -> lookupNameEnv (md_types details) name
+ Nothing -> Nothing
+
+
+groupTyThings :: [TyThing] -> FiniteMap Module TypeEnv
+ -- Finite map because we want the range too
+groupTyThings things
+ = foldl add emptyFM things
+ where
+ add :: FiniteMap Module TypeEnv -> TyThing -> FiniteMap Module TypeEnv
+ add tbl thing = addToFM tbl mod new_env
+ where
+ name = getName thing
+ mod = nameModule name
+ new_env = case lookupFM tbl mod of
+ Nothing -> unitNameEnv name thing
+ Just env -> extendNameEnv env name thing
+
+extendTypeEnv :: SymbolTable -> FiniteMap Module TypeEnv -> SymbolTable
+extendTypeEnv tbl things
+ = foldFM add tbl things
+ where
+ add mod type_env tbl
+ = panic "extendTypeEnv" --extendModuleEnv mod new_details
+ where
+ new_details
+ = case lookupModuleEnv tbl mod of
+ Nothing -> emptyModDetails {md_types = type_env}
+ Just details -> details {md_types = md_types details
+ `plusNameEnv` type_env}
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{Auxiliary types}
+%* *
+%************************************************************************
+
+These types are defined here because they are mentioned in ModDetails,
+but they are mostly elaborated elsewhere
+
+\begin{code}
+data VersionInfo
+ = VersionInfo {
+ vers_module :: Version, -- Changes when anything changes
+ vers_exports :: Version, -- Changes when export list changes
+ vers_rules :: Version, -- Changes when any rule changes
+ vers_decls :: NameEnv Version
+ -- Versions for "big" names only (not data constructors, class ops)
+ -- The version of an Id changes if its fixity changes
+ -- Ditto data constructors, class operations, except that the version of
+ -- the parent class/tycon changes
+ }
+
+initialVersionInfo :: VersionInfo
+initialVersionInfo = VersionInfo { vers_module = initialVersion,
+ vers_exports = initialVersion,
+ vers_rules = initialVersion,
+ vers_decls = emptyNameEnv }
+
+data Deprecations = NoDeprecs
+ | DeprecAll DeprecTxt -- Whole module deprecated
+ | DeprecSome (NameEnv DeprecTxt) -- Some things deprecated
+ -- Just "big" names
+
+lookupDeprec :: ModIface -> Name -> Maybe DeprecTxt
+lookupDeprec iface name
+ = case mi_deprecs iface of
+ NoDeprecs -> Nothing
+ DeprecAll txt -> Just txt
+ DeprecSome env -> lookupNameEnv env name
+
+type InstEnv = UniqFM ClsInstEnv -- Maps Class to instances for that class
+type ClsInstEnv = [(TyVarSet, [Type], DFunId)] -- The instances for a particular class
+type DFunId = Id
+
+type RuleEnv = NameEnv [CoreRule]
+
+emptyRuleEnv = emptyVarEnv
+\end{code}
+
+
+\begin{code}
+type Avails = [AvailInfo]
+type AvailInfo = GenAvailInfo Name
+type RdrAvailInfo = GenAvailInfo OccName