Cabal-2.2.0.0: A framework for packaging Haskell software

Distribution.Types.VersionInterval

Synopsis

# Version intervals

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 VersionRanges. 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
 Source # Instance detailsMethods Source # Instance detailsMethodsshowList :: [VersionIntervals] -> ShowS #

Convert a VersionRange to a sequence of version intervals.

Convert a VersionIntervals value back into a VersionRange expression representing the version intervals.

Test if a version falls within the version intervals.

It exists mostly for completeness and testing. It satisfies the following properties:

withinIntervals v (toVersionIntervals vr) = withinRange v vr
withinIntervals v ivs = withinRange v (fromVersionIntervals ivs)

Inspect the list of version intervals.

Directly construct a VersionIntervals from a list of intervals.

In Cabal-2.2 the Maybe is dropped from the result type.

# Version intervals view

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

Constructors

 LowerBound Version !Bound
Instances
 Source # Instance detailsMethods Source # Instance detailsMethods Source # Instance detailsMethodsshowList :: [LowerBound] -> ShowS #

Constructors

 NoUpperBound UpperBound Version !Bound
Instances
 Source # Instance detailsMethods Source # Instance detailsMethods Source # Instance detailsMethodsshowList :: [UpperBound] -> ShowS #

data Bound Source #

Constructors

 ExclusiveBound InclusiveBound
Instances
 Source # Instance detailsMethods(==) :: Bound -> Bound -> Bool #(/=) :: Bound -> Bound -> Bool # Source # Instance detailsMethodsshowsPrec :: Int -> Bound -> ShowS #show :: Bound -> String #showList :: [Bound] -> ShowS #