PubGrub.Range

Dealing with version ranges union and intersection.

type Range

A range corresponds to any set of versions representable as a concatenation, union, and complement of version ranges building blocks.

Those building blocks are:

  • none: the empty set
  • any: the set of all possible versions
  • exact v: the singleton set of only version v
  • higherThan v: the set of versions higher or equal to v
  • lowerThan v: the set of versions strictly lower than v
  • between v1 v2: the set of versions higher or equal to v1 and strictly lower than v2

Internally, they are represented as an ordered list of intervals to have a normalized form enabling comparisons of ranges.

toDebugString : Range -> String

Displayable representation of a range, for debug purposes

Creation of a range selection

Empty set of versions.

none == lowerThan zero

Set of all possible versions.

any == higherThan zero

Set containing exactly one version.

exact v == intersection (higherThan v) (lowerThan <| bumpPatch v)

Set of all versions higher or equal to some version.

Set of all versions strictly lower than some version.

Set of versions comprised between two given versions. The lower bound is included and the higher bound excluded. v1 <= v < v2.

between v1 v2 == intersection (higherThan v1) (lowerThan v2)

Set operations on ranges

Compute the complement set of versions.

Compute intersection of two sets of versions.

Compute union of two sets of versions.

Evaluate if a range contains a given version

contains : Version -> Range -> Bool

Check if a range selection contains a given version.