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