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
a5905fb5
Commit
a5905fb5
authored
May 09, 2008
by
Duncan Coutts
Browse files
Swap Either args so it's Either Error Ok
Which seems to be the normal convention.
parent
8f5ef044
Changes
2
Hide whitespace changes
Inline
Side-by-side
cabal-install/Hackage/Dependency.hs
View file @
a5905fb5
...
...
@@ -55,12 +55,10 @@ resolveDependencies :: OS
->
[
UnresolvedDependency
]
->
Either
[
Dependency
]
(
InstallPlan
a
)
resolveDependencies
os
arch
comp
(
Just
installed
)
available
deps
=
either
Right
Left
$
dependencyResolver
naiveResolver
os
arch
comp
installed
available
deps
resolveDependencies
os
arch
comp
Nothing
available
deps
=
either
Right
Left
$
dependencyResolver
bogusResolver
os
arch
comp
mempty
available
deps
...
...
@@ -77,7 +75,7 @@ type DependencyResolver a = OS
->
PackageIndex
InstalledPackageInfo
->
PackageIndex
AvailablePackage
->
[
UnresolvedDependency
]
->
Either
[
InstallPlan
.
PlanPackage
a
]
[
Dependency
]
->
Either
[
Dependency
]
[
InstallPlan
.
PlanPackage
a
]
dependencyResolver
::
DependencyResolver
a
...
...
@@ -85,22 +83,22 @@ dependencyResolver
->
PackageIndex
InstalledPackageInfo
->
PackageIndex
AvailablePackage
->
[
UnresolvedDependency
]
->
Either
(
InstallPlan
a
)
[
Dependency
]
->
Either
[
Dependency
]
(
InstallPlan
a
)
dependencyResolver
resolver
os
arch
comp
installed
available
deps
=
case
resolver
os
arch
comp
(
hideBrokenPackages
installed
)
available
deps
of
Left
pkgs
->
Left
unresolved
->
Left
unresolved
Right
pkgs
->
case
InstallPlan
.
new
os
arch
comp
(
PackageIndex
.
fromList
pkgs
)
of
Left
plan
->
Lef
t
plan
Right
problems
->
error
$
unlines
$
Right
plan
->
Righ
t
plan
Left
problems
->
error
$
unlines
$
"internal error: could not construct a valid install plan."
:
"The proposed (invalid) plan contained the following problems:"
:
map
InstallPlan
.
showPlanProblem
problems
Right
unresolved
->
Right
unresolved
-- | This is an example resolver that says that every package failed.
--
failingResolver
::
DependencyResolver
a
failingResolver
_
_
_
_
_
deps
=
Righ
t
failingResolver
_
_
_
_
_
deps
=
Lef
t
[
dep
|
UnresolvedDependency
dep
_
<-
deps
]
-- | This resolver thinks that every package is already installed.
...
...
@@ -108,8 +106,8 @@ failingResolver _ _ _ _ _ deps = Right
bogusResolver
::
DependencyResolver
a
bogusResolver
os
arch
comp
_
available
deps
=
case
unzipEithers
(
map
resolveFromAvailable
deps
)
of
(
ok
,
[]
)
->
Lef
t
ok
(
_
,
missing
)
->
Righ
t
missing
(
ok
,
[]
)
->
Righ
t
ok
(
_
,
missing
)
->
Lef
t
missing
where
resolveFromAvailable
(
UnresolvedDependency
dep
flags
)
=
case
latestAvailableSatisfying
available
dep
of
...
...
@@ -196,7 +194,7 @@ getDependencies os arch comp installed available pkg flags
packagesToInstall
::
PackageIndex
InstalledPackageInfo
->
[
ResolvedDependency
]
->
Either
[
InstallPlan
.
PlanPackage
a
]
[
Dependency
]
->
Either
[
Dependency
]
[
InstallPlan
.
PlanPackage
a
]
-- ^ Either a list of missing dependencies, or a graph
-- of packages to install, with their options.
packagesToInstall
allInstalled
deps0
=
...
...
@@ -216,10 +214,10 @@ packagesToInstall allInstalled deps0 =
allInstalled
(
getInstalled
deps0
)
in
Lef
t
$
map
InstallPlan
.
Configured
selectedAvailable
in
Righ
t
$
map
InstallPlan
.
Configured
selectedAvailable
++
map
InstallPlan
.
PreExisting
selectedInstalled
(
missing
,
_
)
->
Righ
t
$
concat
missing
(
missing
,
_
)
->
Lef
t
$
concat
missing
where
getAvailable
::
ResolvedDependency
...
...
cabal-install/Hackage/InstallPlan.hs
View file @
a5905fb5
...
...
@@ -158,10 +158,10 @@ internalError msg = error $ "InstallPlan: internal error: " ++ msg
-- | Build an installation plan from a valid set of resolved packages.
--
new
::
OS
->
Arch
->
CompilerId
->
PackageIndex
(
PlanPackage
a
)
->
Either
(
InstallPlan
a
)
[
PlanProblem
a
]
->
Either
[
PlanProblem
a
]
(
InstallPlan
a
)
new
os
arch
compiler
index
=
case
problems
os
arch
compiler
index
of
[]
->
Lef
t
InstallPlan
{
[]
->
Righ
t
InstallPlan
{
planIndex
=
index
,
planGraph
=
graph
,
planGraphRev
=
Graph
.
transposeG
graph
,
...
...
@@ -174,7 +174,7 @@ new os arch compiler index =
where
(
graph
,
vertexToPkgId
,
pkgIdToVertex
)
=
PackageIndex
.
dependencyGraph
index
noSuchPkgId
=
internalError
"package is not in the graph"
probs
->
Righ
t
probs
probs
->
Lef
t
probs
toList
::
InstallPlan
buildResult
->
[
PlanPackage
buildResult
]
toList
=
PackageIndex
.
allPackages
.
planIndex
...
...
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