Skip to content

Follow hlint suggestion: use infix #11143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
- ignore: {name: "Use fold"} # 1 hint
- ignore: {name: "Use fromMaybe"} # 5 hints
- ignore: {name: "Use fst"} # 2 hints
- ignore: {name: "Use infix"} # 27 hints
- ignore: {name: "Use lambda-case"} # 58 hints
- ignore: {name: "Use list comprehension"} # 19 hints
- ignore: {name: "Use list literal"} # 3 hints
Expand Down
12 changes: 6 additions & 6 deletions Cabal-syntax/src/Distribution/Types/VersionInterval/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@ unionVersionIntervals
-> VersionIntervals
-> VersionIntervals
unionVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =
checkInvariant (VersionIntervals (union is0 is'0))
checkInvariant (VersionIntervals (is0 `union` is'0))
where
union is [] = is
union [] is' = is'
union (i : is) (i' : is') = case unionInterval i i' of
-- @i < i'@ and separated: keep @i@.
Left Nothing -> i : union is (i' : is')
-- @i'' = i ∪ i'@ and @i@ ends first: drop @i@, replace @i'@ by @i''@.
Left (Just i'') -> union is (i'' : is')
Left (Just i'') -> is `union` (i'' : is')
-- @i' < i@ and separated: keep @i'@.
Right Nothing -> i' : union (i : is) is'
-- @i'' = i ∪ i'@ and @i'@ ends first: drop @i'@, replace @i@ by @i''@.
Right (Just i'') -> union (i'' : is) is'
Right (Just i'') -> (i'' : is) `union` is'

-- | Given two version intervals @i1@ and @i2@, return one of the following:
--
Expand Down Expand Up @@ -364,17 +364,17 @@ intersectVersionIntervals
-> VersionIntervals
-> VersionIntervals
intersectVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =
checkInvariant (VersionIntervals (intersect is0 is'0))
checkInvariant (VersionIntervals (is0 `intersect` is'0))
where
intersect _ [] = []
intersect [] _ = []
intersect (i : is) (i' : is') = case intersectInterval i i' of
-- @i < i'@: throw out @i@
Left Nothing -> intersect is (i' : is')
Left Nothing -> is `intersect` (i' : is')
-- @i'' = i /\ i'@ and @i@ ends first: replace @i@ by @i''@.
Left (Just i'') -> i'' : intersect is (i' : is')
-- @i' < i@: throw out @i'@
Right Nothing -> intersect (i : is) is'
Right Nothing -> (i : is) `intersect` is'
-- @i'' = i /\ i'@ and @i'@ ends first: replace @i'@ by @i''@.
Right (Just i'') -> i'' : intersect (i : is) is'

Expand Down
8 changes: 4 additions & 4 deletions Cabal-syntax/src/Distribution/Types/VersionRange.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ foldVersionRange _any this later earlier union intersect = fold

alg (ThisVersionF v) = this v
alg (LaterVersionF v) = later v
alg (OrLaterVersionF v) = union (this v) (later v)
alg (OrLaterVersionF v) = this v `union` later v
alg (EarlierVersionF v) = earlier v
alg (OrEarlierVersionF v) = union (this v) (earlier v)
alg (OrEarlierVersionF v) = this v `union` earlier v
alg (MajorBoundVersionF v) = fold (majorBound v)
alg (UnionVersionRangesF v1 v2) = union v1 v2
alg (IntersectVersionRangesF v1 v2) = intersect v1 v2
alg (UnionVersionRangesF v1 v2) = v1 `union` v2
alg (IntersectVersionRangesF v1 v2) = v1 `intersect` v2

majorBound v =
intersectVersionRanges
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ checkPackageDescription
-- But it is OK for executables to have the same name.
nsubs <- asksCM (pnSubLibs . ccNames)
checkP
(elem (prettyShow pn) (prettyShow <$> nsubs))
(prettyShow pn `elem` (prettyShow <$> nsubs))
(PackageBuildImpossible $ IllegalLibraryName pn)

-- § Fields check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ annotateCondTree fs ta (CondNode a c bs) =
-- \*off* by default.
isPkgFlagCond :: Condition ConfVar -> Bool
isPkgFlagCond (Lit _) = False
isPkgFlagCond (Var (PackageFlag f)) = elem f defOffFlags
isPkgFlagCond (Var (PackageFlag f)) = f `elem` defOffFlags
isPkgFlagCond (Var _) = False
isPkgFlagCond (CNot cn) = not (isPkgFlagCond cn)
isPkgFlagCond (CAnd ca cb) = isPkgFlagCond ca || isPkgFlagCond cb
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ checkAutogenModules ams bi = do
-- PackageBuildImpossible and not merely PackageDistInexcusable.
checkSpecVer
CabalSpecV3_12
(elem autoInfoModuleName allModsForAuto)
(autoInfoModuleName `elem` allModsForAuto)
(PackageBuildImpossible CVAutogenPackageInfoGuard)
where
allModsForAuto :: [ModuleName]
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ computeLocalBuildConfig cfg comp programDb = do
-- rely on them. By the time that bug was fixed, ghci had
-- been changed to read shared libraries instead of archive
-- files (see next code block).
notElem (GHC.compilerBuildWay comp) [DynWay, ProfDynWay]
GHC.compilerBuildWay comp `notElem` [DynWay, ProfDynWay]
CompilerId GHCJS _ ->
not (GHCJS.isDynamic comp)
_ -> False
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ extractRtsInfo lbi =
-- threaded RTS. This is used to determine which RTS to link against when
-- building a foreign library with a GHC without support for @-flink-rts@.
hasThreaded :: BuildInfo -> Bool
hasThreaded bi = elem "-threaded" ghc
hasThreaded bi = "-threaded" `elem` ghc
where
PerCompilerFlavor ghc _ = options bi

Expand Down
10 changes: 7 additions & 3 deletions Cabal/src/Distribution/Simple/GHC/Build/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ withDynFLib flib =
ForeignLibTypeUnknown ->
cabalBug "unknown foreign lib type"

-- | Is the extension of the file in the list of extensions?
extensionIn :: [String] -> FilePath -> Bool
extensionIn exts fp = takeExtension fp `elem` exts

-- | Is this file a C++ source file, i.e. ends with .cpp, .cxx, or .c++?
isCxx :: FilePath -> Bool
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]
isCxx = extensionIn [".cpp", ".cxx", ".c++"]

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

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

-- | Returns True if the modification date of the given source file is newer than
-- the object file we last compiled for it, or if no object file exists yet.
Expand Down
14 changes: 3 additions & 11 deletions Cabal/src/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import Distribution.Simple.BuildPaths
import Distribution.Simple.Compiler
import Distribution.Simple.Errors
import Distribution.Simple.Flag
import Distribution.Simple.GHC.Build.Link (hasThreaded)
import Distribution.Simple.GHC.Build.Utils (isCxx, isHaskell)
import Distribution.Simple.GHC.EnvironmentParser
import Distribution.Simple.GHC.ImplInfo
import qualified Distribution.Simple.GHC.Internal as Internal
Expand Down Expand Up @@ -1242,13 +1244,6 @@ gbuildSources verbosity mbWorkDir pkgId specVer tmpDir bm =
, inputSourceModules = foreignLibModules flib
}

isCxx :: FilePath -> Bool
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]

-- | FilePath has a Haskell extension: .hs or .lhs
isHaskell :: FilePath -> Bool
isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"]

-- | Generic build function. See comment for 'GBuildMode'.
gbuild
:: Verbosity
Expand Down Expand Up @@ -1776,7 +1771,7 @@ getRPaths _ _ = return mempty
popThreadedFlag :: BuildInfo -> (BuildInfo, Bool)
popThreadedFlag bi =
( bi{options = filterHcOptions (/= "-threaded") (options bi)}
, hasThreaded (options bi)
, hasThreaded bi
)
where
filterHcOptions
Expand All @@ -1786,9 +1781,6 @@ popThreadedFlag bi =
filterHcOptions p (PerCompilerFlavor ghc ghcjs) =
PerCompilerFlavor (filter p ghc) ghcjs

hasThreaded :: PerCompilerFlavor [String] -> Bool
hasThreaded (PerCompilerFlavor ghc _) = elem "-threaded" ghc

-- | Extracts a String representing a hash of the ABI of a built
-- library. It can fail if the library has not yet been built.
libAbiHash
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/LocalBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ depLibraryPaths
-- because you never have any internal libraries in this case;
-- they're all external.
let external_ipkgs = filter is_external (allPackages installed)
is_external ipkg = notElem (installedUnitId ipkg) internalDeps
is_external ipkg = installedUnitId ipkg `notElem` internalDeps
-- First look for dynamic libraries in `dynamic-library-dirs`, and use
-- `library-dirs` as a fall back.
getDynDir pkg = case Installed.libraryDynDirs pkg of
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ installCommand =
}
where
-- install doesn't take installDirs flags, since it always installs into the store in a fixed way.
notInstallDirOpt x = notElem (optionName x) installDirOptNames
notInstallDirOpt x = optionName x `notElem` installDirOptNames
installDirOptNames = map optionName installDirsOptions

-- | The @install@ command actually serves four different needs. It installs:
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ updateAction flags@NixStyleFlags{..} extraArgs globalFlags = do
unless (null updateRepoRequests) $ do
let remoteRepoNames = map repoName repos
unknownRepos =
[ r | (UpdateRequest r _) <- updateRepoRequests, notElem r remoteRepoNames
[ r | (UpdateRequest r _) <- updateRepoRequests, r `notElem` remoteRepoNames
]
unless (null unknownRepos) $
dieWithException verbosity $
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ checkPrintPlan
-- likely to be broken. We exclude packages that are already broken.
let newBrokenPkgs =
filter
(\p -> notElem (Installed.installedUnitId p) excluded)
(\p -> Installed.installedUnitId p `notElem` excluded)
(PackageIndex.reverseDependencyClosure installed reinstalledPkgs)
let containsReinstalls = not (null reinstalledPkgs)
let breaksPkgs = not (null newBrokenPkgs)
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/Types/AllowNewer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ isRelaxDeps RelaxDepsAll = True
-- | A smarter 'RelaxedDepsSome', @*:*@ is the same as @all@.
mkRelaxDepSome :: [RelaxedDep] -> RelaxDeps
mkRelaxDepSome xs
| elem (RelaxedDep RelaxDepScopeAll RelaxDepModNone RelaxDepSubjectAll) xs =
| RelaxedDep RelaxDepScopeAll RelaxDepModNone RelaxDepSubjectAll `elem` xs =
RelaxDepsAll
| otherwise =
RelaxDepsSome xs
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/tests/UnitTests/Distribution/Client/VCS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ getDirectoryContentsRecursive ignore dir0 dir = do
isdir <- doesDirectoryExist (dir0 </> dir </> entry)
return (dir </> entry, isdir)
| entry <- entries
, not (isPrefixOf "." entry)
, not ("." `isPrefixOf` entry)
, (dir </> entry) `Set.notMember` ignore
]
let subdirs = [d | (d, True) <- entries']
Expand Down
Loading