GHC.Unit.Finder

ghc-9.4.0.20220501: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Unit.Finder

Description

Module finder

Synopsis

- data FindResult
  - = Found ModLocation Module
  - | NoPackage Unit
  - | FoundMultiple [(Module, ModuleOrigin)]
  - | NotFound {
    - fr_paths :: [FilePath]
    - fr_pkg :: Maybe Unit
    - fr_mods_hidden :: [Unit]
    - fr_pkgs_hidden :: [Unit]
    - fr_unusables :: [(Unit, UnusableUnitReason)]
    - fr_suggestions :: [ModuleSuggestion]
    }
- data InstalledFindResult
  - = InstalledFound ModLocation InstalledModule
  - | InstalledNoPackage UnitId
  - | InstalledNotFound [FilePath] (Maybe UnitId)
- data FinderOpts = FinderOpts {
  - finder_importPaths :: [FilePath]
  - finder_lookupHomeInterfaces :: Bool
  - finder_bypassHiFileCheck :: Bool
  - finder_ways :: Ways
  - finder_enableSuggestions :: Bool
  - finder_workingDirectory :: Maybe FilePath
  - finder_thisPackageName :: Maybe FastString
  - finder_hiddenModules :: Set ModuleName
  - finder_reexportedModules :: Set ModuleName
  - finder_hieDir :: Maybe FilePath
  - finder_hieSuf :: String
  - finder_hiDir :: Maybe FilePath
  - finder_hiSuf :: String
  - finder_dynHiSuf :: String
  - finder_objectDir :: Maybe FilePath
  - finder_objectSuf :: String
  - finder_dynObjectSuf :: String
  - finder_stubDir :: Maybe FilePath
  }
- data FinderCache
- initFinderCache :: IO FinderCache
- flushFinderCaches :: FinderCache -> UnitEnv -> IO ()
- findImportedModule :: HscEnv -> ModuleName -> PkgQual -> IO FindResult
- findPluginModule :: FinderCache -> FinderOpts -> UnitState -> Maybe HomeUnit -> ModuleName -> IO FindResult
- findExactModule :: FinderCache -> FinderOpts -> UnitEnvGraph FinderOpts -> UnitState -> Maybe HomeUnit -> InstalledModule -> IO InstalledFindResult
- findHomeModule :: FinderCache -> FinderOpts -> HomeUnit -> ModuleName -> IO FindResult
- findExposedPackageModule :: FinderCache -> FinderOpts -> UnitState -> ModuleName -> PkgQual -> IO FindResult
- mkHomeModLocation :: FinderOpts -> ModuleName -> FilePath -> ModLocation
- mkHomeModLocation2 :: FinderOpts -> ModuleName -> FilePath -> String -> ModLocation
- mkHiOnlyModLocation :: FinderOpts -> Suffix -> Suffix -> FilePath -> String -> ModLocation
- mkHiPath :: FinderOpts -> FilePath -> String -> FilePath
- mkObjPath :: FinderOpts -> FilePath -> String -> FilePath
- addModuleToFinder :: FinderCache -> Module -> ModLocation -> IO ()
- addHomeModuleToFinder :: FinderCache -> HomeUnit -> ModuleName -> ModLocation -> IO Module
- uncacheModule :: FinderCache -> HomeUnit -> ModuleName -> IO ()
- mkStubPaths :: FinderOpts -> ModuleName -> ModLocation -> FilePath
- findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable)
- findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable
- lookupFileCache :: FinderCache -> FilePath -> IO Fingerprint

# Documentation

data FindResult Source #

The result of searching for an imported module.

NB: FindResult manages both user source-import lookups (which can result in `GenModule`) as well as direct imports for interfaces (which always result in `InstalledModule`).

Constructors

Found ModLocation Module | The module was found
NoPackage Unit | The requested unit was not found
FoundMultiple [(Module, ModuleOrigin)] | _Error_: both in multiple packages
NotFound | Not found
Fields fr_paths :: [FilePath] Places where I looked fr_pkg :: Maybe Unit Just p => module is in this unit's manifest, but couldn't find the .hi file fr_mods_hidden :: [Unit] Module is in these units, but the *module* is hidden fr_pkgs_hidden :: [Unit] Module is in these units, but the *unit* is hidden fr_unusables :: [(Unit, UnusableUnitReason)] Module is in these units, but it is unusable fr_suggestions :: [ModuleSuggestion] Possible mis-spelled modules

data InstalledFindResult Source #

Constructors

InstalledFound ModLocation InstalledModule |
InstalledNoPackage UnitId |
InstalledNotFound [FilePath] (Maybe UnitId) |

data FinderOpts Source #

Locations and information the finder cares about.

Should be taken from `DynFlags` via `initFinderOpts`.

Constructors

FinderOpts |
Fields finder_importPaths :: [FilePath] Where are we allowed to look for Modules and Source files finder_lookupHomeInterfaces :: Bool When looking up a home module: `True`: search interface files (e.g. in '-c' mode) `False`: search source files (e.g. in '--make' mode) finder_bypassHiFileCheck :: Bool Don't check that an imported interface file actually exists if it can only be at one location. The interface will be reported as `InstalledFound` even if the file doesn't exist, so this is only useful in specific cases (e.g. to generate dependencies with `ghc -M`) finder_ways :: Ways finder_enableSuggestions :: Bool If we encounter unknown modules, should we suggest modules that have a similar name. finder_workingDirectory :: Maybe FilePath finder_thisPackageName :: Maybe FastString finder_hiddenModules :: Set ModuleName finder_reexportedModules :: Set ModuleName finder_hieDir :: Maybe FilePath finder_hieSuf :: String finder_hiDir :: Maybe FilePath finder_hiSuf :: String finder_dynHiSuf :: String finder_objectDir :: Maybe FilePath finder_objectSuf :: String finder_dynObjectSuf :: String finder_stubDir :: Maybe FilePath

#### Instances

Instances details

Show FinderOpts Source # |
Instance details Defined in GHC.Unit.Finder.Types Methods showsPrec :: Int -> FinderOpts -> ShowS Source # show :: FinderOpts -> String Source # showList :: [FinderOpts] -> ShowS Source #

data FinderCache Source #

initFinderCache :: IO FinderCache Source #

flushFinderCaches :: FinderCache -> UnitEnv -> IO () Source #

findImportedModule :: HscEnv -> ModuleName -> PkgQual -> IO FindResult Source #

Locate a module that was imported by the user. We have the module's name, and possibly a package name. Without a package name, this function will use the search path and the known exposed packages to find the module, if a package is specified then only that package is searched for the module.

findPluginModule :: FinderCache -> FinderOpts -> UnitState -> Maybe HomeUnit -> ModuleName -> IO FindResult Source #

Locate a plugin module requested by the user, for a compiler plugin. This consults the same set of exposed packages as `findImportedModule`, unless `-hide-all-plugin-packages` or `-plugin-package` are specified.

findExactModule :: FinderCache -> FinderOpts -> UnitEnvGraph FinderOpts -> UnitState -> Maybe HomeUnit -> InstalledModule -> IO InstalledFindResult Source #

Locate a specific `GenModule`. The purpose of this function is to create a `ModLocation` for a given `GenModule`, that is to find out where the files associated with this module live. It is used when reading the interface for a module mentioned by another interface, for example (a "system import").

findHomeModule :: FinderCache -> FinderOpts -> HomeUnit -> ModuleName -> IO FindResult Source #

findExposedPackageModule :: FinderCache -> FinderOpts -> UnitState -> ModuleName -> PkgQual -> IO FindResult Source #

mkHomeModLocation :: FinderOpts -> ModuleName -> FilePath -> ModLocation Source #

mkHomeModLocation2 :: FinderOpts -> ModuleName -> FilePath -> String -> ModLocation Source #

mkHiOnlyModLocation :: FinderOpts -> Suffix -> Suffix -> FilePath -> String -> ModLocation Source #

mkHiPath :: FinderOpts -> FilePath -> String -> FilePath Source #

Constructs the filename of a .hi file for a given source file. Does not check whether the .hi file exists

mkObjPath :: FinderOpts -> FilePath -> String -> FilePath Source #

Constructs the filename of a .o file for a given source file. Does not check whether the .o file exists

addModuleToFinder :: FinderCache -> Module -> ModLocation -> IO () Source #

addHomeModuleToFinder :: FinderCache -> HomeUnit -> ModuleName -> ModLocation -> IO Module Source #

uncacheModule :: FinderCache -> HomeUnit -> ModuleName -> IO () Source #

mkStubPaths :: FinderOpts -> ModuleName -> ModLocation -> FilePath Source #

findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable) Source #

findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable Source #

lookupFileCache :: FinderCache -> FilePath -> IO Fingerprint Source #