Semver
toStr : Semver -> Str
Render a semver to a string.
versionStr = "1.2.3-alpha+beta" version = parse versionStr expect toStr version == versionStr
parse : Str -> Result Semver InvalidSemverError
Parse a semver from a string.
This fails if there is any leftover text after the string. Use the parseLazy
twin function if you want to get the leftover text after parsing.
version = parse "1.2.3-alpha+beta" expect version == Ok { major: 1, minor: 2, patch: 3, preRelease: ["alpha"], build: ["beta"] }
parseLazy : Str -> Result ( Semver, Str ) InvalidSemverError
Parse a semver from a string, returning the leftover text after parsing on success.
If you don't need the leftover text, use the parse
twin function.
version = parse "1.2.3 abc" expect version == Ok { version: { major: 1, minor: 2, patch: 3, preRelease: [], build: [] }, rest: " abc", }
compare : Semver, Semver -> Ordering
Compare two semvers, useful for sorting.
version1 = { major: 1, minor: 2, patch: 3, preRelease: [], build: [] } version2 = { major: 1, minor: 3, patch: 0, preRelease: [], build: [] } expect compare version1 version2 == LT