Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
This is an internal module. End-users should not use it.
Synopsis
- 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
- asVersionIntervals :: VersionRange -> [VersionInterval]
- mkVersion :: [Int] -> Version
- mkVersionIntervals :: [VersionInterval] -> VersionIntervals
- versionNumbers :: Version -> [Int]
- type BaseVersion = Version
- showBaseVersion :: BaseVersion -> String
- parseVersionText :: Text -> Maybe Version
Re-exports
A Version
represents the version of a software entity.
Instances of Eq
and Ord
are provided, which gives exact
equality and lexicographic ordering of the version number
components (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2, etc.).
This type is opaque and distinct from the Version
type in
Data.Version since Cabal-2.0
. The difference extends to the
Binary
instance using a different (and more compact) encoding.
Since: Cabal-2.0.0.2
Instances
data VersionRange #
Instances
data LowerBound #
Instances
Eq LowerBound | |
Defined in Distribution.Types.VersionInterval (==) :: LowerBound -> LowerBound -> Bool # (/=) :: LowerBound -> LowerBound -> Bool # | |
Ord LowerBound | |
Defined in Distribution.Types.VersionInterval compare :: LowerBound -> LowerBound -> Ordering # (<) :: LowerBound -> LowerBound -> Bool # (<=) :: LowerBound -> LowerBound -> Bool # (>) :: LowerBound -> LowerBound -> Bool # (>=) :: LowerBound -> LowerBound -> Bool # max :: LowerBound -> LowerBound -> LowerBound # min :: LowerBound -> LowerBound -> LowerBound # | |
Show LowerBound | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> LowerBound -> ShowS # show :: LowerBound -> String # showList :: [LowerBound] -> ShowS # |
data UpperBound #
Instances
Eq UpperBound | |
Defined in Distribution.Types.VersionInterval (==) :: UpperBound -> UpperBound -> Bool # (/=) :: UpperBound -> UpperBound -> Bool # | |
Ord UpperBound | |
Defined in Distribution.Types.VersionInterval compare :: UpperBound -> UpperBound -> Ordering # (<) :: UpperBound -> UpperBound -> Bool # (<=) :: UpperBound -> UpperBound -> Bool # (>) :: UpperBound -> UpperBound -> Bool # (>=) :: UpperBound -> UpperBound -> Bool # max :: UpperBound -> UpperBound -> UpperBound # min :: UpperBound -> UpperBound -> UpperBound # | |
Show UpperBound | |
Defined in Distribution.Types.VersionInterval showsPrec :: Int -> UpperBound -> ShowS # show :: UpperBound -> String # showList :: [UpperBound] -> ShowS # |
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.
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 #