staversion-0.2.1.2: What version is the package X in stackage lts-Y.ZZ?

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellSafe
LanguageHaskell2010

Staversion.Internal.Version

Contents

Description

This is an internal module. End-users should not use it.

Synopsis

Re-exports

data Version :: * #

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.

Instances

IsList Version

Since: 4.8.0.0

Associated Types

type Item Version :: * #

Eq Version 

Methods

(==) :: Version -> Version -> Bool #

(/=) :: Version -> Version -> Bool #

Ord Version 
Read Version 
Show Version 
Generic Version 

Associated Types

type Rep Version :: * -> * #

Methods

from :: Version -> Rep Version x #

to :: Rep Version x -> Version #

Text Version 

Methods

disp :: Version -> Doc #

parse :: ReadP r Version #

Hashable Version 

Methods

hashWithSalt :: Int -> Version -> Int #

hash :: Version -> Int #

FromJSON Version 
FromJSONKey Version 
type Rep Version 
type Item Version 

data VersionRange :: * #

Instances

Eq VersionRange 
Data VersionRange 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> VersionRange -> c VersionRange #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c VersionRange #

toConstr :: VersionRange -> Constr #

dataTypeOf :: VersionRange -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c VersionRange) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c VersionRange) #

gmapT :: (forall b. Data b => b -> b) -> VersionRange -> VersionRange #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> VersionRange -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> VersionRange -> r #

gmapQ :: (forall d. Data d => d -> u) -> VersionRange -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> VersionRange -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> VersionRange -> m VersionRange #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> VersionRange -> m VersionRange #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> VersionRange -> m VersionRange #

Read VersionRange 
Show VersionRange 
Generic VersionRange 

Associated Types

type Rep VersionRange :: * -> * #

Binary VersionRange 
Text VersionRange 
type Rep VersionRange 

data Bound :: * #

Instances

Eq Bound 

Methods

(==) :: Bound -> Bound -> Bool #

(/=) :: Bound -> Bound -> Bool #

Show Bound 

Methods

showsPrec :: Int -> Bound -> ShowS #

show :: Bound -> String #

showList :: [Bound] -> ShowS #

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

Util

type BaseVersion = Version Source #

A Version type by Data.Version.

parseVersionText :: Text -> Maybe Version Source #

Parse a version text. There must not be any trailing characters after a valid version text.