- | otherwise = mapMaybe prune avails
-
- prune (Avail n) | unqual_in_scope n = Just (Avail n)
- | otherwise = Nothing
- prune (AvailTC n ns) | null uqs = Nothing
- | otherwise = Just (AvailTC n uqs)
- where
- uqs = filter unqual_in_scope ns
-
- unqual_in_scope n = unQualInScope gbl_env n
-
-
- entity_avail_env = mkNameEnv ([ (availName avail,avail) | avail <- effective_avails ] ++
- -- sigh - need to have the method/field names in
- -- the environment also, so that export lists
- -- can be computed precisely (cf. exportsFromAvail)
- [ (name,avail) | avail <- effective_avails,
- name <- avNames avail ] )
-
- avNames (Avail n) = [n]
- avNames (AvailTC n ns) = filter (/=n) ns
-
- -- remove 'hides' names from the avail list.
- effective_avails = foldl wipeOut avails hides
- where
- wipeOut as (Avail n) = mapMaybe (delName n) as
- wipeOut as (AvailTC n ns) = foldl wipeOut as (map Avail ns)
-
- delName x a@(Avail n)
- | n == x = Nothing
- | otherwise = Just a
- delName x (AvailTC n ns)
- = case (filter (/=x) ns) of
- [] -> Nothing
- xs -> Just (AvailTC n xs)
-
-plusExportAvails :: ExportAvails -> ExportAvails -> ExportAvails
-plusExportAvails (m1, e1) (m2, e2)
- = (plusFM_C (++) m1 m2, plusAvailEnv e1 e2)
- -- ToDo: wasteful: we do this once for each constructor!
+ | otherwise = pruneAvails (unQualInScope gbl_env) 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