ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Unit.Finder.Types

Synopsis

- data FinderCache = FinderCache {
  - flushFinderCaches :: UnitEnv -> IO ()
  - addToFinderCache :: InstalledModule -> InstalledFindResult -> IO ()
  - lookupFinderCache :: InstalledModule -> IO (Maybe InstalledFindResult)
  - lookupFileCache :: FilePath -> IO Fingerprint
  }
- type FinderCacheState = InstalledModuleEnv InstalledFindResult
- type FileCacheState = Map FilePath Fingerprint
- 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 :: [UnusableUnit]
    - fr_suggestions :: [ModuleSuggestion]
    }
- data InstalledFindResult
  - = InstalledFound ModLocation
  - | InstalledNoPackage UnitId
  - | InstalledNotFound [OsPath] (Maybe UnitId)
- data FinderOpts = FinderOpts {
  - finder_importPaths :: [OsPath]
  - finder_lookupHomeInterfaces :: Bool
  - finder_bypassHiFileCheck :: Bool
  - finder_ways :: Ways
  - finder_enableSuggestions :: Bool
  - finder_workingDirectory :: Maybe OsPath
  - finder_thisPackageName :: Maybe FastString
  - finder_hiddenModules :: Set ModuleName
  - finder_reexportedModules :: Map ModuleName ModuleName
  - finder_hieDir :: Maybe OsPath
  - finder_hieSuf :: OsString
  - finder_hiDir :: Maybe OsPath
  - finder_hiSuf :: OsString
  - finder_dynHiSuf :: OsString
  - finder_objectDir :: Maybe OsPath
  - finder_objectSuf :: OsString
  - finder_dynObjectSuf :: OsString
  - finder_stubDir :: Maybe OsPath
  }

# Documentation

data FinderCache #

Constructors

FinderCache |
Fields flushFinderCaches :: UnitEnv -> IO () remove all the home modules from the cache; package modules are assumed to not move around during a session; also flush the file hash cache. addToFinderCache :: InstalledModule -> InstalledFindResult -> IO () Add a found location to the cache for the module. lookupFinderCache :: InstalledModule -> IO (Maybe InstalledFindResult) Look for a location in the cache. lookupFileCache :: FilePath -> IO Fingerprint Look for the hash of a file in the cache. This should add it to the cache. If the file doesn't exist, raise an IOException.

type FinderCacheState = InstalledModuleEnv InstalledFindResult #

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.

type FileCacheState = Map FilePath Fingerprint #

data FindResult #

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 :: [UnusableUnit] Module is in these units, but it is unusable fr_suggestions :: [ModuleSuggestion] Possible mis-spelled modules

data InstalledFindResult #

Constructors

InstalledFound ModLocation |
InstalledNoPackage UnitId |
InstalledNotFound [OsPath] (Maybe UnitId) |

data FinderOpts #

Locations and information the finder cares about.

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

Constructors

FinderOpts |
Fields finder_importPaths :: [OsPath] 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 OsPath finder_thisPackageName :: Maybe FastString finder_hiddenModules :: Set ModuleName finder_reexportedModules :: Map ModuleName ModuleName finder_hieDir :: Maybe OsPath finder_hieSuf :: OsString finder_hiDir :: Maybe OsPath finder_hiSuf :: OsString finder_dynHiSuf :: OsString finder_objectDir :: Maybe OsPath finder_objectSuf :: OsString finder_dynObjectSuf :: OsString finder_stubDir :: Maybe OsPath