import HsSyn ( IE(..), ieName, ImportDecl(..), LImportDecl,
ForeignDecl(..), HsGroup(..), HsValBinds(..),
Sig(..), collectHsBindLocatedBinders, tyClDeclNames,
import HsSyn ( IE(..), ieName, ImportDecl(..), LImportDecl,
ForeignDecl(..), HsGroup(..), HsValBinds(..),
Sig(..), collectHsBindLocatedBinders, tyClDeclNames,
= do { main_name <- lookupFamInstDeclBndr mod main_rdr
; sub_names <- mappM (newTopSrcBinder mod) sub_rdrs
; return (AvailTC main_name sub_names) }
= do { main_name <- lookupFamInstDeclBndr mod main_rdr
; sub_names <- mappM (newTopSrcBinder mod) sub_rdrs
; return (AvailTC main_name sub_names) }
warnDuplicateImports gres
= ifOptM Opt_WarnUnusedImports $
sequenceM_ [ warn name pr
warnDuplicateImports gres
= ifOptM Opt_WarnUnusedImports $
sequenceM_ [ warn name pr
| GRE { gre_name = name, gre_prov = Imported imps } <- gres
, pr <- redundants imps ]
where
| GRE { gre_name = name, gre_prov = Imported imps } <- gres
, pr <- redundants imps ]
where
= False -- They bring into scope different qualified names
| not (is_qual red_decl) && is_qual cov_decl
= False -- Covering one doesn't bring unqualified name into scope
= False -- They bring into scope different qualified names
| not (is_qual red_decl) && is_qual cov_decl
= False -- Covering one doesn't bring unqualified name into scope
| red_selective
= not cov_selective -- Redundant one is selective and covering one isn't
|| red_later -- Both are explicit; tie-break using red_later
| red_selective
= not cov_selective -- Redundant one is selective and covering one isn't
|| red_later -- Both are explicit; tie-break using red_later
= not cov_selective -- Neither import is selective
&& (is_mod red_decl == is_mod cov_decl) -- They import the same module
&& red_later -- Tie-break
= not cov_selective -- Neither import is selective
&& (is_mod red_decl == is_mod cov_decl) -- They import the same module
&& red_later -- Tie-break
where
red_loc = importSpecLoc red_imp
cov_loc = importSpecLoc cov_imp
red_later = red_loc > cov_loc
where
red_loc = importSpecLoc red_imp
cov_loc = importSpecLoc cov_imp
red_later = red_loc > cov_loc
- cov_selective = selectiveImpItem cov_item
- red_selective = selectiveImpItem red_item
-
-selectiveImpItem :: ImpItemSpec -> Bool
-selectiveImpItem ImpAll = False
-selectiveImpItem (ImpSome {}) = True
-- ToDo: deal with original imports with 'qualified' and 'as M' clauses
printMinimalImports :: FiniteMap ModuleName AvailEnv -- Minimal imports
-- ToDo: deal with original imports with 'qualified' and 'as M' clauses
printMinimalImports :: FiniteMap ModuleName AvailEnv -- Minimal imports