Module

Data.Version

This module defines a Version data type, for representing software versions, according to the Semantic Versioning specification. To summarize, a Version consists of:

  • a MAJOR, MINOR, and a PATCH component, all of which are nonnegative integers.
  • optionally, a list of pre-release identifiers, consisting of ASCII letters, numbers, and hyphens, and which is separated from the three main components with a hyphen.
  • optionally, build metadata, consisting of ASCII letters, numbers, and hyphens, and which is separated from the rest of the version with a plus symbol.

Note that, according to the semver spec, version precedence must ignore any build metadata. Therefore, the Ord instance ignores the build metadata. In order to have the Eq instance agree with the Ord instance, the Eq instance ignores build metadata too.

#Version

data Version

A semver version.

Instances

#version

version :: Int -> Int -> Int -> List Identifier -> List Identifier -> Version

Smart constructor for versions. Negative integer components will be replaced with zeroes.

#runVersion

runVersion :: forall r. (Int -> Int -> Int -> List Identifier -> List Identifier -> r) -> Version -> r

Unpack a version. Useful for pattern matching.

The reason we have this function instead of exporting the Version constructor is that in this way we can guarantee that Version values are always valid.

#major

#minor

#isPreRelease

isPreRelease :: Version -> Boolean

Tells you whether a version is a pre-release version; that is, if it has any pre-release identifiers.

#bumpMajor

bumpMajor :: Version -> Version

Bump the major version, and discard any prerelease identifiers and build metadata.

#bumpMinor

bumpMinor :: Version -> Version

Bump the minor version, and discard any prerelease identifiers and build metadata.

#bumpPatch

bumpPatch :: Version -> Version

Bump the patch version, and discard any prerelease identifiers and build metadata.

#textual

textual :: String -> Maybe Identifier

Construct a textual identifier.

#numeric

numeric :: Int -> Identifier

Construct a numeric identifier.

#showVersion

Modules