Module

Data.Version

Package
purescript-versions
Repository
hdgarrood/purescript-versions

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 Source

data Version

A semver version.

Instances

#version Source

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

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

#runVersion Source

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.

#bumpMajor Source

bumpMajor :: Version -> Version

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

#bumpMinor Source

bumpMinor :: Version -> Version

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

#bumpPatch Source

bumpPatch :: Version -> Version

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

#numeric Source

numeric :: Int -> Identifier

Construct a numeric identifier.

#textual Source

textual :: String -> Maybe Identifier

Construct a textual identifier.

#isPreRelease Source

isPreRelease :: Version -> Boolean

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