Semver
implements semantic versions for Carp.
Semantic versions are composed of a major, minor, and patch version, and might optionally have a tag.
Installation
(load "https://github.com/carpentry-org/semver@0.1.0")
<
(Fn [(Ref Semver a), (Ref Semver a)] Bool)
(< a b)
compares two semantic versions for precedence per SemVer 2.0.0 §11:
major, minor, and patch numerically, then — when those are equal — by
pre-release tag. A version with a pre-release tag (e.g. 1.0.0-rc.1) has lower
precedence than the corresponding release (1.0.0). Build metadata is ignored.
compare
(Fn [(Ref Semver a), (Ref Semver a)] Int)
(compare a b)
compares two versions under SemVer 2.0.0 precedence, returning
-1 when a ranks below b, 1 when it ranks above, and 0 when the two are
of equal precedence. Handy as an explicit three-way comparator.
set-tag!
(Fn [(Ref Semver a), (Maybe String)] ())
sets the tag property of a Semver in place.
str
(Fn [(Ref Semver a)] String)
(str s)
converts a semantic version to a string, e.g. 1.2.3 or 1.2.3-tag.
update-major
(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)
updates the major property of a Semver using a function f.
update-minor
(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)
updates the minor property of a Semver using a function f.
update-patch
(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)
updates the patch property of a Semver using a function f.
update-tag
(Fn [Semver, (Ref (Fn [(Maybe String)] (Maybe String) a) b)] Semver)
updates the tag property of a Semver using a function f.