Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data VersionRange
- anyVersion :: VersionRange
- noVersion :: VersionRange
- thisVersion :: Version -> VersionRange
- notThisVersion :: Version -> VersionRange
- laterVersion :: Version -> VersionRange
- earlierVersion :: Version -> VersionRange
- orLaterVersion :: Version -> VersionRange
- orEarlierVersion :: Version -> VersionRange
- unionVersionRanges :: VersionRange -> VersionRange -> VersionRange
- intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
- withinVersion :: Version -> VersionRange
- majorBoundVersion :: Version -> VersionRange
- withinRange :: Version -> VersionRange -> Bool
- foldVersionRange :: a -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (a -> a -> a) -> (a -> a -> a) -> VersionRange -> a
- normaliseVersionRange :: VersionRange -> VersionRange
- stripParensVersionRange :: VersionRange -> VersionRange
- hasUpperBound :: VersionRange -> Bool
- hasLowerBound :: VersionRange -> Bool
- data VersionRangeF a
- cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a
- anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange
- hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange) -> (VersionRange -> VersionRangeF VersionRange) -> VersionRange -> VersionRange
- projectVersionRange :: VersionRange -> VersionRangeF VersionRange
- embedVersionRange :: VersionRangeF VersionRange -> VersionRange
- wildcardUpperBound :: Version -> Version
- majorUpperBound :: Version -> Version
- isWildcardRange :: Version -> Version -> Bool
- versionRangeParser :: forall m. CabalParsing m => m Int -> m VersionRange
Version ranges
data VersionRange #
Instances
Constructing
The version range -any
. That is, a version range containing all
versions.
withinRange v anyVersion = True
The empty version range, that is a version range containing no versions.
This can be constructed using any unsatisfiable version range expression,
for example > 1 && < 1
.
withinRange v noVersion = False
thisVersion :: Version -> VersionRange #
The version range == v
withinRange v' (thisVersion v) = v' == v
notThisVersion :: Version -> VersionRange #
The version range || v
withinRange v' (notThisVersion v) = v' /= v
laterVersion :: Version -> VersionRange #
The version range > v
withinRange v' (laterVersion v) = v' > v
earlierVersion :: Version -> VersionRange #
The version range < v
withinRange v' (earlierVersion v) = v' < v
orLaterVersion :: Version -> VersionRange #
The version range >= v
withinRange v' (orLaterVersion v) = v' >= v
orEarlierVersion :: Version -> VersionRange #
The version range <= v
withinRange v' (orEarlierVersion v) = v' <= v
unionVersionRanges :: VersionRange -> VersionRange -> VersionRange #
The version range vr1 || vr2
withinRange v' (unionVersionRanges vr1 vr2) = withinRange v' vr1 || withinRange v' vr2
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange #
The version range vr1 && vr2
withinRange v' (intersectVersionRanges vr1 vr2) = withinRange v' vr1 && withinRange v' vr2
withinVersion :: Version -> VersionRange #
The version range == v.*
.
For example, for version 1.2
, the version range == 1.2.*
is the same as
>= 1.2 && < 1.3
withinRange v' (laterVersion v) = v' >= v && v' < upper v where upper (Version lower t) = Version (init lower ++ [last lower + 1]) t
majorBoundVersion :: Version -> VersionRange #
The version range ^>= v
.
For example, for version 1.2.3.4
, the version range ^>= 1.2.3.4
is the same as >= 1.2.3.4 && < 1.3
.
Note that ^>= 1
is equivalent to >= 1 && < 1.1
.
Since: 2.0.0.2
Inspection
withinRange :: Version -> VersionRange -> Bool #
Does this version fall within the given range?
This is the evaluation function for the VersionRange
type.
:: a |
|
-> (Version -> a) | "== v" |
-> (Version -> a) | "> v" |
-> (Version -> a) | "< v" |
-> (a -> a -> a) |
|
-> (a -> a -> a) |
|
-> VersionRange | |
-> a |
Fold over the basic syntactic structure of a VersionRange
.
This provides a syntactic view of the expression defining the version range.
The syntactic sugar ">= v"
, "<= v"
and "== v.*"
is presented
in terms of the other basic syntax.
For a semantic view use asVersionIntervals
.
normaliseVersionRange :: VersionRange -> VersionRange #
Normalise VersionRange
.
In particular collapse (== v || > v)
into >= v
, and so on.
stripParensVersionRange :: VersionRange -> VersionRange #
Remove VersionRangeParens
constructors.
Since: 2.2
hasUpperBound :: VersionRange -> Bool #
Does the version range have an upper bound?
Since: 1.24.0.0
hasLowerBound :: VersionRange -> Bool #
Does the version range have an explicit lower bound?
Note: this function only considers the user-specified lower bounds, but not the implicit >=0 lower bound.
Since: 1.24.0.0
Cata & ana
data VersionRangeF a #
F-Algebra of VersionRange
. See cataVersionRange
.
Since: 2.2
Instances
cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a #
Fold VersionRange
.
Since: 2.2
anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange #
Unfold VersionRange
.
Since: 2.2
hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange) -> (VersionRange -> VersionRangeF VersionRange) -> VersionRange -> VersionRange #
Refold VersionRange
Since: 2.2
projectVersionRange :: VersionRange -> VersionRangeF VersionRange #
Since: 2.2
embedVersionRange :: VersionRangeF VersionRange -> VersionRange #
Since: 2.2
Utilities
wildcardUpperBound :: Version -> Version #
Since: 2.2
majorUpperBound :: Version -> Version #
Compute next greater major version to be used as upper bound
Example: 0.4.1
produces the version 0.5
which then can be used
to construct a range >= 0.4.1 && < 0.5
Since: 2.2
isWildcardRange :: Version -> Version -> Bool #
versionRangeParser :: forall m. CabalParsing m => m Int -> m VersionRange #
VersionRange
parser parametrised by version digit parser
versionDigitParser
is used for allVersionRange
.integral
is used for backward-compatpkgconfig-depends
versions,PkgConfigVersionRange
.
Since: 3.0