%
\begin{code}
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
module MkIface (
mkUsageInfo, -- Construct the usage info for a module
\begin{code}
mkUsageInfo :: HscEnv
- -> ModuleEnv (Module, Bool, SrcSpan)
+ -> ModuleEnv (Module, [(ModuleName, Bool, SrcSpan)])
-> [(ModuleName, IsBootInterface)]
-> NameSet -> IO [Usage]
mkUsageInfo hsc_env dir_imp_mods dep_mods used_names
-- don't get evaluated for a while and we can end up hanging on to
-- the entire collection of Ifaces.
+mk_usage_info :: PackageIfaceTable
+ -> HscEnv
+ -> ModuleEnv (Module, [(ModuleName, Bool, SrcSpan)])
+ -> [(ModuleName, IsBootInterface)]
+ -> NameSet
+ -> [Usage]
mk_usage_info pit hsc_env dir_imp_mods dep_mods used_names
= mapCatMaybes mkUsage dep_mods
-- ToDo: do we need to sort into canonical order?
add_item occs _ = occ:occs
depend_on_exports mod = case lookupModuleEnv dir_imp_mods mod of
- Just (_,no_imp,_) -> not no_imp
- Nothing -> True
+ Just (_, xs) -> any (\(_, no_imp, _) -> not no_imp) xs
+ Nothing -> True
-- We want to create a Usage for a home module if
-- a) we used something from; has something in used_names
-- Usually just one, but see Note [Original module]
add_for_mod env mod
- = add_one env mod (AvailTC tc_occ names_from_mod)
+ = add_one env mod (AvailTC tc_occ (sort names_from_mod))
+ -- NB. sort the children, we need a canonical order
where
names_from_mod = [nameOccName n | n <- ns, nameModule n == mod]
\end{code}
ifConUnivTvs = toIfaceTvBndrs (dataConUnivTyVars data_con),
ifConExTvs = toIfaceTvBndrs (dataConExTyVars data_con),
ifConEqSpec = to_eq_spec (dataConEqSpec data_con),
- ifConCtxt = toIfaceContext (dataConTheta data_con),
+ ifConCtxt = toIfaceContext (dataConEqTheta data_con ++ dataConDictTheta data_con),
ifConArgTys = map toIfaceType (dataConOrigArgTys data_con),
ifConFields = map getOccName
(dataConFieldLabels data_con),