GHC.Unit.Finder

ghc-9.2.0.20210422: 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)
- type FinderCache = InstalledModuleEnv InstalledFindResult
- flushFinderCaches :: HscEnv -> IO ()
- findImportedModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult
- findPluginModule :: HscEnv -> ModuleName -> IO FindResult
- findExactModule :: HscEnv -> InstalledModule -> IO InstalledFindResult
- findHomeModule :: HscEnv -> ModuleName -> IO FindResult
- findExposedPackageModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult
- mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO ModLocation
- mkHomeModLocation2 :: DynFlags -> ModuleName -> FilePath -> String -> IO ModLocation
- mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String -> IO ModLocation
- mkHiPath :: DynFlags -> FilePath -> String -> FilePath
- mkObjPath :: DynFlags -> FilePath -> String -> FilePath
- addHomeModuleToFinder :: HscEnv -> ModuleName -> ModLocation -> IO Module
- uncacheModule :: HscEnv -> ModuleName -> IO ()
- mkStubPaths :: DynFlags -> ModuleName -> ModLocation -> FilePath
- findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable)
- findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable

# Documentation

data FindResult Source #

The result of searching for an imported module.

NB: FindResult manages both user source-import lookups (which can result in `Module`) 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) |

type FinderCache = InstalledModuleEnv InstalledFindResult Source #

The `FinderCache` maps modules to the result of searching for that module. It records the results of searching for modules along the search path. On `:load`, we flush the entire contents of this cache.

flushFinderCaches :: HscEnv -> IO () Source #

findImportedModule :: HscEnv -> ModuleName -> Maybe FastString -> 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 :: HscEnv -> 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 :: HscEnv -> InstalledModule -> IO InstalledFindResult Source #

Locate a specific `Module`. The purpose of this function is to create a `ModLocation` for a given `Module`, 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 :: HscEnv -> ModuleName -> IO FindResult Source #

findExposedPackageModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult Source #

mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO ModLocation Source #

mkHomeModLocation2 :: DynFlags -> ModuleName -> FilePath -> String -> IO ModLocation Source #

mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String -> IO ModLocation Source #

mkHiPath :: DynFlags -> 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 :: DynFlags -> FilePath -> String -> FilePath Source #

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

addHomeModuleToFinder :: HscEnv -> ModuleName -> ModLocation -> IO Module Source #

uncacheModule :: HscEnv -> ModuleName -> IO () Source #

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

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

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