Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | Safe |
Language | Haskell2010 |
This is an internal module. End-users should not use it.
- data Version :: *
- data VersionRange :: *
- data LowerBound :: * = LowerBound Version ~Bound
- data UpperBound :: *
- data Bound :: *
- type VersionInterval = (LowerBound, UpperBound)
- thisVersion :: Version -> VersionRange
- unionVersionRanges :: VersionRange -> VersionRange -> VersionRange
- simplifyVersionRange :: VersionRange -> VersionRange
- fromVersionIntervals :: VersionIntervals -> VersionRange
- mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals
- asVersionIntervals :: VersionRange -> [VersionInterval]
- mkVersion :: [Int] -> Version
- versionNumbers :: Version -> [Int]
- type BaseVersion = Version
- showBaseVersion :: BaseVersion -> String
- parseVersionText :: Text -> Maybe Version
Re-exports
A Version
represents the version of a software entity.
An instance of Eq
is provided, which implements exact equality
modulo reordering of the tags in the versionTags
field.
An instance of Ord
is also provided, which gives lexicographic
ordering on the versionBranch
fields (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2,
etc.). This is expected to be sufficient for many uses, but note that
you may need to use a more specific ordering for your versioning
scheme. For example, some versioning schemes may include pre-releases
which have tags "pre1"
, "pre2"
, and so on, and these would need to
be taken into account when determining ordering. In some cases, date
ordering may be more appropriate, so the application would have to
look for date
tags in the versionTags
field and compare those.
The bottom line is, don't always assume that compare
and other Ord
operations are the right thing for every Version
.
Similarly, concrete representations of versions may differ. One
possible concrete representation is provided (see showVersion
and
parseVersion
), but depending on the application a different concrete
representation may be more appropriate.
data VersionRange :: * #
data UpperBound :: * #
type VersionInterval = (LowerBound, UpperBound) #
thisVersion :: Version -> VersionRange #
The version range == v
withinRange v' (thisVersion v) = v' == v
unionVersionRanges :: VersionRange -> VersionRange -> VersionRange #
The version range vr1 || vr2
withinRange v' (unionVersionRanges vr1 vr2) = withinRange v' vr1 || withinRange v' vr2
simplifyVersionRange :: VersionRange -> VersionRange #
Simplify a VersionRange
expression. For non-empty version ranges
this produces a canonical form. Empty or inconsistent version ranges
are left as-is because that provides more information.
If you need a canonical form use
fromVersionIntervals . toVersionIntervals
It satisfies the following properties:
withinRange v (simplifyVersionRange r) = withinRange v r
withinRange v r = withinRange v r' ==> simplifyVersionRange r = simplifyVersionRange r' || isNoVersion r || isNoVersion r'
fromVersionIntervals :: VersionIntervals -> VersionRange #
Convert a VersionIntervals
value back into a VersionRange
expression
representing the version intervals.
mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals #
Directly construct a VersionIntervals
from a list of intervals.
Each interval must be non-empty. The sequence must be in increasing order
and no intervals may overlap or touch. If any of these conditions are not
satisfied the function returns Nothing
.
asVersionIntervals :: VersionRange -> [VersionInterval] #
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
Compatibility
versionNumbers :: Version -> [Int] Source #
Util
type BaseVersion = Version Source #
A Version type by Data.Version.
showBaseVersion :: BaseVersion -> String Source #