Skip to content

Commit

Permalink
Make package db preference right-biased (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Jun 2, 2015
1 parent 021600c commit 70ce926
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ getPackageDatabases bconfig BTDeps =
liftIO $ liftM return $ runReaderT packageDatabaseDeps bconfig
getPackageDatabases bconfig BTLocals = liftIO $ flip runReaderT bconfig $
sequence
[ packageDatabaseLocal
, packageDatabaseDeps
[ packageDatabaseDeps
, packageDatabaseLocal
]

getInstallRoot :: MonadIO m => BuildConfig -> BuildType -> m (Path Abs Dir)
Expand Down
6 changes: 4 additions & 2 deletions src/Stack/GhcPkg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ghcPkg menv pkgDbs args = do
-- latest version of each package.
--
-- Package databases passed to this function override eachother in a
-- left-biased way when containing two packages of the same name.
-- right-biased way when containing two packages of the same name.
getPackageVersionMapWithGlobalDb
:: (MonadCatch m, MonadIO m, MonadThrow m, MonadLogger m)
=> EnvOverride
Expand All @@ -129,13 +129,15 @@ getPackageVersionMapWithGlobalDb menv mmbp pkgDbs = do
Just mbp ->
filtering gdb mbp allGlobals
$logDebug ("Filtered globals: " <> T.pack (show globals))
-- M.unions is left-biased.
-- M.unions is left-biased, so we reverse the list before calling
-- it to make it right-biased, like GHC.
rest <-
getPackageVersions
menv
pkgDbs
(flip elem pkgDbs)
(M.unions .
reverse .
map (M.fromList . rights))
return (M.unions [rest,globals])
where
Expand Down

0 comments on commit 70ce926

Please sign in to comment.