1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
module GHC.Unit.Module.Imported
( ImportedMods
, ImportedBy (..)
, ImportedModsVal (..)
, importedByUser
)
where
import GHC.Prelude
import GHC.Unit.Module
import GHC.Types.Name.Reader
import GHC.Types.SafeHaskell
import GHC.Types.SrcLoc
-- | Records the modules directly imported by a module for extracting e.g.
-- usage information, and also to give better error message
type ImportedMods = ModuleEnv [ImportedBy]
-- | If a module was "imported" by the user, we associate it with
-- more detailed usage information 'ImportedModsVal'; a module
-- imported by the system only gets used for usage information.
data ImportedBy
= ImportedByUser ImportedModsVal
| ImportedBySystem
importedByUser :: [ImportedBy] -> [ImportedModsVal]
importedByUser (ImportedByUser imv : bys) = imv : importedByUser bys
importedByUser (ImportedBySystem : bys) = importedByUser bys
importedByUser [] = []
data ImportedModsVal = ImportedModsVal
{ imv_name :: ModuleName
-- ^ The name the module is imported with
, imv_span :: SrcSpan
-- ^ the source span of the whole import
, imv_is_safe :: IsSafeImport
-- ^ whether this is a safe import
, imv_is_hiding :: Bool
-- ^ whether this is an "hiding" import
, imv_all_exports :: !GlobalRdrEnv
-- ^ all the things the module could provide.
--
-- NB. BangPattern here: otherwise this leaks. (#15111)
, imv_qualified :: Bool
-- ^ whether this is a qualified import
}
|