Commit 7d0cefeb authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

New function: 'relaxUpperBound :: VersionRange -> VersionRange'.

parent 9a5b601b
......@@ -68,6 +68,9 @@ module Distribution.Version (
foldVersionRange,
foldVersionRange',
-- ** Modification
relaxUpperBound,
-- * Version intervals view
asVersionIntervals,
VersionInterval,
......@@ -237,6 +240,18 @@ betweenVersionsInclusive v1 v2 =
{-# DEPRECATED betweenVersionsInclusive
"In practice this is not very useful because we normally use inclusive lower bounds and exclusive upper bounds" #-}
-- | Given a version range, remove the highest upper bound. Example: @(>= 1 && <
-- 3) || (>= 4 && < 5)@ is converted to @(>= 1 && < 3) || (>= 4)@.
relaxUpperBound :: VersionRange -> VersionRange
relaxUpperBound = fromVersionIntervals . relaxLastInterval . toVersionIntervals
where
relaxLastInterval (VersionIntervals intervals) =
VersionIntervals (relaxLastInterval' intervals)
relaxLastInterval' [] = []
relaxLastInterval' [(l,_)] = [(l, NoUpperBound)]
relaxLastInterval' (i:is) = i : relaxLastInterval' is
-- | Fold over the basic syntactic structure of a 'VersionRange'.
--
-- This provides a syntacic view of the expression defining the version range.
......
Markdown is supported
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