Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
42364776
Commit
42364776
authored
Oct 02, 2016
by
Edward Z. Yang
Browse files
Add some more Backpack utility functions to InstalledPackageInfo.
Signed-off-by:
Edward Z. Yang
<
ezyang@cs.stanford.edu
>
parent
fd893156
Changes
2
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Backpack/ModuleShape.hs
View file @
42364776
...
...
@@ -74,13 +74,9 @@ emptyModuleShape = ModuleShape Map.empty Set.empty
shapeInstalledPackage
::
IPI
.
InstalledPackageInfo
->
ModuleShape
shapeInstalledPackage
ipi
=
ModuleShape
(
Map
.
fromList
provs
)
reqs
where
insts
=
Map
.
fromList
(
IPI
.
instantiatedWith
ipi
)
uid
=
if
Set
.
null
(
indefModuleSubstFreeHoles
insts
)
then
DefiniteUnitId
(
IPI
.
installedUnitId
ipi
)
else
IndefFullUnitId
(
IPI
.
installedComponentId
ipi
)
insts
uid
=
installedIndefUnitId
ipi
provs
=
map
shapeExposedModule
(
IPI
.
exposedModules
ipi
)
reqs
=
indefModuleSubstFreeHoles
(
Map
.
fromList
(
IPI
.
instantiatedWith
ipi
))
reqs
=
requiredSignatures
ipi
shapeExposedModule
(
IPI
.
ExposedModule
mod_name
Nothing
)
=
(
mod_name
,
IndefModule
uid
mod_name
)
shapeExposedModule
(
IPI
.
ExposedModule
mod_name
(
Just
mod
))
...
...
Cabal/Distribution/InstalledPackageInfo.hs
View file @
42364776
...
...
@@ -31,6 +31,9 @@ module Distribution.InstalledPackageInfo (
InstalledPackageInfo
(
..
),
installedComponentId
,
installedPackageId
,
indefinite
,
requiredSignatures
,
installedIndefUnitId
,
ExposedModule
(
..
),
ParseResult
(
..
),
PError
(
..
),
PWarning
,
emptyInstalledPackageInfo
,
...
...
@@ -58,6 +61,8 @@ import Distribution.Compat.Graph
import
Text.PrettyPrint
as
Disp
import
qualified
Data.Char
as
Char
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
Data.Set
(
Set
)
-- -----------------------------------------------------------------------------
-- The InstalledPackageInfo type
...
...
@@ -114,6 +119,30 @@ data InstalledPackageInfo
}
deriving
(
Eq
,
Generic
,
Read
,
Show
)
-- | Returns 'True' if this is an interface-file only indefinite
-- package which has not been instantiated.
indefinite
::
InstalledPackageInfo
->
Bool
indefinite
ipi
=
-- TODO: optimize a little
Set
.
null
(
indefModuleSubstFreeHoles
(
Map
.
fromList
(
instantiatedWith
ipi
)))
-- | Get the indefinite unit identity representing this package.
-- This IS NOT guaranteed to give you a substitution; for
-- instantiated packages you will get @DefiniteUnitId (installedUnitId ipi)@.
-- For indefinite libraries, however, you will correctly get
-- an @IndefUnitId@ with the appropriate 'IndefModuleSubst'.
installedIndefUnitId
::
InstalledPackageInfo
->
IndefUnitId
installedIndefUnitId
ipi
=
if
indefinite
ipi
then
IndefFullUnitId
(
installedComponentId
ipi
)
(
Map
.
fromList
(
instantiatedWith
ipi
))
else
DefiniteUnitId
(
installedUnitId
ipi
)
-- | Returns the set of module names which need to be filled for
-- an indefinite package, or the empty set if the package is definite.
requiredSignatures
::
InstalledPackageInfo
->
Set
ModuleName
requiredSignatures
ipi
=
indefModuleSubstFreeHoles
(
Map
.
fromList
(
instantiatedWith
ipi
))
installedComponentId
::
InstalledPackageInfo
->
ComponentId
installedComponentId
ipi
=
unitIdComponentId
(
installedUnitId
ipi
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment