Commit 923f093c authored by Andres Löh's avatar Andres Löh
Browse files

use InstalledPackageIndex throughout

parent d0591946
......@@ -33,7 +33,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.Program (ProgramConfiguration )
import Distribution.Simple.Setup
( ConfigFlags(..), toFlag, flagToMaybe, fromFlagOrDefault )
import Distribution.Client.PackageIndex (PackageIndex)
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.Utils
( defaultPackageDesc )
import Distribution.Package
......@@ -121,7 +121,7 @@ configure verbosity packageDBs repos comp conf
--
planLocalPackage :: Verbosity -> Compiler
-> ConfigFlags -> ConfigExFlags
-> PackageIndex InstalledPackage
-> PackageIndex
-> SourcePackageDb
-> IO (Progress String String InstallPlan)
planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex
......
......@@ -43,28 +43,30 @@ module Distribution.Client.Dependency (
addPreferences,
setPreferenceDefault,
addSourcePackages,
hideInstalledPackagesSpecific,
hideInstalledPackagesSpecificByInstalledPackageId,
hideInstalledPackagesSpecificBySourcePackageId,
hideInstalledPackagesAllVersions,
) where
import Distribution.Client.Dependency.TopDown (topDownResolver)
import Distribution.Client.Dependency.Modular ()
import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Client.PackageIndex (PackageIndex)
import qualified Distribution.Simple.PackageIndex as InstalledPackageIndex
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan (InstallPlan)
import Distribution.Client.Types
( SourcePackageDb(SourcePackageDb)
, SourcePackage(..), InstalledPackage )
, SourcePackage(..) )
import Distribution.Client.Dependency.Types
( DependencyResolver, PackageConstraint(..)
, PackagePreferences(..), InstalledPreference(..)
, PackagesPreferenceDefault(..)
, Progress(..), foldProgress )
import Distribution.Client.Targets
import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.Package
( PackageName(..), PackageId, Package(..), packageVersion
, Dependency(Dependency))
, InstalledPackageId, Dependency(Dependency))
import Distribution.Version
( VersionRange, anyVersion, withinRange, simplifyVersionRange )
import Distribution.Compiler
......@@ -76,12 +78,11 @@ import Distribution.Text
( display )
import Data.List (maximumBy, foldl')
import Data.Maybe (fromMaybe, isJust)
import Data.Maybe (fromMaybe)
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Set (Set)
-- ------------------------------------------------------------
-- * High level planner policy
-- ------------------------------------------------------------
......@@ -95,8 +96,8 @@ data DepResolverParams = DepResolverParams {
depResolverConstraints :: [PackageConstraint],
depResolverPreferences :: [PackagePreference],
depResolverPreferenceDefault :: PackagesPreferenceDefault,
depResolverInstalledPkgIndex :: PackageIndex InstalledPackage,
depResolverSourcePkgIndex :: PackageIndex SourcePackage
depResolverInstalledPkgIndex :: InstalledPackageIndex.PackageIndex,
depResolverSourcePkgIndex :: PackageIndex.PackageIndex SourcePackage
}
......@@ -114,8 +115,8 @@ data PackagePreference =
-- | If we prefer versions of packages that are already installed.
| PackageInstalledPreference PackageName InstalledPreference
basicDepResolverParams :: PackageIndex InstalledPackage
-> PackageIndex SourcePackage
basicDepResolverParams :: InstalledPackageIndex.PackageIndex
-> PackageIndex.PackageIndex SourcePackage
-> DepResolverParams
basicDepResolverParams installedPkgIndex sourcePkgIndex =
DepResolverParams {
......@@ -170,7 +171,7 @@ dontUpgradeBasePackage params =
-- below when there are no targets and thus no dep on base.
-- Need to refactor contraints separate from needing packages.
isInstalled = not . null
. PackageIndex.lookupPackageName
. InstalledPackageIndex.lookupPackageName
(depResolverInstalledPkgIndex params)
addSourcePackages :: [SourcePackage]
......@@ -182,13 +183,23 @@ addSourcePackages pkgs params =
(depResolverSourcePkgIndex params) pkgs
}
hideInstalledPackagesSpecific :: [PackageId]
-> DepResolverParams -> DepResolverParams
hideInstalledPackagesSpecific pkgids params =
hideInstalledPackagesSpecificByInstalledPackageId :: [InstalledPackageId]
-> DepResolverParams -> DepResolverParams
hideInstalledPackagesSpecificByInstalledPackageId pkgids params =
--TODO: this should work using exclude constraints instead
params {
depResolverInstalledPkgIndex =
foldl' (flip InstalledPackageIndex.deleteInstalledPackageId)
(depResolverInstalledPkgIndex params) pkgids
}
hideInstalledPackagesSpecificBySourcePackageId :: [PackageId]
-> DepResolverParams -> DepResolverParams
hideInstalledPackagesSpecificBySourcePackageId pkgids params =
--TODO: this should work using exclude constraints instead
params {
depResolverInstalledPkgIndex =
foldl' (flip PackageIndex.deletePackageId)
foldl' (flip InstalledPackageIndex.deleteSourcePackageId)
(depResolverInstalledPkgIndex params) pkgids
}
......@@ -198,20 +209,20 @@ hideInstalledPackagesAllVersions pkgnames params =
--TODO: this should work using exclude constraints instead
params {
depResolverInstalledPkgIndex =
foldl' (flip PackageIndex.deletePackageName)
foldl' (flip InstalledPackageIndex.deletePackageName)
(depResolverInstalledPkgIndex params) pkgnames
}
hideBrokenInstalledPackages :: DepResolverParams -> DepResolverParams
hideBrokenInstalledPackages params =
hideInstalledPackagesSpecific pkgids params
hideInstalledPackagesSpecificByInstalledPackageId pkgids params
where
pkgids = map packageId
. PackageIndex.reverseDependencyClosure
pkgids = map Installed.installedPackageId
. InstalledPackageIndex.reverseDependencyClosure
(depResolverInstalledPkgIndex params)
. map (packageId . fst)
. PackageIndex.brokenPackages
. map (Installed.installedPackageId . fst)
. InstalledPackageIndex.brokenPackages
$ depResolverInstalledPkgIndex params
......@@ -224,7 +235,7 @@ reinstallTargets params =
hideInstalledPackagesAllVersions (depResolverTargets params) params
standardInstallPolicy :: PackageIndex InstalledPackage
standardInstallPolicy :: InstalledPackageIndex.PackageIndex
-> SourcePackageDb
-> [PackageSpecifier SourcePackage]
-> DepResolverParams
......@@ -242,7 +253,7 @@ standardInstallPolicy
. addTargets
(map pkgSpecifierTarget pkgSpecifiers)
. hideInstalledPackagesSpecific
. hideInstalledPackagesSpecificBySourcePackageId
[ packageId pkg | SpecificSourcePackage pkg <- pkgSpecifiers ]
. addSourcePackages
......@@ -383,7 +394,7 @@ resolveWithoutDependencies (DepResolverParams targets constraints
(installPref pkg, versionPref pkg, packageVersion pkg)
installPref = case preferInstalled of
PreferLatest -> const False
PreferInstalled -> isJust . PackageIndex.lookupPackageId
PreferInstalled -> not . null . InstalledPackageIndex.lookupSourcePackageId
installedPkgIndex
. packageId
versionPref pkg = packageVersion pkg `withinRange` preferredVersions
......
......@@ -16,6 +16,8 @@ import Distribution.Client.Dependency.Modular.Solver
( defaultSolver )
import Distribution.Client.Dependency.Types
( DependencyResolver )
import Distribution.Client.InstallPlan
( PlanPackage )
import Distribution.System
( Platform(..) )
......
......@@ -239,7 +239,7 @@ search configure pref constraints =
-- the standard 'DependencyResolver' interface.
--
topDownResolver :: DependencyResolver
topDownResolver = ((((((mapMessages .).).).).).) . topDownResolver'
topDownResolver = undefined -- ((((((mapMessages .).).).).).) . topDownResolver'
where
mapMessages :: Progress Log Failure a -> Progress String String a
mapMessages = foldProgress (Step . showLog) (Fail . showFailure) Done
......
......@@ -11,6 +11,8 @@
-- Common types for dependency resolution.
-----------------------------------------------------------------------------
module Distribution.Client.Dependency.Types (
ExtDependency(..),
DependencyResolver,
PackageConstraint(..),
......@@ -32,21 +34,39 @@ import Distribution.Client.Types
( SourcePackage(..), InstalledPackage )
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Compat.ReadP
( (<++) )
import Distribution.PackageDescription
( FlagAssignment )
import Distribution.Client.PackageIndex
import qualified Distribution.Client.PackageIndex as PackageIndex
( PackageIndex )
import qualified Distribution.Simple.PackageIndex as InstalledPackageIndex
( PackageIndex )
import Distribution.Package
( PackageName )
( Dependency, PackageName, InstalledPackageId )
import Distribution.Version
( VersionRange )
import Distribution.Compiler
( CompilerId )
import Distribution.System
( Platform )
import Distribution.Text
( Text(..) )
import Prelude hiding (fail)
-- | Covers source dependencies and installed dependencies in
-- one type.
data ExtDependency = SourceDependency Dependency
| InstalledDependency InstalledPackageId
instance Text ExtDependency where
disp (SourceDependency dep) = disp dep
disp (InstalledDependency dep) = disp dep
parse = (SourceDependency `fmap` parse) <++ (InstalledDependency `fmap` parse)
-- | A dependency resolver is a function that works out an installation plan
-- given the set of installed and available packages and a set of deps to
-- solve for.
......@@ -57,8 +77,8 @@ import Prelude hiding (fail)
--
type DependencyResolver = Platform
-> CompilerId
-> PackageIndex InstalledPackage
-> PackageIndex SourcePackage
-> InstalledPackageIndex.PackageIndex
-> PackageIndex.PackageIndex SourcePackage
-> (PackageName -> PackagePreferences)
-> [PackageConstraint]
-> [PackageName]
......
......@@ -19,7 +19,6 @@ import Distribution.Client.Types
import Distribution.Client.Targets
import Distribution.Client.FetchUtils hiding (fetchPackage)
import Distribution.Client.Dependency
import Distribution.Client.PackageIndex (PackageIndex)
import Distribution.Client.IndexUtils as IndexUtils
( getSourcePackages, getInstalledPackages )
import qualified Distribution.Client.InstallPlan as InstallPlan
......@@ -30,6 +29,7 @@ import Distribution.Package
( packageId )
import Distribution.Simple.Compiler
( Compiler(compilerId), PackageDBStack )
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.Program
( ProgramConfiguration )
import Distribution.Simple.Setup
......@@ -112,7 +112,7 @@ fetch verbosity packageDBs repos comp conf
planPackages :: Verbosity
-> Compiler
-> FetchFlags
-> PackageIndex InstalledPackage
-> PackageIndex
-> SourcePackageDb
-> [PackageSpecifier SourcePackage]
-> IO [SourcePackage]
......
......@@ -10,7 +10,7 @@
-- Interfacing with Haddock
--
-----------------------------------------------------------------------------
module Distribution.Client.Haddock
module Distribution.Client.Haddock
(
regenerateHaddockIndex
)
......@@ -28,24 +28,22 @@ import Distribution.Simple.Program (haddockProgram, ProgramConfiguration
import Distribution.Version (Version(Version), orLaterVersion)
import Distribution.Verbosity (Verbosity)
import Distribution.Text (display)
import Distribution.Client.PackageIndex(PackageIndex, allPackages,
allPackagesByName, fromList)
import Distribution.Simple.PackageIndex (PackageIndex, allPackages,
allPackagesByName, fromList)
import Distribution.Simple.Utils
( comparing, intercalate, debug
, installDirectoryContents, withTempDirectory )
import Distribution.InstalledPackageInfo as InstalledPackageInfo
import Distribution.InstalledPackageInfo as InstalledPackageInfo
( InstalledPackageInfo
, InstalledPackageInfo_(haddockHTMLs, haddockInterfaces, exposed) )
import Distribution.Client.Types
( InstalledPackage(..) )
regenerateHaddockIndex :: Verbosity -> PackageIndex InstalledPackage -> ProgramConfiguration -> FilePath -> IO ()
regenerateHaddockIndex :: Verbosity -> PackageIndex -> ProgramConfiguration -> FilePath -> IO ()
regenerateHaddockIndex verbosity pkgs conf index = do
(paths,warns) <- haddockPackagePaths pkgs'
case warns of
Nothing -> return ()
Just m -> debug verbosity m
(confHaddock, _, _) <-
requireProgramVersion verbosity haddockProgram
(orLaterVersion (Version [0,6] [])) conf
......@@ -63,14 +61,13 @@ regenerateHaddockIndex verbosity pkgs conf index = do
rawSystemProgram verbosity confHaddock flags
renameFile (tempDir </> "index.html") (tempDir </> destFile)
installDirectoryContents verbosity tempDir destDir
where
where
(destDir,destFile) = splitFileName index
pkgs' = map (maximumBy $ comparing packageId)
. allPackagesByName
pkgs' = map (maximumBy $ comparing packageId)
. allPackagesByName
. fromList
. filter exposed
. map (\(InstalledPackage pkg _) -> pkg)
. allPackages
$ pkgs
......
......@@ -78,10 +78,9 @@ import System.Time
getInstalledPackages :: Verbosity -> Compiler
-> PackageDBStack -> ProgramConfiguration
-> IO (PackageIndex InstalledPackage)
-> IO InstalledPackageIndex.PackageIndex
getInstalledPackages verbosity comp packageDbs conf =
fmap convert (Configure.getInstalledPackages verbosity'
comp packageDbs conf)
Configure.getInstalledPackages verbosity' comp packageDbs conf
where
--FIXME: make getInstalledPackages use sensible verbosity in the first place
verbosity' = lessVerbose verbosity
......@@ -116,11 +115,6 @@ getInstalledPackages verbosity comp packageDbs conf =
brokenPackageId (InstalledPackageId str) =
PackageIdentifier (PackageName (str ++ "-broken")) (Version [] [])
------------------------------------------------------------------------
-- Reading the source package index
--
-- | Read a repository index from disk, from the local files specified by
-- a list of 'Repo's.
--
......
......@@ -74,6 +74,7 @@ import qualified Distribution.Client.InstallSymlink as InstallSymlink
( symlinkBinaries )
import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade
import qualified Distribution.Client.World as World
import qualified Distribution.InstalledPackageInfo as Installed
import Paths_cabal_install (getBinDir)
import Distribution.Simple.Compiler
......@@ -81,8 +82,8 @@ import Distribution.Simple.Compiler
, PackageDB(..), PackageDBStack )
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
import qualified Distribution.Simple.InstallDirs as InstallDirs
import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Client.PackageIndex (PackageIndex)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.Setup
( haddockCommand, HaddockFlags(..)
, buildCommand, BuildFlags(..), emptyBuildFlags
......@@ -218,7 +219,7 @@ planPackages :: Compiler
-> ConfigFlags
-> ConfigExFlags
-> InstallFlags
-> PackageIndex InstalledPackage
-> PackageIndex
-> SourcePackageDb
-> [PackageSpecifier SourcePackage]
-> Progress String String InstallPlan
......@@ -293,7 +294,7 @@ planPackages comp configFlags configExFlags installFlags
where
isTarget pkg = packageName pkg `elem` targetnames
targetnames = map pkgSpecifierTarget pkgSpecifiers
explain :: [InstallPlan.PlanProblem] -> String
explain problems =
"Cannot select only the dependencies (as requested by the "
......@@ -319,7 +320,7 @@ planPackages comp configFlags configExFlags installFlags
-- ------------------------------------------------------------
printPlanMessages :: Verbosity
-> PackageIndex InstalledPackage
-> PackageIndex
-> InstallPlan
-> Bool
-> IO ()
......@@ -339,7 +340,7 @@ printPlanMessages verbosity installed installPlan dryRun = do
printDryRun :: Verbosity
-> PackageIndex InstalledPackage
-> PackageIndex
-> InstallPlan
-> IO ()
printDryRun verbosity installedPkgIndex plan = case unfoldr next plan of
......@@ -364,11 +365,14 @@ printDryRun verbosity installedPkgIndex plan = case unfoldr next plan of
case PackageIndex.lookupPackageName installedPkgIndex
(packageName pkg') of
[] -> "(new package)"
ps -> case find ((==packageId pkg') . packageId) ps of
ps -> case find ((==packageId pkg') . Installed.sourcePackageId) (concatMap snd ps) of
Nothing -> "(new version)"
Just pkg -> "(reinstall)" ++ case changes pkg pkg' of
[] -> ""
diff -> " changes: " ++ intercalate ", " diff
changes :: Installed.InstalledPackageInfo -> ConfiguredPackage -> [String]
changes _ _ = []
{-
changes pkg pkg' = map change . filter changed
$ mergeBy (comparing packageName)
(nub . sort . depends $ pkg)
......@@ -379,6 +383,7 @@ printDryRun verbosity installedPkgIndex plan = case unfoldr next plan of
change (OnlyInRight pkgid') = display pkgid' ++ " added"
changed (InBoth pkgid pkgid') = pkgid /= pkgid'
changed _ = True
-}
-- ------------------------------------------------------------
-- * Post installation stuff
......@@ -587,7 +592,7 @@ data InstallMisc = InstallMisc {
performInstallations :: Verbosity
-> InstallContext
-> PackageIndex InstalledPackage
-> PackageIndex
-> InstallPlan
-> IO InstallPlan
performInstallations verbosity
......
......@@ -15,7 +15,8 @@ module Distribution.Client.List (
import Distribution.Package
( PackageName(..), Package(..), packageName, packageVersion
, Dependency(..), thisPackageVersion, depends, simplifyDependency )
, Dependency(..), InstalledPackageId()
, thisPackageVersion, depends, simplifyDependency )
import Distribution.ModuleName (ModuleName)
import Distribution.License (License)
import qualified Distribution.InstalledPackageInfo as Installed
......@@ -31,6 +32,7 @@ import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Simple.Utils
( equating, comparing, die, notice )
import Distribution.Simple.Setup (fromFlag)
import qualified Distribution.Simple.PackageIndex as InstalledPackageIndex
import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Version
( Version(..), VersionRange, withinRange, anyVersion
......@@ -43,7 +45,7 @@ import Distribution.Client.Types
( SourcePackage(..), Repo, SourcePackageDb(..)
, InstalledPackage(..) )
import Distribution.Client.Dependency.Types
( PackageConstraint(..) )
( PackageConstraint(..), ExtDependency(..) )
import Distribution.Client.Targets
( UserTarget, resolveUserTargets, PackageSpecifier(..) )
import Distribution.Client.Setup
......@@ -87,15 +89,15 @@ list verbosity packageDBs repos comp conf listFlags pats = do
prefs name = fromMaybe anyVersion
(Map.lookup name (packagePreferences sourcePkgDb))
pkgsInfo :: [(PackageName, [InstalledPackage], [SourcePackage])]
pkgsInfo :: [(PackageName, [Installed.InstalledPackageInfo], [SourcePackage])]
pkgsInfo
-- gather info for all packages
| null pats = mergePackages (PackageIndex.allPackages installedPkgIndex)
(PackageIndex.allPackages sourcePkgIndex)
| null pats = mergePackages (InstalledPackageIndex.allPackages installedPkgIndex)
( PackageIndex.allPackages sourcePkgIndex)
-- gather info for packages matching search term
| otherwise = mergePackages (matchingPackages installedPkgIndex)
(matchingPackages sourcePkgIndex)
| otherwise = mergePackages (matchingPackages InstalledPackageIndex.searchByNameSubstring installedPkgIndex)
(matchingPackages (\ idx n -> concatMap snd (PackageIndex.searchByNameSubstring idx n)) sourcePkgIndex)
matches :: [PackageDisplayInfo]
matches = [ mergePackageInfo pref
......@@ -124,11 +126,10 @@ list verbosity packageDBs repos comp conf listFlags pats = do
onlyInstalled = fromFlag (listInstalled listFlags)
simpleOutput = fromFlag (listSimpleOutput listFlags)
matchingPackages index =
matchingPackages search index =
[ pkg
| pat <- pats
, (_, pkgs) <- PackageIndex.searchByNameSubstring index pat
, pkg <- pkgs ]
, pkg <- search index pat ]
info :: Verbosity
-> PackageDBStack
......@@ -152,8 +153,8 @@ info verbosity packageDBs repos comp conf
-- just available source packages, so we must resolve targets using
-- the combination of installed and source packages.
let sourcePkgs' = PackageIndex.fromList
$ map packageId (PackageIndex.allPackages installedPkgIndex)
++ map packageId (PackageIndex.allPackages sourcePkgIndex)
$ map packageId (InstalledPackageIndex.allPackages installedPkgIndex)
++ map packageId ( PackageIndex.allPackages sourcePkgIndex)
pkgSpecifiers <- resolveUserTargets verbosity
(fromFlag $ globalWorldFile globalFlags)
sourcePkgs' userTargets
......@@ -169,6 +170,11 @@ info verbosity packageDBs repos comp conf
putStr $ unlines (map showPackageDetailedInfo pkgsinfo)
where
gatherPkgInfo :: (PackageName -> VersionRange) ->
InstalledPackageIndex.PackageIndex ->
PackageIndex.PackageIndex SourcePackage ->
PackageSpecifier SourcePackage ->
Either String PackageDisplayInfo
gatherPkgInfo prefs installedPkgIndex sourcePkgIndex (NamedPackage name constraints)
| null (selectedInstalledPkgs) && null (selectedSourcePkgs)
= Left $ "There is no available version of " ++ display name
......@@ -181,12 +187,12 @@ info verbosity packageDBs repos comp conf
showPkgVersion
where
pref = prefs name
installedPkgs = PackageIndex.lookupPackageName installedPkgIndex name
sourcePkgs = PackageIndex.lookupPackageName sourcePkgIndex name
installedPkgs = concatMap snd (InstalledPackageIndex.lookupPackageName installedPkgIndex name)
sourcePkgs = PackageIndex.lookupPackageName sourcePkgIndex name
selectedInstalledPkgs = PackageIndex.lookupDependency installedPkgIndex
selectedInstalledPkgs = InstalledPackageIndex.lookupDependency installedPkgIndex
(Dependency name verConstraint)
selectedSourcePkgs = PackageIndex.lookupDependency sourcePkgIndex
selectedSourcePkgs = PackageIndex.lookupDependency sourcePkgIndex
(Dependency name verConstraint)
selectedSourcePkg = latestWithPref pref selectedSourcePkgs
......@@ -202,8 +208,8 @@ info verbosity packageDBs repos comp conf
where
name = packageName pkg
pref = prefs name
installedPkgs = PackageIndex.lookupPackageName installedPkgIndex name
sourcePkgs = PackageIndex.lookupPackageName sourcePkgIndex name
installedPkgs = concatMap snd (InstalledPackageIndex.lookupPackageName installedPkgIndex name)
sourcePkgs = PackageIndex.lookupPackageName sourcePkgIndex name
selectedPkg = Just pkg
......@@ -226,7 +232,7 @@ data PackageDisplayInfo = PackageDisplayInfo {
license :: License,
author :: String,
maintainer :: String,
dependencies :: [Dependency],
dependencies :: [ExtDependency],
flags :: [Flag],
hasLib :: Bool,
hasExe :: Bool,
......@@ -353,7 +359,7 @@ reflowLines = vcat . map text . lines
-- package name.
--
mergePackageInfo :: VersionRange
-> [InstalledPackage]
-> [Installed.InstalledPackageInfo]
-> [SourcePackage]
-> Maybe SourcePackage
-> Bool
......@@ -400,9 +406,8 @@ mergePackageInfo versionPref installedPkgs sourcePkgs selectedPkg showVer =
modules = combine Installed.exposedModules installed
(maybe [] Source.exposedModules
. Source.library) source,
dependencies = map simplifyDependency
$ combine Source.buildDepends source
(map thisPackageVersion . depends) installed',
dependencies = combine (map (SourceDependency . simplifyDependency) . Source.buildDepends) source
(map InstalledDependency . Installed.depends) installed,
haddockHtml = fromMaybe "" . join
. fmap (listToMaybe . Installed.haddockHTMLs)
$ installed,
......@@ -410,8 +415,8 @@ mergePackageInfo versionPref installedPkgs sourcePkgs selectedPkg showVer =
}
where
combine f x g y = fromJust (fmap f x `mplus` fmap g y)
installed' = latestWithPref versionPref installedPkgs
installed = fmap (\(InstalledPackage p _) -> p) installed'
installed :: Maybe Installed.InstalledPackageInfo
installed = latestWithPref versionPref installedPkgs
sourceSelected
| isJust selectedPkg = selectedPkg
......@@ -450,10 +455,10 @@ latestWithPref pref pkgs = Just (maximumBy (comparing prefThenVersion) pkgs)
-- same package by name. In the result pairs, the lists are guaranteed to not
-- both be empty.
--
mergePackages :: [InstalledPackage]
mergePackages :: [Installed.InstalledPackageInfo]
-> [SourcePackage]
-> [( PackageName