Skip to content

Commit 433a9f0

Browse files
authored
Merge of #11143
2 parents 59c80b7 + 906d2de commit 433a9f0

File tree

16 files changed

+31
-36
lines changed

16 files changed

+31
-36
lines changed

.hlint.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
- ignore: {name: "Use fold"} # 1 hint
4646
- ignore: {name: "Use fromMaybe"} # 5 hints
4747
- ignore: {name: "Use fst"} # 2 hints
48-
- ignore: {name: "Use infix"} # 27 hints
4948
- ignore: {name: "Use lambda-case"} # 58 hints
5049
- ignore: {name: "Use list comprehension"} # 19 hints
5150
- ignore: {name: "Use list literal"} # 3 hints

Cabal-syntax/src/Distribution/Types/VersionInterval/Legacy.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,19 +309,19 @@ unionVersionIntervals
309309
-> VersionIntervals
310310
-> VersionIntervals
311311
unionVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =
312-
checkInvariant (VersionIntervals (union is0 is'0))
312+
checkInvariant (VersionIntervals (is0 `union` is'0))
313313
where
314314
union is [] = is
315315
union [] is' = is'
316316
union (i : is) (i' : is') = case unionInterval i i' of
317317
-- @i < i'@ and separated: keep @i@.
318318
Left Nothing -> i : union is (i' : is')
319319
-- @i'' = i ∪ i'@ and @i@ ends first: drop @i@, replace @i'@ by @i''@.
320-
Left (Just i'') -> union is (i'' : is')
320+
Left (Just i'') -> is `union` (i'' : is')
321321
-- @i' < i@ and separated: keep @i'@.
322322
Right Nothing -> i' : union (i : is) is'
323323
-- @i'' = i ∪ i'@ and @i'@ ends first: drop @i'@, replace @i@ by @i''@.
324-
Right (Just i'') -> union (i'' : is) is'
324+
Right (Just i'') -> (i'' : is) `union` is'
325325

326326
-- | Given two version intervals @i1@ and @i2@, return one of the following:
327327
--
@@ -364,17 +364,17 @@ intersectVersionIntervals
364364
-> VersionIntervals
365365
-> VersionIntervals
366366
intersectVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =
367-
checkInvariant (VersionIntervals (intersect is0 is'0))
367+
checkInvariant (VersionIntervals (is0 `intersect` is'0))
368368
where
369369
intersect _ [] = []
370370
intersect [] _ = []
371371
intersect (i : is) (i' : is') = case intersectInterval i i' of
372372
-- @i < i'@: throw out @i@
373-
Left Nothing -> intersect is (i' : is')
373+
Left Nothing -> is `intersect` (i' : is')
374374
-- @i'' = i /\ i'@ and @i@ ends first: replace @i@ by @i''@.
375375
Left (Just i'') -> i'' : intersect is (i' : is')
376376
-- @i' < i@: throw out @i'@
377-
Right Nothing -> intersect (i : is) is'
377+
Right Nothing -> (i : is) `intersect` is'
378378
-- @i'' = i /\ i'@ and @i'@ ends first: replace @i'@ by @i''@.
379379
Right (Just i'') -> i'' : intersect (i : is) is'
380380

Cabal-syntax/src/Distribution/Types/VersionRange.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ foldVersionRange _any this later earlier union intersect = fold
9696

9797
alg (ThisVersionF v) = this v
9898
alg (LaterVersionF v) = later v
99-
alg (OrLaterVersionF v) = union (this v) (later v)
99+
alg (OrLaterVersionF v) = this v `union` later v
100100
alg (EarlierVersionF v) = earlier v
101-
alg (OrEarlierVersionF v) = union (this v) (earlier v)
101+
alg (OrEarlierVersionF v) = this v `union` earlier v
102102
alg (MajorBoundVersionF v) = fold (majorBound v)
103-
alg (UnionVersionRangesF v1 v2) = union v1 v2
104-
alg (IntersectVersionRangesF v1 v2) = intersect v1 v2
103+
alg (UnionVersionRangesF v1 v2) = v1 `union` v2
104+
alg (IntersectVersionRangesF v1 v2) = v1 `intersect` v2
105105

106106
majorBound v =
107107
intersectVersionRanges

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ checkPackageDescription
423423
-- But it is OK for executables to have the same name.
424424
nsubs <- asksCM (pnSubLibs . ccNames)
425425
checkP
426-
(elem (prettyShow pn) (prettyShow <$> nsubs))
426+
(prettyShow pn `elem` (prettyShow <$> nsubs))
427427
(PackageBuildImpossible $ IllegalLibraryName pn)
428428

429429
-- § Fields check.

Cabal/src/Distribution/PackageDescription/Check/Conditional.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ annotateCondTree fs ta (CondNode a c bs) =
9292
-- \*off* by default.
9393
isPkgFlagCond :: Condition ConfVar -> Bool
9494
isPkgFlagCond (Lit _) = False
95-
isPkgFlagCond (Var (PackageFlag f)) = elem f defOffFlags
95+
isPkgFlagCond (Var (PackageFlag f)) = f `elem` defOffFlags
9696
isPkgFlagCond (Var _) = False
9797
isPkgFlagCond (CNot cn) = not (isPkgFlagCond cn)
9898
isPkgFlagCond (CAnd ca cb) = isPkgFlagCond ca || isPkgFlagCond cb

Cabal/src/Distribution/PackageDescription/Check/Target.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ checkAutogenModules ams bi = do
692692
-- PackageBuildImpossible and not merely PackageDistInexcusable.
693693
checkSpecVer
694694
CabalSpecV3_12
695-
(elem autoInfoModuleName allModsForAuto)
695+
(autoInfoModuleName `elem` allModsForAuto)
696696
(PackageBuildImpossible CVAutogenPackageInfoGuard)
697697
where
698698
allModsForAuto :: [ModuleName]

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ computeLocalBuildConfig cfg comp programDb = do
711711
-- rely on them. By the time that bug was fixed, ghci had
712712
-- been changed to read shared libraries instead of archive
713713
-- files (see next code block).
714-
notElem (GHC.compilerBuildWay comp) [DynWay, ProfDynWay]
714+
GHC.compilerBuildWay comp `notElem` [DynWay, ProfDynWay]
715715
CompilerId GHCJS _ ->
716716
not (GHCJS.isDynamic comp)
717717
_ -> False

Cabal/src/Distribution/Simple/GHC/Build/Link.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ extractRtsInfo lbi =
726726
-- threaded RTS. This is used to determine which RTS to link against when
727727
-- building a foreign library with a GHC without support for @-flink-rts@.
728728
hasThreaded :: BuildInfo -> Bool
729-
hasThreaded bi = elem "-threaded" ghc
729+
hasThreaded bi = "-threaded" `elem` ghc
730730
where
731731
PerCompilerFlavor ghc _ = options bi
732732

Cabal/src/Distribution/Simple/GHC/Build/Utils.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ withDynFLib flib =
7474
ForeignLibTypeUnknown ->
7575
cabalBug "unknown foreign lib type"
7676

77+
-- | Is the extension of the file in the list of extensions?
78+
extensionIn :: [String] -> FilePath -> Bool
79+
extensionIn exts fp = takeExtension fp `elem` exts
80+
7781
-- | Is this file a C++ source file, i.e. ends with .cpp, .cxx, or .c++?
7882
isCxx :: FilePath -> Bool
79-
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]
83+
isCxx = extensionIn [".cpp", ".cxx", ".c++"]
8084

8185
-- | Is this a C source file, i.e. ends with .c?
8286
isC :: FilePath -> Bool
83-
isC fp = elem (takeExtension fp) [".c"]
87+
isC = extensionIn [".c"]
8488

8589
-- | FilePath has a Haskell extension: .hs or .lhs
8690
isHaskell :: FilePath -> Bool
87-
isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"]
91+
isHaskell = extensionIn [".hs", ".lhs"]
8892

8993
-- | Returns True if the modification date of the given source file is newer than
9094
-- the object file we last compiled for it, or if no object file exists yet.

Cabal/src/Distribution/Simple/GHCJS.hs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ import Distribution.Simple.BuildPaths
6262
import Distribution.Simple.Compiler
6363
import Distribution.Simple.Errors
6464
import Distribution.Simple.Flag
65+
import Distribution.Simple.GHC.Build.Link (hasThreaded)
66+
import Distribution.Simple.GHC.Build.Utils (isCxx, isHaskell)
6567
import Distribution.Simple.GHC.EnvironmentParser
6668
import Distribution.Simple.GHC.ImplInfo
6769
import qualified Distribution.Simple.GHC.Internal as Internal
@@ -1242,13 +1244,6 @@ gbuildSources verbosity mbWorkDir pkgId specVer tmpDir bm =
12421244
, inputSourceModules = foreignLibModules flib
12431245
}
12441246

1245-
isCxx :: FilePath -> Bool
1246-
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]
1247-
1248-
-- | FilePath has a Haskell extension: .hs or .lhs
1249-
isHaskell :: FilePath -> Bool
1250-
isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"]
1251-
12521247
-- | Generic build function. See comment for 'GBuildMode'.
12531248
gbuild
12541249
:: Verbosity
@@ -1776,7 +1771,7 @@ getRPaths _ _ = return mempty
17761771
popThreadedFlag :: BuildInfo -> (BuildInfo, Bool)
17771772
popThreadedFlag bi =
17781773
( bi{options = filterHcOptions (/= "-threaded") (options bi)}
1779-
, hasThreaded (options bi)
1774+
, hasThreaded bi
17801775
)
17811776
where
17821777
filterHcOptions
@@ -1786,9 +1781,6 @@ popThreadedFlag bi =
17861781
filterHcOptions p (PerCompilerFlavor ghc ghcjs) =
17871782
PerCompilerFlavor (filter p ghc) ghcjs
17881783

1789-
hasThreaded :: PerCompilerFlavor [String] -> Bool
1790-
hasThreaded (PerCompilerFlavor ghc _) = elem "-threaded" ghc
1791-
17921784
-- | Extracts a String representing a hash of the ABI of a built
17931785
-- library. It can fail if the library has not yet been built.
17941786
libAbiHash

0 commit comments

Comments
 (0)