From e6304ff660ca629b1b664f0848a601959e31cb31 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov <mikhail.glushenkov@gmail.com> Date: Tue, 22 Sep 2015 09:07:31 +0200 Subject: [PATCH] Code simplification. --- Cabal/Distribution/Version.hs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Cabal/Distribution/Version.hs b/Cabal/Distribution/Version.hs index bd22429b71..2f0de5d784 100644 --- a/Cabal/Distribution/Version.hs +++ b/Cabal/Distribution/Version.hs @@ -286,9 +286,10 @@ foldVersionRange anyv this later earlier union intersect = fold (orLaterVersion v) (earlierVersion (wildcardUpperBound v)) --- | An extended variant of 'foldVersionRange' that also provides a view of --- in which the syntactic sugar @\">= v\"@, @\"<= v\"@ and @\"== v.*\"@ is presented --- explicitly rather than in terms of the other basic syntax. +-- | An extended variant of 'foldVersionRange' that also provides a view of the +-- expression in which the syntactic sugar @\">= v\"@, @\"<= v\"@ and @\"== +-- v.*\"@ is presented explicitly rather than in terms of the other basic +-- syntax. -- foldVersionRange' :: a -- ^ @\"-any\"@ version -> (Version -> a) -- ^ @\"== v\"@ @@ -812,14 +813,12 @@ instance Text VersionRange where -- -- @since 1.24.0.0 hasUpperBound :: VersionRange -> Bool -hasUpperBound AnyVersion = False -hasUpperBound (ThisVersion _) = True -hasUpperBound (LaterVersion _) = False -hasUpperBound (EarlierVersion _) = True -hasUpperBound (WildcardVersion _) = True -hasUpperBound (UnionVersionRanges x y) = hasUpperBound x && hasUpperBound y -hasUpperBound (IntersectVersionRanges x y) = hasUpperBound x || hasUpperBound y -hasUpperBound (VersionRangeParens x) = hasUpperBound x +hasUpperBound = foldVersionRange + False + (const True) + (const False) + (const True) + (&&) (||) -- | Does the version range have an explicit lower bound? -- @@ -828,11 +827,9 @@ hasUpperBound (VersionRangeParens x) = hasUpperBound x -- -- @since 1.24.0.0 hasLowerBound :: VersionRange -> Bool -hasLowerBound AnyVersion = False -hasLowerBound (ThisVersion _) = True -hasLowerBound (LaterVersion _) = True -hasLowerBound (EarlierVersion _) = False -hasLowerBound (WildcardVersion _) = True -hasLowerBound (UnionVersionRanges x y) = hasLowerBound x && hasLowerBound y -hasLowerBound (IntersectVersionRanges x y) = hasLowerBound x || hasLowerBound y -hasLowerBound (VersionRangeParens x) = hasLowerBound x +hasLowerBound = foldVersionRange + False + (const True) + (const True) + (const False) + (&&) (||) -- GitLab