summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit/Finder/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Unit/Finder/Types.hs')
-rw-r--r--compiler/GHC/Unit/Finder/Types.hs56
1 files changed, 56 insertions, 0 deletions
diff --git a/compiler/GHC/Unit/Finder/Types.hs b/compiler/GHC/Unit/Finder/Types.hs
new file mode 100644
index 0000000000..094f77be3a
--- /dev/null
+++ b/compiler/GHC/Unit/Finder/Types.hs
@@ -0,0 +1,56 @@
+module GHC.Unit.Finder.Types
+ ( FinderCache
+ , FindResult (..)
+ , InstalledFindResult (..)
+ )
+where
+
+import GHC.Prelude
+import GHC.Unit
+import GHC.Unit.State
+
+-- | 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 FinderCache = InstalledModuleEnv InstalledFindResult
+
+data InstalledFindResult
+ = InstalledFound ModLocation InstalledModule
+ | InstalledNoPackage UnitId
+ | InstalledNotFound [FilePath] (Maybe UnitId)
+
+-- | 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').
+data FindResult
+ = Found ModLocation Module
+ -- ^ The module was found
+ | NoPackage Unit
+ -- ^ The requested unit was not found
+ | FoundMultiple [(Module, ModuleOrigin)]
+ -- ^ _Error_: both in multiple packages
+
+ -- | Not found
+ | NotFound
+ { 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
+
+ -- | Module is in these units, but it is unusable
+ , fr_unusables :: [(Unit, UnusableUnitReason)]
+
+ , fr_suggestions :: [ModuleSuggestion] -- ^ Possible mis-spelled modules
+ }
+