@@ -20,7 +20,6 @@ module Stack.BuildPlan
2020 , DepErrors
2121 , removeSrcPkgDefaultFlags
2222 , selectBestSnapshot
23- , showItems
2423 ) where
2524
2625import qualified Data.Foldable as F
@@ -194,8 +193,8 @@ gpdPackageDeps gpd compilerVersion platform flags =
194193 , platform
195194 }
196195
197- -- Remove any src package flags having default values
198- -- Remove any package entries with no flags set
196+ -- | For the given list of packages and dictionary of packages and Cabal flags,
197+ -- remove flags that have defaults and packages with no remaining flags.
199198removeSrcPkgDefaultFlags ::
200199 [C. GenericPackageDescription ]
201200 -> Map PackageName (Map FlagName Bool )
@@ -210,12 +209,8 @@ removeSrcPkgDefaultFlags gpds flags =
210209 in Just $ Map. differenceWith diff f1 f2
211210
212211 gpdDefaultFlags gpd =
213- let tuples = map getDefault (C. genPackageFlags gpd)
214- in Map. singleton (gpdPackageName gpd) (Map. fromList tuples)
215-
216- getDefault f
217- | C. flagDefault f = (C. flagName f, True )
218- | otherwise = (C. flagName f, False )
212+ let pairs = map (C. flagName &&& C. flagDefault) (C. genPackageFlags gpd)
213+ in Map. singleton (gpdPackageName gpd) (Map. fromList pairs)
219214
220215-- | Find the set of @FlagName@s necessary to get the given
221216-- @GenericPackageDescription@ to compile against the given @BuildPlan@. Will
@@ -305,11 +300,17 @@ checkPackageDeps myName deps packages =
305300 , neededBy = Map. singleton myName range
306301 }
307302
303+ -- | A type synoynm for a dictionary of packages and failures to satisfy
304+ -- packages' dependency constraints.
308305type DepErrors = Map PackageName DepError
309306
307+ -- | A type representing failures to satisfy packages' dependency constraints.
310308data DepError = DepError
311309 { version :: ! (Maybe Version )
310+ -- ^ If available, the available version of the package.
312311 , neededBy :: ! (Map PackageName VersionRange )
312+ -- ^ A dictionary of the packages requiring the package and the permitted
313+ -- range of versions.
313314 }
314315 deriving Show
315316
@@ -344,6 +345,8 @@ checkBundleBuildPlan platform compiler pool flags gpds =
344345
345346 dupError _ _ = impureThrow DuplicatePackagesBug
346347
348+ -- | A type representing the results of evaluating how well a snapshot satisfies
349+ -- the dependencies of a set of packages and a set of Cabal flags.
347350data BuildPlanCheck
348351 = BuildPlanCheckOk (Map PackageName (Map FlagName Bool ))
349352 | BuildPlanCheckPartial (Map PackageName (Map FlagName Bool )) DepErrors
0 commit comments