File: Imported.hs

package info (click to toggle)
haskell-ghc-lib-parser 9.6.6.20240701-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,280 kB
  • sloc: haskell: 109,582; yacc: 3,744; ansic: 2,480; makefile: 12
file content (54 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download | duplicates (2)
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
   }