HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

ModuleCabal-syntax-3.12.1.0Haskell2010

Distribution.Types.VersionRange

  • 2 types
  • 29 values

Version ranges

1 declaration
datadata VersionRange
#
Instances13Eq, Data, Ord, Read, Show, Generic, …

Constructing

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

withinRange v anyVersion = True

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

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

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.

Inspection

valuefoldVersionRange
  1. :: a

    "-any" version

  2. -> (Version -> a)
    "== v"
  3. -> (Version -> a)
    "> v"
  4. -> (Version -> a)
    "< v"
  5. -> (a -> a -> a)

    "_ || _" union

  6. -> (a -> a -> a)

    "_ && _" intersection

  7. -> VersionRange
  8. -> 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.

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.

Cata & ana

datadata VersionRangeF a
#

F-Algebra of VersionRange. See cataVersionRange.

Constructors

Instances9Functor, Foldable, Traversable, Eq, Data, Read, …

Utilities

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)

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.

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