Skip to content
GitLab
Menu
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
3b990b1c
Commit
3b990b1c
authored
Sep 07, 2013
by
Mikhail Glushenkov
Browse files
Merge pull request #1469 from 23Skidoo/issue-1463
Add a workaround for issue #1463.
parents
4c6fa93e
bcf8b2d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Simple/PackageIndex.hs
View file @
3b990b1c
...
...
@@ -106,6 +106,8 @@ data PackageIndex = PackageIndex
-- of the same package version. These are unique by InstalledPackageId
-- and are kept in preference order.
--
-- FIXME: Clarify what "preference order" means. Check that this invariant is
-- preserved. See #1463 for discussion.
!
(
Map
PackageName
(
Map
Version
[
InstalledPackageInfo
]))
deriving
(
Show
,
Read
)
...
...
cabal-install/Distribution/Client/SetupWrapper.hs
View file @
3b990b1c
...
...
@@ -87,7 +87,7 @@ import System.IO ( Handle, hPutStr )
import
System.Exit
(
ExitCode
(
..
),
exitWith
)
import
System.Process
(
runProcess
,
waitForProcess
)
import
Control.Monad
(
when
,
unless
)
import
Data.List
(
maximumBy
)
import
Data.List
(
foldl1'
)
import
Data.Maybe
(
fromMaybe
,
isJust
)
import
Data.Monoid
(
mempty
)
import
Data.Char
(
isSpace
)
...
...
@@ -270,8 +270,24 @@ externalSetupMethod verbosity options pkg bt mkargs = do
pkgs
->
return
$
bestVersion
id
(
map
fst
pkgs
)
bestVersion
::
(
a
->
Version
)
->
[
a
]
->
a
bestVersion
f
=
m
aximumBy
(
comparing
(
preference
.
f
))
bestVersion
f
=
firstM
aximumBy
(
comparing
(
preference
.
f
))
where
-- Like maximumBy, but picks the first maximum element instead of the
-- last. In general, we expect the preferred version to go first in the
-- list. For the default case, this has the effect of choosing the version
-- installed in the user package DB instead of the global one. See #1463.
--
-- Note: firstMaximumBy could be written as just
-- `maximumBy cmp . reverse`, but the problem is that the behaviour of
-- maximumBy is not fully specified in the case when there is not a single
-- greatest element.
firstMaximumBy
::
(
a
->
a
->
Ordering
)
->
[
a
]
->
a
firstMaximumBy
_
[]
=
error
"Distribution.Client.firstMaximumBy: empty list"
firstMaximumBy
cmp
xs
=
foldl1'
maxBy
xs
where
maxBy
x
y
=
case
cmp
x
y
of
{
GT
->
x
;
EQ
->
x
;
LT
->
y
;
}
preference
version
=
(
sameVersion
,
sameMajorVersion
,
stableVersion
,
latestVersion
)
where
...
...
Write
Preview
Supports
Markdown
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