From 59ec2c3538345f53406c978af34cd7675f6b314c Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Mon, 25 Nov 2024 12:29:41 -0500 Subject: [PATCH] Drop Has prefix on patterns, use LE not LEQ - avoid name clash with has*Bound (VersionRange -> Bool) predicates - use TZ not TrailingZero, a two-letter prefix like the other two --- Cabal-syntax/src/Distribution/Types/VersionRange.hs | 12 ++++++------ .../src/Distribution/Types/VersionRange/Internal.hs | 10 +++++----- Cabal-syntax/src/Distribution/Version.hs | 2 +- Cabal/src/Distribution/PackageDescription/Check.hs | 6 +++--- .../Distribution/PackageDescription/Check/Target.hs | 4 ++-- .../Distribution/PackageDescription/Check/Warning.hs | 10 +++++----- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cabal-syntax/src/Distribution/Types/VersionRange.hs b/Cabal-syntax/src/Distribution/Types/VersionRange.hs index c3cfe770658..80b0373df9c 100644 --- a/Cabal-syntax/src/Distribution/Types/VersionRange.hs +++ b/Cabal-syntax/src/Distribution/Types/VersionRange.hs @@ -15,7 +15,7 @@ module Distribution.Types.VersionRange -- *** Upper Bound , hasUpperBound - , hasLEQUpperBound + , hasLEUpperBound , hasTrailingZeroUpperBound -- *** Any Version @@ -225,24 +225,24 @@ hasLowerBound = -- | Is the upper bound version range (less than or equal (LE, <=)? -- --- >>> forM ["< 1", "<= 1", ">= 0 && < 1", ">= 0 || < 1", ">= 0 && <= 1", ">= 0 || <= 1", "^>= 4.20.0.0"] (fmap hasLEQUpperBound . simpleParsec) +-- >>> forM ["< 1", "<= 1", ">= 0 && < 1", ">= 0 || < 1", ">= 0 && <= 1", ">= 0 || <= 1", "^>= 4.20.0.0"] (fmap hasLEUpperBound . simpleParsec) -- Just [False,True,False,False,True,True,False] -hasLEQUpperBound :: VersionRange -> Bool -hasLEQUpperBound = queryVersionRange (\case HasLEQUpperBound -> True; _ -> False) hasLEQUpperBound +hasLEUpperBound :: VersionRange -> Bool +hasLEUpperBound = queryVersionRange (\case LEUpperBound -> True; _ -> False) hasLEUpperBound -- | Is the lower bound version range greater than (GT, >)? -- -- >>> forM ["< 1", ">= 0 && < 1", ">= 0 || < 1", "> 0 && < 1", "> 0 || < 1", "^>= 4.20.0.0"] (fmap hasGTLowerBound . simpleParsec) -- Just [False,False,False,True,True,False] hasGTLowerBound :: VersionRange -> Bool -hasGTLowerBound = queryVersionRange (\case HasGTLowerBound -> True; _ -> False) hasGTLowerBound +hasGTLowerBound = queryVersionRange (\case GTLowerBound -> True; _ -> False) hasGTLowerBound -- | Does the upper bound version range have a trailing zero? -- -- >>> forM ["< 1", "< 1.1", "< 1.0", "< 1.1.0", "^>= 4.20.0.0"] (fmap hasTrailingZeroUpperBound . simpleParsec) -- Just [False,False,True,True,False] hasTrailingZeroUpperBound :: VersionRange -> Bool -hasTrailingZeroUpperBound = queryVersionRange (\case HasTrailingZeroUpperBound -> True; _ -> False) hasTrailingZeroUpperBound +hasTrailingZeroUpperBound = queryVersionRange (\case TZUpperBound -> True; _ -> False) hasTrailingZeroUpperBound queryVersionRange :: (VersionRangeF VersionRange -> Bool) -> (VersionRange -> Bool) -> VersionRange -> Bool queryVersionRange pf p (projectVersionRange -> v) = diff --git a/Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs b/Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs index 65628a05a53..8ac1cd0073e 100644 --- a/Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs +++ b/Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs @@ -27,7 +27,7 @@ module Distribution.Types.VersionRange.Internal , intersectVersionRanges , withinVersion , majorBoundVersion - , VersionRangeF (.., HasLEQUpperBound, HasGTLowerBound, HasTrailingZeroUpperBound) + , VersionRangeF (.., LEUpperBound, GTLowerBound, TZUpperBound) , projectVersionRange , embedVersionRange , cataVersionRange @@ -189,10 +189,10 @@ data VersionRangeF a , Traversable ) -pattern HasLEQUpperBound, HasGTLowerBound, HasTrailingZeroUpperBound :: VersionRangeF a -pattern HasLEQUpperBound <- OrEarlierVersionF _ -pattern HasGTLowerBound <- LaterVersionF _ -pattern HasTrailingZeroUpperBound <- (upperTrailingZero -> True) +pattern LEUpperBound, GTLowerBound, TZUpperBound :: VersionRangeF a +pattern LEUpperBound <- OrEarlierVersionF _ +pattern GTLowerBound <- LaterVersionF _ +pattern TZUpperBound <- (upperTrailingZero -> True) upperTrailingZero :: VersionRangeF a -> Bool upperTrailingZero (OrEarlierVersionF x) = trailingZero x diff --git a/Cabal-syntax/src/Distribution/Version.hs b/Cabal-syntax/src/Distribution/Version.hs index f460da2648b..76aed461228 100644 --- a/Cabal-syntax/src/Distribution/Version.hs +++ b/Cabal-syntax/src/Distribution/Version.hs @@ -50,7 +50,7 @@ module Distribution.Version , stripParensVersionRange , hasUpperBound , hasLowerBound - , hasLEQUpperBound + , hasLEUpperBound , hasTrailingZeroUpperBound , hasGTLowerBound diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index 3f9879b99f3..2d9750de77d 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -568,9 +568,9 @@ checkSetupBuildInfo (Just (SetupBuildInfo ds _)) = do rck = PackageDistSuspiciousWarn . MissingUpperBounds CETSetup - lequck = + leuck = PackageDistSuspiciousWarn - . LEQUpperBounds CETSetup + . LEUpperBounds CETSetup tzuck = PackageDistSuspiciousWarn . TrailingZeroUpperBounds CETSetup @@ -579,7 +579,7 @@ checkSetupBuildInfo (Just (SetupBuildInfo ds _)) = do . GTLowerBounds CETSetup checkPVP (checkDependencyVersionRange $ not . hasUpperBound) ick is checkPVPs (checkDependencyVersionRange $ not . hasUpperBound) rck rs - checkPVPs (checkDependencyVersionRange hasLEQUpperBound) lequck ds + checkPVPs (checkDependencyVersionRange hasLEUpperBound) leuck ds checkPVPs (checkDependencyVersionRange hasTrailingZeroUpperBound) tzuck ds checkPVPs (checkDependencyVersionRange hasGTLowerBound) gtlck ds diff --git a/Cabal/src/Distribution/PackageDescription/Check/Target.hs b/Cabal/src/Distribution/PackageDescription/Check/Target.hs index dd692efbfe9..0bf173cb980 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Target.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Target.hs @@ -339,7 +339,7 @@ checkBuildInfo cet ams ads bi = do ds let ick = const (PackageDistInexcusable BaseNoUpperBounds) rck = PackageDistSuspiciousWarn . MissingUpperBounds cet - lequck = PackageDistSuspiciousWarn . LEQUpperBounds cet + leuck = PackageDistSuspiciousWarn . LEUpperBounds cet tzuck = PackageDistSuspiciousWarn . TrailingZeroUpperBounds cet gtlck = PackageDistSuspiciousWarn . GTLowerBounds cet checkPVP (checkDependencyVersionRange $ not . hasUpperBound) ick ids @@ -348,7 +348,7 @@ checkBuildInfo cet ams ads bi = do (checkPVPs (checkDependencyVersionRange $ not . hasUpperBound) rck rds) unless (isInternalTarget cet) - (checkPVPs (checkDependencyVersionRange hasLEQUpperBound) lequck ds) + (checkPVPs (checkDependencyVersionRange hasLEUpperBound) leuck ds) unless (isInternalTarget cet) (checkPVPs (checkDependencyVersionRange hasTrailingZeroUpperBound) tzuck ds) diff --git a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs index f0abad85278..a83440599b3 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs @@ -256,7 +256,7 @@ data CheckExplanation | UnknownCompiler [String] | BaseNoUpperBounds | MissingUpperBounds CEType [String] - | LEQUpperBounds CEType [String] + | LEUpperBounds CEType [String] | TrailingZeroUpperBounds CEType [String] | GTLowerBounds CEType [String] | SuspiciousFlagName [String] @@ -422,7 +422,7 @@ data CheckExplanationID | CIUnknownCompiler | CIBaseNoUpperBounds | CIMissingUpperBounds - | CILEQUpperBounds + | CILEUpperBounds | CITrailingZeroUpperBounds | CIGTLowerBounds | CISuspiciousFlagName @@ -567,7 +567,7 @@ checkExplanationId (UnknownArch{}) = CIUnknownArch checkExplanationId (UnknownCompiler{}) = CIUnknownCompiler checkExplanationId (BaseNoUpperBounds{}) = CIBaseNoUpperBounds checkExplanationId (MissingUpperBounds{}) = CIMissingUpperBounds -checkExplanationId (LEQUpperBounds{}) = CILEQUpperBounds +checkExplanationId (LEUpperBounds{}) = CILEUpperBounds checkExplanationId (TrailingZeroUpperBounds{}) = CITrailingZeroUpperBounds checkExplanationId (GTLowerBounds{}) = CIGTLowerBounds checkExplanationId (SuspiciousFlagName{}) = CISuspiciousFlagName @@ -720,7 +720,7 @@ ppCheckExplanationId CIMissingUpperBounds = "missing-upper-bounds" -- NOTE: Satisfy the Parsimonious test, a test that checks that these messages -- don't have too many dashes: -- $ cabal run Cabal-tests:unit-tests -- --pattern=Parsimonious -ppCheckExplanationId CILEQUpperBounds = "le-upper-bounds" +ppCheckExplanationId CILEUpperBounds = "le-upper-bounds" ppCheckExplanationId CITrailingZeroUpperBounds = "tz-upper-bounds" ppCheckExplanationId CIGTLowerBounds = "gt-lower-bounds" ppCheckExplanationId CISuspiciousFlagName = "suspicious-flag" @@ -1322,7 +1322,7 @@ ppExplanation (MissingUpperBounds ct names) = ++ "these packages miss upper bounds:" ++ listSep names ++ "Please add them. There is more information at https://pvp.haskell.org/" -ppExplanation (LEQUpperBounds ct names) = +ppExplanation (LEUpperBounds ct names) = "On " ++ ppCET ct ++ ", "