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")

<

defn

(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.

=

defn

(Fn [(Ref Semver a), (Ref Semver a)] Bool)

                        (= o1 o2)
                    

>

defn

(Fn [a, a] Bool)

                        (> a b)
                    

compare

defn

(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.

copy

instantiate

(Fn [(Ref Semver a)] Semver)

copies a Semver.

delete

instantiate

(Fn [Semver] ())

deletes a Semver. Should usually not be called manually.

from-string

defn

(Fn [(Ref String a)] (Maybe Semver))

                        (from-string s)
                    

init

instantiate

(Fn [Int, Int, Int, (Maybe String)] Semver)

creates a Semver.

major

instantiate

(Fn [(Ref Semver a)] (Ref Int a))

gets the major property of a Semver.

minor

instantiate

(Fn [(Ref Semver a)] (Ref Int a))

gets the minor property of a Semver.

patch

instantiate

(Fn [(Ref Semver a)] (Ref Int a))

gets the patch property of a Semver.

prn

instantiate

(Fn [(Ref Semver a)] String)

converts a Semver to a string.

set-major

instantiate

(Fn [Semver, Int] Semver)

sets the major property of a Semver.

set-major!

instantiate

(Fn [(Ref Semver a), Int] ())

sets the major property of a Semver in place.

set-minor

instantiate

(Fn [Semver, Int] Semver)

sets the minor property of a Semver.

set-minor!

instantiate

(Fn [(Ref Semver a), Int] ())

sets the minor property of a Semver in place.

set-patch

instantiate

(Fn [Semver, Int] Semver)

sets the patch property of a Semver.

set-patch!

instantiate

(Fn [(Ref Semver a), Int] ())

sets the patch property of a Semver in place.

set-tag

instantiate

(Fn [Semver, (Maybe String)] Semver)

sets the tag property of a Semver.

set-tag!

instantiate

(Fn [(Ref Semver a), (Maybe String)] ())

sets the tag property of a Semver in place.

str

defn

(Fn [(Ref Semver a)] String)

                        (str s)
                    

converts a semantic version to a string, e.g. 1.2.3 or 1.2.3-tag.

tag

instantiate

(Fn [(Ref Semver a)] (Ref (Maybe String) a))

gets the tag property of a Semver.

update-major

instantiate

(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)

updates the major property of a Semver using a function f.

update-minor

instantiate

(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)

updates the minor property of a Semver using a function f.

update-patch

instantiate

(Fn [Semver, (Ref (Fn [Int] Int a) b)] Semver)

updates the patch property of a Semver using a function f.

update-tag

instantiate

(Fn [Semver, (Ref (Fn [(Maybe String)] (Maybe String) a) b)] Semver)

updates the tag property of a Semver using a function f.

zero

defn

(Fn [] Semver)

                        (zero)