- module PackageConfig
- data PackageState
- initPackages :: DynFlags -> IO (DynFlags, [PackageKey])
- readPackageConfigs :: DynFlags -> IO [PackageConfig]
- getPackageConfRefs :: DynFlags -> IO [PkgConfRef]
- resolvePackageConfig :: DynFlags -> PkgConfRef -> IO (Maybe FilePath)
- readPackageConfig :: DynFlags -> FilePath -> IO [PackageConfig]
- lookupPackage :: DynFlags -> PackageKey -> Maybe PackageConfig
- resolveInstalledPackageId :: DynFlags -> InstalledPackageId -> PackageKey
- searchPackageId :: DynFlags -> SourcePackageId -> [PackageConfig]
- getPackageDetails :: DynFlags -> PackageKey -> PackageConfig
- listVisibleModuleNames :: DynFlags -> [ModuleName]
- lookupModuleInAllPackages :: DynFlags -> ModuleName -> [(Module, PackageConfig)]
- lookupModuleWithSuggestions :: DynFlags -> ModuleName -> Maybe FastString -> LookupResult
- data LookupResult
- data ModuleSuggestion
- data ModuleOrigin
- getPackageIncludePath :: DynFlags -> [PackageKey] -> IO [String]
- getPackageLibraryPath :: DynFlags -> [PackageKey] -> IO [String]
- getPackageLinkOpts :: DynFlags -> [PackageKey] -> IO ([String], [String], [String])
- getPackageExtraCcOpts :: DynFlags -> [PackageKey] -> IO [String]
- getPackageFrameworkPath :: DynFlags -> [PackageKey] -> IO [String]
- getPackageFrameworks :: DynFlags -> [PackageKey] -> IO [String]
- getPreloadPackagesAnd :: DynFlags -> [PackageKey] -> IO [PackageConfig]
- collectIncludeDirs :: [PackageConfig] -> [FilePath]
- collectLibraryPaths :: [PackageConfig] -> [FilePath]
- collectLinkOpts :: DynFlags -> [PackageConfig] -> ([String], [String], [String])
- packageHsLibs :: DynFlags -> PackageConfig -> [String]
- packageKeyPackageIdString :: DynFlags -> PackageKey -> Maybe String
- pprFlag :: PackageFlag -> SDoc
- pprPackages :: DynFlags -> SDoc
- pprPackagesSimple :: DynFlags -> SDoc
- pprModuleMap :: DynFlags -> SDoc
- isDllName :: DynFlags -> PackageKey -> Module -> Name -> Bool
Reading the package config, and processing cmdline args
Call this after
parseDynFlags. It reads the package
database files, and sets up various internal tables of package
information, according to the package-related flags on the
Returns a list of packages to link in if we're doing dynamic linking.
This list contains the packages that the user explicitly mentioned with
Querying the package config
Find the package we know about with the given key (e.g.
foo_HASH), if any
Search for packages with a given package ID (e.g. "foo-0.1")
Looks up the package with the given id in the package state, panicing if it is not found
ModuleName, and if the module is in any package returns
list of modules which take that name.
The result of performing a lookup
|LookupFound Module PackageConfig|
Found the module uniquely, nothing else to do
|LookupMultiple [(Module, ModuleOrigin)]|
Multiple modules with the same name in scope
|LookupHidden [(Module, ModuleOrigin)] [(Module, ModuleOrigin)]|
No modules found, but there were some hidden ones with an exact name match. First is due to package hidden, second is due to module being hidden
Nothing found, here are some suggested different names
Package state is all stored in
DynFlags, including the details of
all packages, which packages are exposed, and which modules they
The package state is computed by
initPackages, and kept in DynFlags.
It is influenced by various package flags:
pkgto become exposed. If
-hide-all-packageswas not specified, these commands also cause all other packages with the same name to become hidden.
pkgto become hidden.
- (there are a few more flags, check below for their semantics)
The package state has the following properties.
exposedPackagesbe the set of packages thus exposed. Let
depExposedPackagesbe the transitive closure from
exposedPackagesof their dependencies.
- When searching for a module from an preload import declaration,
only the exposed modules in
- When searching for a module from an implicit import, all modules
- When linking in a compilation manager mode, we link in packages the
program depends on (the compiler knows this list by the
time it gets to the link step). Also, we link in all packages
which were mentioned with preload
-packageflags on the command-line, or are a transitive dependency of same, or are "base"/"rts". The reason for this is that we might need packages which don't contain any Haskell modules, and therefore won't be discovered by the normal mechanism of dependency tracking.
Given a module name, there may be multiple ways it came into scope, possibly simultaneously. This data type tracks all the possible ways it could have come into scope. Warning: don't use the record functions, they're partial!
Module is hidden, and thus never will be available for import. (But maybe the user didn't realize), so we'll still keep track of these modules.)
Module is public, and could have come from some places.
Inspecting the set of packages in scope
Find all the include directories in these and the preload packages
Find all the library paths in these and the preload packages
Find all the link options in these and the preload packages, returning (package hs lib options, extra library options, other flags)
Find all the C-compiler options in these and the preload packages
Find all the package framework paths in these and the preload packages
Find all the package frameworks in these and the preload packages
Show simplified package info.
The idea is to only print package id, and any information that might be different from the package databases (exposure, trust)