Commit bb9501bc authored by Simon Jakobi's avatar Simon Jakobi Committed by Mikhail Glushenkov
Browse files

Add differenceVersionRanges

(cherry picked from commit 0562d952)
parent 00f5d2c7
......@@ -53,6 +53,7 @@ module Distribution.Version (
laterVersion, earlierVersion,
orLaterVersion, orEarlierVersion,
unionVersionRanges, intersectVersionRanges,
differenceVersionRanges,
invertVersionRange,
withinVersion,
betweenVersionsInclusive,
......@@ -240,6 +241,16 @@ unionVersionRanges = UnionVersionRanges
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
intersectVersionRanges = IntersectVersionRanges
-- | The difference of two version ranges
--
-- > withinRange v' (differenceVersionRanges vr1 vr2)
-- > = withinRange v' vr1 && not (withinRange v' vr2)
--
-- @since 1.24.1.0
differenceVersionRanges :: VersionRange -> VersionRange -> VersionRange
differenceVersionRanges vr1 vr2 =
intersectVersionRanges vr1 (invertVersionRange vr2)
-- | The inverse of a version range
--
-- > withinRange v' (invertVersionRange vr)
......
......@@ -41,6 +41,7 @@ versionTests =
, property prop_orEarlierVersion
, property prop_unionVersionRanges
, property prop_intersectVersionRanges
, property prop_differenceVersionRanges
, property prop_invertVersionRange
, property prop_withinVersion
, property prop_foldVersionRange
......@@ -196,6 +197,11 @@ prop_intersectVersionRanges vr1 vr2 v' =
withinRange v' (intersectVersionRanges vr1 vr2)
== (withinRange v' vr1 && withinRange v' vr2)
prop_differenceVersionRanges :: VersionRange -> VersionRange -> Version -> Bool
prop_differenceVersionRanges vr1 vr2 v' =
withinRange v' (differenceVersionRanges vr1 vr2)
== (withinRange v' vr1 && not (withinRange v' vr2))
prop_invertVersionRange :: VersionRange -> Version -> Bool
prop_invertVersionRange vr v' =
withinRange v' (invertVersionRange vr)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment