From 0ff63413d29e3c99083649fd62fde949ab48869c Mon Sep 17 00:00:00 2001
From: Edsko de Vries <edsko@well-typed.com>
Date: Wed, 25 Mar 2015 09:30:47 +0000
Subject: [PATCH] Update code comments

This addresses commit commemts

* https://github.com/haskell/cabal/pull/2488#commitcomment-10373353
* https://github.com/haskell/cabal/pull/2488#commitcomment-10373373
* https://github.com/haskell/cabal/pull/2488#commitcomment-10375768

from @23Skidoo.
---
 cabal-install/Distribution/Client/Install.hs     | 10 +++++-----
 cabal-install/Distribution/Client/InstallPlan.hs | 13 +++++++++++--
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/cabal-install/Distribution/Client/Install.hs b/cabal-install/Distribution/Client/Install.hs
index bdc8cd7495..69083afb95 100644
--- a/cabal-install/Distribution/Client/Install.hs
+++ b/cabal-install/Distribution/Client/Install.hs
@@ -561,12 +561,12 @@ packageStatus _comp installedPkgIndex cpkg =
     changes :: Installed.InstalledPackageInfo
             -> ReadyPackage
             -> [MergeResult PackageIdentifier PackageIdentifier]
-    changes pkg pkg' =
-      filter changed
-      $ mergeBy (comparing packageName)
-          (resolveInstalledIds $ Installed.depends pkg)
-          (resolveInstalledIds $ depends $ pkg')
+    changes pkg pkg' = filter changed $
+      mergeBy (comparing packageName)
+        (resolveInstalledIds $ Installed.depends pkg) -- deps of installed pkg
+        (resolveInstalledIds $ depends $ pkg')        -- deps of configured pkg
 
+    -- convert to source pkg ids via index
     resolveInstalledIds :: [InstalledPackageId] -> [PackageIdentifier]
     resolveInstalledIds =
         nub
diff --git a/cabal-install/Distribution/Client/InstallPlan.hs b/cabal-install/Distribution/Client/InstallPlan.hs
index 0505fbeaea..e750b12ac9 100644
--- a/cabal-install/Distribution/Client/InstallPlan.hs
+++ b/cabal-install/Distribution/Client/InstallPlan.hs
@@ -143,6 +143,17 @@ type PlanIndex = PackageIndex PlanPackage
 -- have problems with inconsistent dependencies.
 -- On the other hand it is true that every closed sub plan is valid.
 
+-- | Packages in an install plan
+--
+-- NOTE: 'ConfiguredPackage', 'ReadyPackage' and 'PlanPackage' intentionally
+-- have no 'PackageInstalled' instance. `This is important: PackageInstalled
+-- returns only library dependencies, but for package that aren't yet installed
+-- we know many more kinds of dependencies (setup dependencies, exe, test-suite,
+-- benchmark, ..). Any functions that operate on dependencies in cabal-install
+-- should consider what to do with these dependencies; if we give a
+-- 'PackageInstalled' instance it would be too easy to get this wrong (and,
+-- for instance, call graph traversal functions from Cabal rather than from
+-- cabal-install). Instead, see 'PackageFixedDeps'.
 data PlanPackage = PreExisting InstalledPackage
                  | Configured  ConfiguredPackage
                  | Processing  ReadyPackage
@@ -239,8 +250,6 @@ new platform cinfo index =
           }
       where (graph, vertexToPkgId, pkgIdToVertex) =
               PlanIndex.dependencyGraph fakeMap index
-              -- NB: doesn't need to know planFakeMap because the
-              -- fakemap is empty at this point.
             noSuchPkgId = internalError "package is not in the graph"
     probs -> Left probs
 
-- 
GitLab