Cabal-syntax-3.10.2.0: A library for working with .cabal files
CopyrightIsaac Jones Simon Marlow 2003-2004
Duncan Coutts 2008
LicenseBSD3
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Distribution.Version

Description

Exports the Version type along with a parser and pretty printer. A version is something like "1.3.3". It also defines the VersionRange data types. Version ranges are like ">= 1.2 && < 2".

Synopsis

Package versions

data Version Source #

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-syntax-2.0.0.2

Instances

Instances details
Parsec Version Source # 
Instance details

Defined in Distribution.Types.Version

Pretty Version Source # 
Instance details

Defined in Distribution.Types.Version

Structured Version Source # 
Instance details

Defined in Distribution.Types.Version

Data Version Source # 
Instance details

Defined in Distribution.Types.Version

Methods

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

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

toConstr :: Version -> Constr Source #

dataTypeOf :: Version -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Generic Version Source # 
Instance details

Defined in Distribution.Types.Version

Associated Types

type Rep Version 
Instance details

Defined in Distribution.Types.Version

Read Version Source # 
Instance details

Defined in Distribution.Types.Version

Show Version Source # 
Instance details

Defined in Distribution.Types.Version

Binary Version Source # 
Instance details

Defined in Distribution.Types.Version

NFData Version Source # 
Instance details

Defined in Distribution.Types.Version

Methods

rnf :: Version -> () Source #

Eq Version Source # 
Instance details

Defined in Distribution.Types.Version

Methods

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

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

Ord Version Source # 
Instance details

Defined in Distribution.Types.Version

type Rep Version Source # 
Instance details

Defined in Distribution.Types.Version

version0 :: Version Source #

Version 0. A lower bound of Version.

Since: Cabal-syntax-2.2

mkVersion :: [Int] -> Version Source #

Construct Version from list of version number components.

For instance, mkVersion [3,2,1] constructs a Version representing the version 3.2.1.

All version components must be non-negative. mkVersion [] currently represents the special null version; see also nullVersion.

Since: Cabal-syntax-2.0.0.2

mkVersion' :: Version -> Version Source #

Variant of mkVersion which converts a Data.Version Version into Cabal's Version type.

Since: Cabal-syntax-2.0.0.2

versionNumbers :: Version -> [Int] Source #

Unpack Version into list of version number components.

This is the inverse to mkVersion, so the following holds:

(versionNumbers . mkVersion) vs == vs

Since: Cabal-syntax-2.0.0.2

nullVersion :: Version Source #

Constant representing the special null Version

The nullVersion compares (via Ord) as less than every proper Version value.

Since: Cabal-syntax-2.0.0.2

alterVersion :: ([Int] -> [Int]) -> Version -> Version Source #

Apply function to list of version number components

alterVersion f == mkVersion . f . versionNumbers

Since: Cabal-syntax-2.0.0.2

Version ranges

data VersionRange Source #

Instances

Instances details
Parsec VersionRange Source #
>>> simpleParsec "^>= 3.4" :: Maybe VersionRange
Just (MajorBoundVersion (mkVersion [3,4]))

Small history:

-any and -none removed in 3.4 Use >=0 and <0 instead.

>>> map (`simpleParsec'` "-none") [CabalSpecV3_0, CabalSpecV3_4] :: [Maybe VersionRange]
[Just (EarlierVersion (mkVersion [0])),Nothing]

Set operations are introduced in 3.0

>>> map (`simpleParsec'` "^>= { 1.2 , 1.3 }") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe VersionRange]
[Nothing,Just (UnionVersionRanges (MajorBoundVersion (mkVersion [1,2])) (MajorBoundVersion (mkVersion [1,3])))]

^>= is introduced in 2.0

>>> map (`simpleParsec'` "^>=1.2") [CabalSpecV1_24, CabalSpecV2_0] :: [Maybe VersionRange]
[Nothing,Just (MajorBoundVersion (mkVersion [1,2]))]

-none is introduced in 1.22

>>> map (`simpleParsec'` "-none") [CabalSpecV1_20, CabalSpecV1_22] :: [Maybe VersionRange]
[Nothing,Just (EarlierVersion (mkVersion [0]))]

Operators are introduced in 1.8. Issues only a warning.

>>> map (`simpleParsecW'` "== 1 || ==2") [CabalSpecV1_6, CabalSpecV1_8] :: [Maybe VersionRange]
[Nothing,Just (UnionVersionRanges (ThisVersion (mkVersion [1])) (ThisVersion (mkVersion [2])))]

Wild-version ranges are introduced in 1.6. Issues only a warning.

>>> map (`simpleParsecW'` "== 1.2.*") [CabalSpecV1_4, CabalSpecV1_6] :: [Maybe VersionRange]
[Nothing,Just (IntersectVersionRanges (OrLaterVersion (mkVersion [1,2])) (EarlierVersion (mkVersion [1,3])))]
Instance details

Defined in Distribution.Types.VersionRange.Internal

Pretty VersionRange Source #
>>> fmap pretty (simpleParsec' CabalSpecV1_6 "== 3.2.*" :: Maybe VersionRange)
Just >=3.2 && <3.3
>>> fmap (prettyVersioned CabalSpecV1_6) (simpleParsec' CabalSpecV1_6 "== 3.2.*" :: Maybe VersionRange)
Just ==3.2.*
>>> fmap pretty (simpleParsec' CabalSpecV1_6 "-any" :: Maybe VersionRange)
Just >=0
>>> fmap (prettyVersioned CabalSpecV1_6) (simpleParsec' CabalSpecV1_6 "-any" :: Maybe VersionRange)
Just >=0
Instance details

Defined in Distribution.Types.VersionRange.Internal

Structured VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Data VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Methods

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

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

toConstr :: VersionRange -> Constr Source #

dataTypeOf :: VersionRange -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Generic VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Associated Types

type Rep VersionRange 
Instance details

Defined in Distribution.Types.VersionRange.Internal

type Rep VersionRange = D1 ('MetaData "VersionRange" "Distribution.Types.VersionRange.Internal" "Cabal-syntax-3.10.2.0-86d7" 'False) (((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 "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)))))
Read VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Show VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Binary VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

NFData VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Methods

rnf :: VersionRange -> () Source #

Eq VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Ord VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Newtype (CompilerFlavor, VersionRange) TestedWith Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

type Rep VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

type Rep VersionRange = D1 ('MetaData "VersionRange" "Distribution.Types.VersionRange.Internal" "Cabal-syntax-3.10.2.0-86d7" 'False) (((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 "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)))))

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 -none, that is a version range containing no versions.

This can be constructed using any unsatisfiable version range expression, for example < 0.

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' (withinVersion 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: Cabal-syntax-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.

isAnyVersion :: VersionRange -> Bool Source #

Does this VersionRange place any restriction on the Version or is it in fact equivalent to AnyVersion.

Note this is a semantic check, not simply a syntactic check. So for example the following is True (for all v).

isAnyVersion (EarlierVersion v `UnionVersionRanges` orLaterVersion v)

isNoVersion :: VersionRange -> Bool Source #

This is the converse of isAnyVersion. It check if the version range is empty, if there is no possible version that satisfies the version range.

For example this is True (for all v):

isNoVersion (EarlierVersion v `IntersectVersionRanges` LaterVersion v)

isSpecificVersion :: VersionRange -> Maybe Version Source #

Is this version range in fact just a specific version?

For example the version range ">= 3 && <= 3" contains only the version 3.

simplifyVersionRange :: VersionRange -> VersionRange Source #

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'

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.

stripParensVersionRange :: VersionRange -> VersionRange Source #

Remove VersionRangeParens constructors.

Since version 3.4 this function is id, there aren't VersionRangeParens constructor in VersionRange anymore.

Since: Cabal-syntax-2.2

hasUpperBound :: VersionRange -> Bool Source #

Does the version range have an upper bound?

Since: Cabal-syntax-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: Cabal-syntax-1.24.0.0

Cata & ana

data VersionRangeF a Source #

F-Algebra of VersionRange. See cataVersionRange.

Since: Cabal-syntax-2.2

Constructors

ThisVersionF Version

== version.

LaterVersionF Version

> version. NB: not >=

OrLaterVersionF Version

>= version.

EarlierVersionF Version

< version.

OrEarlierVersionF Version

<= version.

MajorBoundVersionF Version

^>= version, same as >= version && < MAJ(version)+1.

UnionVersionRangesF a a

||.

IntersectVersionRangesF a a

&&.

Instances

Instances details
Foldable VersionRangeF Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Methods

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

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

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

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

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

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

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

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

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

toList :: VersionRangeF a -> [a] Source #

null :: VersionRangeF a -> Bool Source #

length :: VersionRangeF a -> Int Source #

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

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

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

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

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

Traversable VersionRangeF Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Methods

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

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

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

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

Functor VersionRangeF Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Methods

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

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

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

Defined in Distribution.Types.VersionRange.Internal

Methods

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

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

toConstr :: VersionRangeF a -> Constr Source #

dataTypeOf :: VersionRangeF a -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Generic (VersionRangeF a) Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Associated Types

type Rep (VersionRangeF a) 
Instance details

Defined in Distribution.Types.VersionRange.Internal

type Rep (VersionRangeF a) = D1 ('MetaData "VersionRangeF" "Distribution.Types.VersionRange.Internal" "Cabal-syntax-3.10.2.0-86d7" 'False) (((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 "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)))))
Read a => Read (VersionRangeF a) Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

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

Defined in Distribution.Types.VersionRange.Internal

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

Defined in Distribution.Types.VersionRange.Internal

type Rep (VersionRangeF a) Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

type Rep (VersionRangeF a) = D1 ('MetaData "VersionRangeF" "Distribution.Types.VersionRange.Internal" "Cabal-syntax-3.10.2.0-86d7" 'False) (((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 "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)))))

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

Fold VersionRange.

Since: Cabal-syntax-2.2

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

Unfold VersionRange.

Since: Cabal-syntax-2.2

projectVersionRange :: VersionRange -> VersionRangeF VersionRange Source #

Generic destructor for VersionRange.

Since: Cabal-syntax-2.2

embedVersionRange :: VersionRangeF VersionRange -> VersionRange Source #

Generic constructor for VersionRange.

Since: Cabal-syntax-2.2

Utilities

wildcardUpperBound :: Version -> Version Source #

Increment the last version number.

Example: For 1.2 this returns 1.3 so that it can be used as upper bound when resolving == 1.2.*. For 0.4.1 it returns 0.4.2.

Since: Cabal-syntax-2.2

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: Cabal-syntax-2.2

Modification

removeUpperBound :: VersionRange -> VersionRange Source #

Given a version range, remove the highest upper bound. Example: (>= 1 && < 3) || (>= 4 && < 5) is converted to (>= 1 && || (= 4).

removeLowerBound :: VersionRange -> VersionRange Source #

Given a version range, remove the lowest lower bound. Example: (>= 1 && || (= 4 && < 5) is converted to (>= 0 && || (= 4 && < 5).

transformCaret :: VersionRange -> VersionRange Source #

Rewrite ^>= x.y.z into >= x.y.z && < x.(y+1)

Since: Cabal-syntax-3.6.0.0

transformCaretUpper :: VersionRange -> VersionRange Source #

Rewrite ^>= x.y.z into >= x.y.z

Since: Cabal-syntax-3.6.0.0

transformCaretLower :: VersionRange -> VersionRange Source #

Rewrite ^>= x.y.z into <x.(y+1)

Since: Cabal-syntax-3.6.0.0

Version intervals view

asVersionIntervals :: VersionRange -> [VersionInterval] Source #

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

data Bound Source #

Instances

Instances details
Show Bound Source # 
Instance details

Defined in Distribution.Types.VersionInterval

Eq Bound Source # 
Instance details

Defined in Distribution.Types.VersionInterval

Methods

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

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

VersionIntervals abstract type

The VersionIntervals type and the accompanying functions are exposed primarily for completeness and testing purposes. In practice asVersionIntervals is the main function to use to view a VersionRange as a bunch of VersionIntervals.

data VersionIntervals Source #

A complementary representation of a VersionRange. Instead of a boolean version predicate it uses an increasing sequence of non-overlapping, non-empty intervals.

The key point is that this representation gives a canonical representation for the semantics of VersionRanges. This makes it easier to check things like whether a version range is empty, covers all versions, or requires a certain minimum or maximum version. It also makes it easy to check equality or containment. It also makes it easier to identify 'simple' version predicates for translation into foreign packaging systems that do not support complex version range expressions.

toVersionIntervals :: VersionRange -> VersionIntervals Source #

Convert a VersionRange to a sequence of version intervals.

fromVersionIntervals :: VersionIntervals -> VersionRange Source #

Convert a VersionIntervals value back into a VersionRange expression representing the version intervals.

unVersionIntervals :: VersionIntervals -> [VersionInterval] Source #

Inspect the list of version intervals.