Cabal-2.2.0.0: A framework for packaging Haskell software

Safe HaskellNone
LanguageHaskell2010

Distribution.Types.VersionRange

Contents

Synopsis

Version ranges

data VersionRange Source #

Instances
Eq VersionRange Source # 
Instance details
Data VersionRange Source # 
Instance details

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 Source # 
Instance details
Show VersionRange Source # 
Instance details
Generic VersionRange Source # 
Instance details

Associated Types

type Rep VersionRange :: * -> * #

Binary VersionRange Source # 
Instance details
NFData VersionRange Source # 
Instance details

Methods

rnf :: VersionRange -> () #

Pretty VersionRange Source # 
Instance details
Parsec VersionRange Source # 
Instance details
Text VersionRange Source # 
Instance details
Newtype TestedWith (CompilerFlavor, VersionRange) Source # 
Instance details
Newtype SpecVersion (Either Version VersionRange) Source # 
Instance details
type Rep VersionRange Source # 
Instance details
type Rep VersionRange = D1 (MetaData "VersionRange" "Distribution.Types.VersionRange" "Cabal-2.2.0.0-inplace" False) (((C1 (MetaCons "AnyVersion" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "ThisVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version))) :+: (C1 (MetaCons "LaterVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: (C1 (MetaCons "OrLaterVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: C1 (MetaCons "EarlierVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version))))) :+: ((C1 (MetaCons "OrEarlierVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: (C1 (MetaCons "WildcardVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: C1 (MetaCons "MajorBoundVersion" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)))) :+: (C1 (MetaCons "UnionVersionRanges" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 VersionRange) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 VersionRange)) :+: (C1 (MetaCons "IntersectVersionRanges" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 VersionRange) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 VersionRange)) :+: C1 (MetaCons "VersionRangeParens" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 VersionRange))))))

Constructing

anyVersion :: VersionRange Source #

The version range -any. That is, a version range containing all versions.

withinRange v anyVersion = True

noVersion :: VersionRange Source #

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 Source #

The version range == v

withinRange v' (thisVersion v) = v' == v

notThisVersion :: Version -> VersionRange Source #

The version range || v

withinRange v' (notThisVersion v) = v' /= v

laterVersion :: Version -> VersionRange Source #

The version range > v

withinRange v' (laterVersion v) = v' > v

earlierVersion :: Version -> VersionRange Source #

The version range < v

withinRange v' (earlierVersion v) = v' < v

orLaterVersion :: Version -> VersionRange Source #

The version range >= v

withinRange v' (orLaterVersion v) = v' >= v

orEarlierVersion :: Version -> VersionRange Source #

The version range <= v

withinRange v' (orEarlierVersion v) = v' <= v

unionVersionRanges :: VersionRange -> VersionRange -> VersionRange Source #

The version range vr1 || vr2

  withinRange v' (unionVersionRanges vr1 vr2)
= withinRange v' vr1 || withinRange v' vr2

intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange Source #

The version range vr1 && vr2

  withinRange v' (intersectVersionRanges vr1 vr2)
= withinRange v' vr1 && withinRange v' vr2

withinVersion :: Version -> VersionRange Source #

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 Source #

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 Source #

Does this version fall within the given range?

This is the evaluation function for the VersionRange type.

foldVersionRange Source #

Arguments

:: a

"-any" version

-> (Version -> a)
"== v"
-> (Version -> a)
"> v"
-> (Version -> a)
"< v"
-> (a -> a -> a)

"_ || _" union

-> (a -> a -> a)

"_ && _" intersection

-> 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 Source #

Normalise VersionRange.

In particular collapse (== v || > v) into >= v, and so on.

hasUpperBound :: VersionRange -> Bool Source #

Does the version range have an upper bound?

Since: 1.24.0.0

hasLowerBound :: VersionRange -> Bool Source #

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 Source #

F-Algebra of VersionRange. See cataVersionRange.

Since: 2.2

Instances
Functor VersionRangeF Source # 
Instance details

Methods

fmap :: (a -> b) -> VersionRangeF a -> VersionRangeF b #

(<$) :: a -> VersionRangeF b -> VersionRangeF a #

Foldable VersionRangeF Source # 
Instance details

Methods

fold :: Monoid m => VersionRangeF m -> m #

foldMap :: Monoid m => (a -> m) -> VersionRangeF a -> m #

foldr :: (a -> b -> b) -> b -> VersionRangeF a -> b #

foldr' :: (a -> b -> b) -> b -> VersionRangeF a -> b #

foldl :: (b -> a -> b) -> b -> VersionRangeF a -> b #

foldl' :: (b -> a -> b) -> b -> VersionRangeF a -> b #

foldr1 :: (a -> a -> a) -> VersionRangeF a -> a #

foldl1 :: (a -> a -> a) -> VersionRangeF a -> a #

toList :: VersionRangeF a -> [a] #

null :: VersionRangeF a -> Bool #

length :: VersionRangeF a -> Int #

elem :: Eq a => a -> VersionRangeF a -> Bool #

maximum :: Ord a => VersionRangeF a -> a #

minimum :: Ord a => VersionRangeF a -> a #

sum :: Num a => VersionRangeF a -> a #

product :: Num a => VersionRangeF a -> a #

Traversable VersionRangeF Source # 
Instance details

Methods

traverse :: Applicative f => (a -> f b) -> VersionRangeF a -> f (VersionRangeF b) #

sequenceA :: Applicative f => VersionRangeF (f a) -> f (VersionRangeF a) #

mapM :: Monad m => (a -> m b) -> VersionRangeF a -> m (VersionRangeF b) #

sequence :: Monad m => VersionRangeF (m a) -> m (VersionRangeF a) #

Eq a => Eq (VersionRangeF a) Source # 
Instance details
Data a => Data (VersionRangeF a) Source # 
Instance details

Methods

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

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

toConstr :: VersionRangeF a -> Constr #

dataTypeOf :: VersionRangeF a -> DataType #

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

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

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

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

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

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

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

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

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

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

Read a => Read (VersionRangeF a) Source # 
Instance details
Show a => Show (VersionRangeF a) Source # 
Instance details
Generic (VersionRangeF a) Source # 
Instance details

Associated Types

type Rep (VersionRangeF a) :: * -> * #

type Rep (VersionRangeF a) Source # 
Instance details
type Rep (VersionRangeF a) = D1 (MetaData "VersionRangeF" "Distribution.Types.VersionRange" "Cabal-2.2.0.0-inplace" False) (((C1 (MetaCons "AnyVersionF" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "ThisVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version))) :+: (C1 (MetaCons "LaterVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: (C1 (MetaCons "OrLaterVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: C1 (MetaCons "EarlierVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version))))) :+: ((C1 (MetaCons "OrEarlierVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: (C1 (MetaCons "WildcardVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)) :+: C1 (MetaCons "MajorBoundVersionF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Version)))) :+: (C1 (MetaCons "UnionVersionRangesF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :+: (C1 (MetaCons "IntersectVersionRangesF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :+: C1 (MetaCons "VersionRangeParensF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))))))

cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a Source #

Fold VersionRange.

Since: 2.2

anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange Source #

Unfold VersionRange.

Since: 2.2

Utilities

majorUpperBound :: Version -> Version Source #

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