Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module implements a view of a VersionRange
as a finite
list of separated version intervals.
In conversion from and to VersionRange
it makes some effort to
preserve the caret operator ^>=x.y
. This constraint a priori
specifies the same interval as ==x.y.*
, but indicates that newer
versions could be acceptable (allow-newer: ^
).
Synopsis
- data VersionIntervals
- unVersionIntervals :: VersionIntervals -> [VersionInterval]
- mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals
- toVersionIntervals :: VersionRange -> VersionIntervals
- fromVersionIntervals :: VersionIntervals -> VersionRange
- normaliseVersionRange2 :: VersionRange -> VersionRange
- relaxLastInterval :: VersionIntervals -> VersionIntervals
- relaxHeadInterval :: VersionIntervals -> VersionIntervals
- asVersionIntervals :: VersionRange -> [VersionInterval]
- data VersionInterval = VersionInterval !LowerBound !UpperBound
- data LowerBound = LowerBound !Version !Bound
- data UpperBound
- data Bound
- invariantVersionIntervals :: VersionIntervals -> Bool
Version intervals
data VersionIntervals Source #
A complementary representation of a VersionRange
. Instead of a boolean
version predicate it uses an increasing sequence of non-overlapping,
non-empty intervals.
The key point is that this representation gives a canonical representation
for the semantics of VersionRange
s. This makes it easier to check things
like whether a version range is empty, covers all versions, or requires a
certain minimum or maximum version. It also makes it easy to check equality
or containment. It also makes it easier to identify 'simple' version
predicates for translation into foreign packaging systems that do not
support complex version range expressions.
Instances
Show VersionIntervals Source # | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> VersionIntervals -> ShowS # show :: VersionIntervals -> String # showList :: [VersionIntervals] -> ShowS # | |
Eq VersionIntervals Source # | |
Defined in Distribution.Types.VersionInterval (==) :: VersionIntervals -> VersionIntervals -> Bool # (/=) :: VersionIntervals -> VersionIntervals -> Bool # |
unVersionIntervals :: VersionIntervals -> [VersionInterval] Source #
Inspect the list of version intervals.
mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals Source #
Directly construct a VersionIntervals
from a list of intervals.
Conversions
toVersionIntervals :: VersionRange -> VersionIntervals Source #
Convert a VersionRange
to a sequence of version intervals.
fromVersionIntervals :: VersionIntervals -> VersionRange Source #
Convert a VersionIntervals
value back into a VersionRange
expression
representing the version intervals.
Normalisation
normaliseVersionRange2 :: VersionRange -> VersionRange Source #
Since Cabal-3.6
this function.. TODO
Relaxation
Version intervals view
asVersionIntervals :: VersionRange -> [VersionInterval] Source #
View a VersionRange
as a union of intervals.
This provides a canonical view of the semantics of a VersionRange
as
opposed to the syntax of the expression used to define it. For the syntactic
view use foldVersionRange
.
Each interval is non-empty. The sequence is in increasing order and no
intervals overlap or touch. Therefore only the first and last can be
unbounded. The sequence can be empty if the range is empty
(e.g. a range expression like && 2
).
Other checks are trivial to implement using this view. For example:
isNoVersion vr | [] <- asVersionIntervals vr = True | otherwise = False
isSpecificVersion vr | [(LowerBound v InclusiveBound ,UpperBound v' InclusiveBound)] <- asVersionIntervals vr , v == v' = Just v | otherwise = Nothing
data VersionInterval Source #
Instances
Show VersionInterval Source # | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> VersionInterval -> ShowS # show :: VersionInterval -> String # showList :: [VersionInterval] -> ShowS # | |
Eq VersionInterval Source # | |
Defined in Distribution.Types.VersionInterval (==) :: VersionInterval -> VersionInterval -> Bool # (/=) :: VersionInterval -> VersionInterval -> Bool # |
data LowerBound Source #
Instances
Show LowerBound Source # | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> LowerBound -> ShowS # show :: LowerBound -> String # showList :: [LowerBound] -> ShowS # | |
Eq LowerBound Source # | |
Defined in Distribution.Types.VersionInterval (==) :: LowerBound -> LowerBound -> Bool # (/=) :: LowerBound -> LowerBound -> Bool # |
data UpperBound Source #
Instances
Show UpperBound Source # | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> UpperBound -> ShowS # show :: UpperBound -> String # showList :: [UpperBound] -> ShowS # | |
Eq UpperBound Source # | |
Defined in Distribution.Types.VersionInterval (==) :: UpperBound -> UpperBound -> Bool # (/=) :: UpperBound -> UpperBound -> Bool # |
Invariants
invariantVersionIntervals :: VersionIntervals -> Bool Source #
VersionIntervals
invariant:
- all intervals are valid (lower bound is less then upper bound, i.e. non-empty)
- intervals doesn't touch each other (distinct)