import RnMonad
import FiniteMap
-import PrelNames ( pRELUDE_Name, mAIN_Name, main_RDR_Unqual, isUnboundName )
+import PrelNames ( pRELUDE_Name, mAIN_Name, isUnboundName )
import Module ( ModuleName, moduleName, WhereFrom(..) )
import Name ( Name, nameSrcLoc, nameOccName )
import NameSet
import OccName ( setOccNameSpace, dataName )
import NameSet ( elemNameSet, emptyNameSet )
import Outputable
-import Maybes ( maybeToBool, catMaybes, mapMaybe )
+import Maybes ( maybeToBool, catMaybes )
import ListSetOps ( removeDups )
import Util ( sortLt )
import List ( partition )
new (rdr_name, loc) = newTopBinder mod rdr_name loc `thenRn` \ name ->
returnRn (Avail name)
-getLocalDeclBinders mod (ForD (ForeignImport nm _ _ loc))
+getLocalDeclBinders mod (ForD (ForeignImport nm _ _ _ loc))
= newTopBinder mod nm loc `thenRn` \ name ->
returnRn [Avail name]
getLocalDeclBinders mod (ForD _)
returnRn []
get_item :: RdrNameIE -> RnMG [(AvailInfo, [Name])]
+ -- Empty list for a bad item.
+ -- Singleton is typical case.
+ -- Can have two when we are hiding, and mention C which might be
+ -- both a class and a data constructor.
+ -- The [Name] is the list of explicitly-mentioned names
get_item item@(IEModuleContents _) = bale_out item
get_item item@(IEThingAll _)
unqual_avails | not unqual_imp = [] -- Short cut when no unqualified imports
| otherwise = pruneAvails (unQualInScope gbl_env) avails
- entity_avail_env = mkNameEnv [(availName avail, avail) | avail <- avails]
+ entity_avail_env = foldl insert emptyAvailEnv avails
+ insert env avail = extendNameEnv_C plusAvail env (availName avail) avail
+ -- 'avails' may have several items with the same availName
+ -- E.g import Ix( Ix(..), index )
+ -- will give Ix(Ix,index,range) and Ix(index)
+ -- We want to combine these
\end{code}
-- Complains about exports items not in scope
exportsFromAvail this_mod Nothing
mod_avail_env entity_avail_env global_name_env
- = exportsFromAvail this_mod true_exports mod_avail_env entity_avail_env global_name_env
+ = exportsFromAvail this_mod (Just true_exports) mod_avail_env
+ entity_avail_env global_name_env
where
- true_exports = Just $ if this_mod == mAIN_Name
- then [IEVar main_RDR_Unqual]
- -- export Main.main *only* unless otherwise specified,
- else [IEModuleContents this_mod]
- -- but for all other modules export everything.
+ true_exports
+ | this_mod == mAIN_Name = []
+ -- Export nothing; Main.$main is automatically exported
+ | otherwise = [IEModuleContents this_mod]
+ -- but for all other modules export everything.
exportsFromAvail this_mod (Just export_items)
mod_avail_env entity_avail_env global_name_env