Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,251
Issues
4,251
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
398
Merge Requests
398
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
5226da37
Commit
5226da37
authored
May 18, 2020
by
Sylvain Henry
Committed by
Marge Bot
Jun 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and document add_package
parent
36e1daf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
compiler/GHC/Unit/State.hs
compiler/GHC/Unit/State.hs
+26
-25
No files found.
compiler/GHC/Unit/State.hs
View file @
5226da37
...
...
@@ -2021,7 +2021,7 @@ getPreloadUnitsAnd dflags pkgids0 =
preload
=
preloadUnits
state
parents
=
zip
pkgids
(
repeat
Nothing
)
in
do
all_pkgs
<-
throwErr
dflags
(
foldM
(
add_
package
pkg_map
)
preload
parents
)
all_pkgs
<-
throwErr
dflags
(
foldM
(
add_
unit
pkg_map
)
preload
parents
)
return
(
map
(
unsafeLookupUnitId
state
)
all_pkgs
)
-- Takes a list of packages, and returns the list with dependencies included,
...
...
@@ -2042,34 +2042,35 @@ throwErr dflags m
closeDepsErr
::
UnitInfoMap
->
[(
UnitId
,
Maybe
UnitId
)]
->
MaybeErr
MsgDoc
[
UnitId
]
closeDepsErr
pkg_map
ps
=
foldM
(
add_
package
pkg_map
)
[]
ps
closeDepsErr
pkg_map
ps
=
foldM
(
add_
unit
pkg_map
)
[]
ps
-- internal helper
add_package
::
UnitInfoMap
-- | Add a UnitId and those it depends on (recursively) to the given list of
-- UnitIds if they are not already in it. Return a list in reverse dependency
-- order (a unit appears before those it depends on).
--
-- The UnitId is looked up in the given UnitInfoMap (to find its dependencies).
-- It it's not found, the optional parent unit is used to return a more precise
-- error message ("dependency of <PARENT>").
add_unit
::
UnitInfoMap
->
[
UnitId
]
->
(
UnitId
,
Maybe
UnitId
)
->
MaybeErr
MsgDoc
[
UnitId
]
add_package
pkg_map
ps
(
p
,
mb_parent
)
|
p
`
elem
`
ps
=
return
ps
-- Check if we've already added this package
|
otherwise
=
case
lookupUnitId'
pkg_map
p
of
Nothing
->
Failed
(
missingPackageMsg
p
<>
missingDependencyMsg
mb_parent
)
Just
pkg
->
do
-- Add the package's dependents also
ps'
<-
foldM
add_unit_key
ps
(
unitDepends
pkg
)
return
(
p
:
ps'
)
where
add_unit_key
ps
key
=
add_package
pkg_map
ps
(
key
,
Just
p
)
missingPackageMsg
::
Outputable
pkgid
=>
pkgid
->
SDoc
missingPackageMsg
p
=
text
"unknown package:"
<+>
ppr
p
missingDependencyMsg
::
Maybe
UnitId
->
SDoc
missingDependencyMsg
Nothing
=
Outputable
.
empty
missingDependencyMsg
(
Just
parent
)
=
space
<>
parens
(
text
"dependency of"
<+>
ftext
(
unitIdFS
parent
))
add_unit
pkg_map
ps
(
p
,
mb_parent
)
|
p
`
elem
`
ps
=
return
ps
-- Check if we've already added this unit
|
otherwise
=
case
lookupUnitId'
pkg_map
p
of
Nothing
->
Failed
$
(
ftext
(
fsLit
"unknown package:"
)
<+>
ppr
p
)
<>
case
mb_parent
of
Nothing
->
Outputable
.
empty
Just
parent
->
space
<>
parens
(
text
"dependency of"
<+>
ftext
(
unitIdFS
parent
))
Just
info
->
do
-- Add the unit's dependents also
ps'
<-
foldM
add_unit_key
ps
(
unitDepends
info
)
return
(
p
:
ps'
)
where
add_unit_key
ps
key
=
add_unit
pkg_map
ps
(
key
,
Just
p
)
-- -----------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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