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
db9ccb5b
Commit
db9ccb5b
authored
Jan 13, 2016
by
Edward Z. Yang
Browse files
Add a Module data type.
Signed-off-by:
Edward Z. Yang
<
ezyang@cs.stanford.edu
>
parent
e65fe1f2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/InstalledPackageInfo.hs
View file @
db9ccb5b
...
...
@@ -30,7 +30,7 @@ module Distribution.InstalledPackageInfo (
InstalledPackageInfo
(
..
),
installedComponentId
,
installedPackageId
,
OriginalModule
(
..
),
ExposedModule
(
..
),
ExposedModule
(
..
),
ParseResult
(
..
),
PError
(
..
),
PWarning
,
emptyInstalledPackageInfo
,
parseInstalledPackageInfo
,
...
...
@@ -162,29 +162,13 @@ emptyInstalledPackageInfo
-- -----------------------------------------------------------------------------
-- Exposed modules
data
OriginalModule
=
OriginalModule
{
originalPackageId
::
UnitId
,
originalModuleName
::
ModuleName
}
deriving
(
Generic
,
Eq
,
Read
,
Show
)
data
ExposedModule
=
ExposedModule
{
exposedName
::
ModuleName
,
exposedReexport
::
Maybe
Original
Module
exposedReexport
::
Maybe
Module
}
deriving
(
Eq
,
Generic
,
Read
,
Show
)
instance
Text
OriginalModule
where
disp
(
OriginalModule
ipi
m
)
=
disp
ipi
<>
Disp
.
char
':'
<>
disp
m
parse
=
do
ipi
<-
parse
_
<-
Parse
.
char
':'
m
<-
parse
return
(
OriginalModule
ipi
m
)
instance
Text
ExposedModule
where
disp
(
ExposedModule
m
reexport
)
=
Disp
.
sep
[
disp
m
...
...
@@ -202,8 +186,6 @@ instance Text ExposedModule where
return
(
ExposedModule
m
reexport
)
instance
Binary
OriginalModule
instance
Binary
ExposedModule
-- To maintain backwards-compatibility, we accept both comma/non-comma
...
...
Cabal/Distribution/Package.hs
View file @
db9ccb5b
...
...
@@ -30,6 +30,9 @@ module Distribution.Package (
getHSLibraryName
,
InstalledPackageId
,
-- backwards compat
-- * Modules
Module
(
..
),
-- * ABI hash
AbiHash
(
..
),
...
...
@@ -55,6 +58,7 @@ import qualified Text.PrettyPrint as Disp
import
Distribution.Compat.ReadP
import
Distribution.Compat.Binary
import
Distribution.Text
import
Distribution.ModuleName
import
Control.DeepSeq
(
NFData
(
..
))
import
qualified
Data.Char
as
Char
...
...
@@ -111,9 +115,32 @@ instance Text PackageIdentifier where
instance
NFData
PackageIdentifier
where
rnf
(
PackageIdentifier
name
version
)
=
rnf
name
`
seq
`
rnf
version
-- ------------------------------------------------------------
-- * Component Source Hash
-- ------------------------------------------------------------
-- | A module identity uniquely identifies a Haskell module by
-- qualifying a 'ModuleName' with the 'UnitId' which defined
-- it. This type distinguishes between two packages
-- which provide a module with the same name, or a module
-- from the same package compiled with different dependencies.
-- There are a few cases where Cabal needs to know about
-- module identities, e.g., when writing out reexported modules in
-- the 'InstalledPackageInfo'.
data
Module
=
Module
{
moduleUnitId
::
UnitId
,
moduleName
::
ModuleName
}
deriving
(
Generic
,
Read
,
Show
,
Eq
,
Ord
,
Typeable
,
Data
)
instance
Binary
Module
instance
Text
Module
where
disp
(
Module
uid
mod_name
)
=
disp
uid
<>
Disp
.
text
":"
<>
disp
mod_name
parse
=
do
uid
<-
parse
_
<-
Parse
.
char
':'
mod_name
<-
parse
return
(
Module
uid
mod_name
)
instance
NFData
Module
where
rnf
(
Module
uid
mod_name
)
=
rnf
uid
`
seq
`
rnf
mod_name
-- | A 'ComponentId' uniquely identifies the transitive source
-- code closure of a component. For non-Backpack components, it also
...
...
Cabal/Distribution/Simple/Configure.hs
View file @
db9ccb5b
...
...
@@ -1740,8 +1740,8 @@ resolveModuleReexports installedPackages srcpkgid key externalPkgDeps lib =
,
let
exportingPackageName
=
packageName
srcpkgid
definingModuleName
=
visibleModuleName
definingPackageId
=
key
originalModule
=
Installed
.
Original
Module
definingPackageId
definingModuleName
originalModule
=
Module
definingPackageId
definingModuleName
exposedModule
=
Installed
.
ExposedModule
visibleModuleName
(
Just
originalModule
)
]
...
...
@@ -1758,7 +1758,7 @@ resolveModuleReexports installedPackages srcpkgid key externalPkgDeps lib =
-- In this case the reexport will point to this package.
Nothing
->
return
exposedModule
{
Installed
.
exposedReexport
=
Just
(
Installed
.
Original
Module
Just
(
Module
(
Installed
.
installedUnitId
pkg
)
(
Installed
.
exposedName
exposedModule
))
}
-- On the other hand, a visible module might actually be itself
...
...
Cabal/Distribution/Simple/PackageIndex.hs
View file @
db9ccb5b
...
...
@@ -614,8 +614,8 @@ moduleNameIndex index =
IPI
.
ExposedModule
m
reexport
<-
IPI
.
exposedModules
pkg
case
reexport
of
Nothing
->
return
(
m
,
[
pkg
])
Just
(
IPI
.
Original
Module
_
m'
)
|
m
==
m'
->
[]
|
otherwise
->
return
(
m'
,
[
pkg
])
Just
(
Module
_
m'
)
|
m
==
m'
->
[]
|
otherwise
->
return
(
m'
,
[
pkg
])
-- The heuristic is this: we want to prefer the original package
-- which originally exported a module. However, if a reexport
-- also *renamed* the module (m /= m'), then we have to use the
...
...
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