Skip to content

Commit ade1428

Browse files
authored
Merge pull request #11709 from zlonast/zlonast/ancient-ghc
Remove obsolete flatDeps alias
2 parents 0b6de78 + f5c4666 commit ade1428

11 files changed

Lines changed: 20 additions & 32 deletions

File tree

cabal-dev-scripts/cabal-dev-scripts.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ executable gen-spdx
1818
ghc-options: -Wall
1919
build-depends:
2020
, aeson ^>=2.2.3.0
21-
, base >=4.13 && <4.21
21+
, base >=4.13 && <5
2222
, bytestring
2323
, containers
2424
, Diff ^>=0.4
@@ -35,7 +35,7 @@ executable gen-spdx-exc
3535
ghc-options: -Wall
3636
build-depends:
3737
, aeson ^>=2.2.3.0
38-
, base >=4.13 && <4.21
38+
, base >=4.13 && <5
3939
, bytestring
4040
, containers
4141
, Diff ^>=0.4

cabal-dev-scripts/src/GenUtils.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module GenUtils where
77

88
import Control.Lens (each, ix, (%~), (&))
99
import Data.Char (toUpper)
10-
import Data.Maybe (fromMaybe)
1110
import Data.Proxy (Proxy (..))
1211
import Data.Text (Text)
1312
import GHC.Generics (Generic)

cabal-install-solver/src/Distribution/Solver/Types/ComponentDeps.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module Distribution.Solver.Types.ComponentDeps (
3131
, fromInstalled
3232
-- ** Deconstructing ComponentDeps
3333
, toList
34-
, flatDeps
3534
, nonSetupDeps
3635
, libraryDeps
3736
, setupDeps
@@ -44,7 +43,6 @@ import Distribution.Types.UnqualComponentName
4443
import Distribution.Solver.Compat.Prelude hiding (empty,toList,zip)
4544

4645
import qualified Data.Map as Map
47-
import Data.Foldable (fold)
4846

4947
import Distribution.Pretty (Pretty (..))
5048
import qualified Distribution.Types.ComponentName as CN
@@ -176,14 +174,6 @@ fromInstalled = fromLibraryDeps
176174
toList :: ComponentDeps a -> [ComponentDep a]
177175
toList = Map.toList . unComponentDeps
178176

179-
-- | All dependencies of a package.
180-
--
181-
-- This is just a synonym for 'fold', but perhaps a use of 'flatDeps' is more
182-
-- obvious than a use of 'fold', and moreover this avoids introducing lots of
183-
-- @#ifdef@s for 7.10 just for the use of 'fold'.
184-
flatDeps :: Monoid a => ComponentDeps a -> a
185-
flatDeps = fold
186-
187177
-- | All dependencies except the setup dependencies.
188178
--
189179
-- Prior to the introduction of setup dependencies in version 1.24 this

cabal-install-solver/src/Distribution/Solver/Types/ResolverPackage.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import qualified Distribution.Solver.Types.ComponentDeps as CD
1717
import Distribution.Compat.Graph (IsNode(..))
1818
import Distribution.Package (Package(..), HasUnitId(..))
1919
import Distribution.Simple.Utils (ordNub)
20+
import Data.Foldable (fold)
2021

2122
-- | The dependency resolver picks either pre-existing installed packages
2223
-- or it picks source packages along with package configuration.
@@ -48,5 +49,5 @@ instance IsNode (ResolverPackage loc) where
4849
nodeKey (Configured spkg) = PlannedId (packageId spkg)
4950
-- Use dependencies for ALL components
5051
nodeNeighbors pkg =
51-
ordNub $ CD.flatDeps (resolverPackageLibDeps pkg) ++
52-
CD.flatDeps (resolverPackageExeDeps pkg)
52+
ordNub $ fold (resolverPackageLibDeps pkg) ++
53+
fold (resolverPackageExeDeps pkg)

cabal-install/src/Distribution/Client/Dependency.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ import Distribution.Solver.Types.Variable
167167
import Control.Exception
168168
( assert
169169
)
170+
import Data.Foldable (fold)
170171
import Data.List
171172
( maximumBy
172173
)
@@ -1099,9 +1100,6 @@ configuredPackageProblems
10991100
specifiedDeps1 :: ComponentDeps [PackageId]
11001101
specifiedDeps1 = fmap (map solverSrcId) specifiedDeps0
11011102

1102-
specifiedDeps :: [PackageId]
1103-
specifiedDeps = CD.flatDeps specifiedDeps1
1104-
11051103
mergedFlags :: [MergeResult PD.FlagName PD.FlagName]
11061104
mergedFlags =
11071105
mergeBy
@@ -1118,7 +1116,7 @@ configuredPackageProblems
11181116
dependencyName (Dependency name _ _) = name
11191117

11201118
mergedDeps :: [MergeResult Dependency PackageId]
1121-
mergedDeps = mergeDeps requiredDeps specifiedDeps
1119+
mergedDeps = mergeDeps requiredDeps (fold specifiedDeps1)
11221120

11231121
mergeDeps
11241122
:: [Dependency]

cabal-install/src/Distribution/Client/Install.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ import Distribution.Version
274274
)
275275

276276
import qualified Data.ByteString as BS
277+
import Data.Foldable (fold)
277278
import Distribution.Client.Errors
278279

279280
-- TODO:
@@ -1002,7 +1003,7 @@ printPlan dryRun verbosity plan sourcePkgDb = case plan of
10021003
)
10031004
)
10041005
_ <-
1005-
CD.flatDeps (confPkgDeps cpkg)
1006+
fold (confPkgDeps cpkg)
10061007
]
10071008

10081009
revDeps :: Map.Map PackageId [PackageId]

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ elaborateInstallPlan
21692169

21702170
-- TODO: Why is this flat?
21712171
pkgPkgConfigDependencies =
2172-
CD.flatDeps $ buildComponentDeps compPkgConfigDependencies
2172+
fold $ buildComponentDeps compPkgConfigDependencies
21732173

21742174
pkgDependsOnSelfLib =
21752175
CD.fromList
@@ -3577,7 +3577,7 @@ pruneInstallPlanPass1 pkgs
35773577
pruneOptionalDependencies elab@ElaboratedConfiguredPackage{elabPkgOrComp = ElabComponent _} =
35783578
InstallPlan.depends elab -- no pruning
35793579
pruneOptionalDependencies ElaboratedConfiguredPackage{elabPkgOrComp = ElabPackage pkg} =
3580-
(CD.flatDeps . CD.filterDeps keepNeeded) (pkgOrderDependencies pkg)
3580+
(fold . CD.filterDeps keepNeeded) (pkgOrderDependencies pkg)
35813581
where
35823582
keepNeeded (CD.ComponentTest _) _ = TestStanzas `optStanzaSetMember` stanzas
35833583
keepNeeded (CD.ComponentBench _) _ = BenchStanzas `optStanzaSetMember` stanzas

cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import Distribution.Utils.Path (getSymbolicPath)
119119
import Distribution.Version
120120

121121
import qualified Data.ByteString.Lazy as LBS
122+
import Data.Foldable (fold)
122123
import qualified Data.List.NonEmpty as NE
123124
import qualified Data.Map as Map
124125
import qualified Data.Monoid as Mon
@@ -558,7 +559,7 @@ elabOrderDependencies elab =
558559
case elabPkgOrComp elab of
559560
-- Important not to have duplicates: otherwise InstallPlan gets
560561
-- confused.
561-
ElabPackage pkg -> ordNub (CD.flatDeps (pkgOrderDependencies pkg))
562+
ElabPackage pkg -> ordNub (fold (pkgOrderDependencies pkg))
562563
ElabComponent comp -> compOrderDependencies comp
563564

564565
-- | Like 'elabOrderDependencies', but only returns dependencies on
@@ -569,7 +570,7 @@ elabOrderLibDependencies elab =
569570
ElabPackage pkg ->
570571
map (newSimpleUnitId . confInstId) $
571572
ordNub $
572-
CD.flatDeps (map fst <$> pkgLibDependencies pkg)
573+
fold (map fst <$> pkgLibDependencies pkg)
573574
ElabComponent comp -> compOrderLibDependencies comp
574575

575576
-- | The library dependencies (i.e., the libraries we depend on, NOT

cabal-install/src/Distribution/Client/Types/ConfiguredPackage.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Distribution.Types.Flag (FlagAssignment)
1616
import Distribution.Types.LibraryName (LibraryName (..))
1717
import Distribution.Types.MungedPackageId (computeCompatPackageId)
1818

19+
import Data.Foldable (fold)
1920
import Distribution.Client.Types.ConfiguredId
2021
import Distribution.Solver.Types.OptionalStanza (OptionalStanzaSet)
2122
import Distribution.Solver.Types.PackageFixedDeps
@@ -65,7 +66,7 @@ instance IsNode (ConfiguredPackage loc) where
6566
-- TODO: if we update ConfiguredPackage to support order-only
6667
-- dependencies, need to include those here.
6768
-- NB: have to deduplicate, otherwise the planner gets confused
68-
nodeNeighbors = ordNub . CD.flatDeps . depends
69+
nodeNeighbors = ordNub . fold . depends
6970

7071
instance Binary loc => Binary (ConfiguredPackage loc)
7172

@@ -80,4 +81,4 @@ instance HasUnitId (ConfiguredPackage loc) where
8081
installedUnitId = newSimpleUnitId . confPkgId
8182

8283
instance PackageInstalled (ConfiguredPackage loc) where
83-
installedDepends = CD.flatDeps . depends
84+
installedDepends = fold . depends

cabal-install/tests/UnitTests/Distribution/Client/GZipUtils.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Control.Exception (try)
1111
import Data.ByteString as BS (null)
1212
import Data.ByteString.Lazy as BSL (pack, toChunks)
1313
import Data.ByteString.Lazy.Char8 as BSLL (init, length, pack)
14+
import Data.Either (isLeft)
1415
import Distribution.Client.GZipUtils (maybeDecompress)
1516

1617
import Test.Tasty
@@ -55,8 +56,3 @@ prop_maybeDecompress_gzip ws = property $ maybeDecompress compressedGZip === ori
5556
where
5657
original = BSL.pack ws
5758
compressedGZip = GZip.compress original
58-
59-
-- (Only available from "Data.Either" since 7.8.)
60-
isLeft :: Either a b -> Bool
61-
isLeft (Right _) = False
62-
isLeft (Left _) = True

0 commit comments

Comments
 (0)