Equations
- instReprParserError = { reprPrec := instReprParserError.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- instBEqParserError = { beq := instBEqParserError.beq }
Equations
Instances For
Returns a formatted string that contains the error message and position.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ParserError.instToString = { toString := ParserError.toString }
Defines a default with "unknown error" as message an implausible position for parser error.
Holds either the value of the given type, if parsing was successful or a parser error in case of failure.
- success {α : Type} : α → ParserResult α
- failure {α : Type} : ParserError → ParserResult α
Instances For
Equations
- instReprParserResult = { reprPrec := instReprParserResult.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- instBEqParserResult.beq (ParserResult.success a) (ParserResult.success b) = (a == b)
- instBEqParserResult.beq (ParserResult.failure a) (ParserResult.failure b) = (a == b)
- instBEqParserResult.beq x✝¹ x✝ = false
Instances For
Defines a default for ParserResult α based on the default of ParserError.
Equations
- instInhabitedParserResult = { default := ParserResult.failure default }
Converts a parser result into an optional value.
Equations
- (ParserResult.success a).to? = some a
- (ParserResult.failure a).to? = none
Instances For
Converts the value from a .success parser result
into an term of IO α and throws an error, if a .failure is provided.
Equations
- (ParserResult.success a).toIO! = pure a
- (ParserResult.failure a).toIO! = throw (IO.userError a.toString)
Instances For
Equations
Equations
- NonEmptyList.instLT α = { lt := NonEmptyList.lt }
Decidable less-then for NonEmptyList.
Equations
- a.decLt b = a.val.decidableLT b.val
Instances For
Provides a representation for a non empty list so that #eval can be used.
Instances For
Equations
- NonEmptyList.instRepr α = { reprPrec := NonEmptyList.repr }
Renders a non-empty list as string with its elements separated by ".".
For instance,
#eval toDotSeparatedString (⟨[0, 1, 2, 3, 4], rfl⟩ : NonEmptyList Nat)
results in "0.1.2.3.4".
Equations
- a.toDotSeparatedString = ".".intercalate (List.map (fun (a : α) => toString a) a.val)
Instances For
Parses the given string and, if possible, returns a result containing
a non-empty list of terms of type α.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- NonEmptyList.parse.helper [] parseElement = ParserResult.success []
Instances For
Equations
Equations
Equations
Less-then (lt) for non-empty strings.
Instances For
Equations
Equations
- a.decidableLT b = a.decLt b
Parses a given string and returns a result containing a non-empty string if possible.
Equations
- NonEmptyString.parse str = if h : (!str.isEmpty) = true then ParserResult.success ⟨str, h⟩ else ParserResult.failure { message := "string must not be empty", position := 0, input := some str }
Instances For
Converts a character representing a digit for base ten
to the natural number corresponding to this digit - for other
characters none is returned.
This implementation is seemingly better suited for proofs compared than e.g.
def toDigit? (c: Char) : Option Nat :=
if c.isDigit then
some (c.toNat - '0'.toNat)
else
none
Equations
Instances For
Is an alternative implementation to the standard function Char.isDigit
that is based on Char.toDigit?.
This implementation appears to be better suited for proofs than Char.isDigit.
Instances For
Converts a digit to a natural number and panics for characters that are no digits (for base ten).
Equations
Instances For
Returns true if the NonEmptyString that is provided as input only contains
digits (for base ten). It is based on Char.isDigit', so that it easier to
work with it in proofs.
Hence it is used here instead of shorter implementations like
def NonEmptyString.hasOnlyDigits (nes: NonEmptyString) : Bool := nes.val.isNat
Equations
Instances For
Equations
Instances For
Defines a subtype of NonEmptyString with the restriction that all
characters must be digits of base ten.
This is used for the definitions
<digits> ::= <digit>
| <digit> <digits>
<digit> ::= "0"
| <positive digit>
<positive digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Equations
- Digits = { nes : NonEmptyString // nes.hasOnlyDigits = true }
Instances For
Equations
- instDecidableEqDigits a b = a.instDecidableEq b
Equations
- Digits.toNat.helper [] x✝ = x✝
- Digits.toNat.helper (c :: cs) x✝ = Digits.toNat.helper cs (x✝ * 10 + c.toDigit!)
Instances For
Less-then relation for digits, which is based on Nat (and not String)
as defined in https://semver.org/ under 4.1:
Identifiers consisting of only digits are compared numerically.
This means that the canonical injection fun (a : Digits) => a.val
is not a strictly increasing function as the following example shows:
def a : NonEmptyString := ⟨"23", rfl⟩
def b : NonEmptyString := ⟨"123", rfl⟩
#eval b < a -- true
def a' : Digits := ⟨a, rfl⟩
def b' : Digits := ⟨b, rfl⟩
#eval a' < b' -- true
Instances For
Equations
- a.decidableLT b = a.decLt b
Converts strings to Digits if possible - wrapped into a
ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Detects if a given term of type Digits has a leading zero.
https://semver.org/ forbids leading zeros for both, numbers in the version core and numeric identifiers.
Equations
Instances For
Numeric identifiers are sequences of digits without leading zeros.
Examples: Strings "1234" and "0" are valid numeric identifiers
while "01" is not.
This is used for the definition
<numeric identifier> ::= "0"
| <positive digit>
| <positive digit> <digits>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Instances For
Equations
Equations
- instDecidableEqNumIdent a b = a.instDecidableEq b
Equations
- a.decidableLT b = a.decLt b
Parses strings into NumIdent wrapped into a ParserResult
if possible.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if a character is allowed for identifiers, i.e. it is either an letter (upper or lowercase), a digit (for base 10) or '-'.
This is used for the definition
<identifier character> ::= <digit>
| <non-digit>
<non-digit> ::= <letter>
| "-"
<digits> ::= <digit>
| <digit> <digits>
<digit> ::= "0"
| <positive digit>
<positive digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<letter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J"
| "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T"
| "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d"
| "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n"
| "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x"
| "y" | "z"
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Equations
- chr.isAllowedForIdentifier = (chr.isAlphanum || chr == '-')
Instances For
Checks if a NonEmptyString only contains characters that are allowed for identifiers.
Instances For
Equations
Instances For
Equations
- instDecidableEqIdent a b = a.instDecidableEq b
Equations
- a.decidableLT b = a.decLt b
Parses the given string and if it is not empty and contains only allowed
characters, returns an Ident wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true iff the character is allowed for identifiers but is not a digit,
i.e. is in [A-Za-z\-].
This is used for
<alphanumeric identifier> ::= <non-digit>
| <non-digit> <identifier characters>
| <identifier characters> <non-digit>
| <identifier characters> <non-digit> <identifier characters>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Instances For
Returns true iff at least one character in the given identifier is not a digit.
Equations
Instances For
Equations
- Ident.hasNonDigit.helper (chr :: tail) = if chr.isAllowedAndNonDigit = true then true else Ident.hasNonDigit.helper tail
- Ident.hasNonDigit.helper [] = false
Instances For
Equations
- AlphanumIdent = { i : Ident // i.hasNonDigit = true }
Instances For
Equations
Equations
Instances For
Equations
- AlphanumIdent.instLT = { lt := AlphanumIdent.lt }
Decidable less-then for AlphanumIdent.
Instances For
Equations
- a.decidableLT b = a.decLt b
Parses the given string and if it is a valid alphanumeric identifier,
returns it wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Defines build-identifiers in accordance with
<build identifier> ::= <alphanumeric identifier>
| <digits>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
- alphanumIdent (val : AlphanumIdent) : BuildIdent
- digits (val : Digits) : BuildIdent
Instances For
Equations
- instDecidableEqBuildIdent.decEq (BuildIdent.alphanumIdent a) (BuildIdent.alphanumIdent b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- instDecidableEqBuildIdent.decEq (BuildIdent.alphanumIdent val) (BuildIdent.digits val_1) = isFalse ⋯
- instDecidableEqBuildIdent.decEq (BuildIdent.digits val) (BuildIdent.alphanumIdent val_1) = isFalse ⋯
- instDecidableEqBuildIdent.decEq (BuildIdent.digits a) (BuildIdent.digits b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Equations
- instBEqBuildIdent = { beq := instBEqBuildIdent.beq }
Equations
- instBEqBuildIdent.beq (BuildIdent.alphanumIdent a) (BuildIdent.alphanumIdent b) = (a == b)
- instBEqBuildIdent.beq (BuildIdent.digits a) (BuildIdent.digits b) = (a == b)
- instBEqBuildIdent.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- instReprBuildIdent = { reprPrec := instReprBuildIdent.repr }
Returns the string representation of a build identifier.
Equations
Instances For
Equations
- BuildIdent.instToString = { toString := BuildIdent.toString }
Parses the given string and if it is a valid build identifier,
returns it wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Defines dot-separated build identifiers as non-empty lists of BuildIdents in accordance with
<dot-separated build identifiers> ::= <build identifier>
| <build identifier> "." <dot-separated build identifiers>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Equations
Instances For
Defines a default value for DotSepBuildIdents so that to!
can be used on ParserResult DotSepBuildIdents.
Equations
- One or more equations did not get rendered due to their size.
Returns the string representation of dot-separated build identifiers.
Instances For
Equations
- DotSepBuildIdents.instToString = { toString := DotSepBuildIdents.toString }
Parses the given string and if it is a valid dot-separated build identifiers,
retruns it wrapped in a ParserResult.
Equations
- DotSepBuildIdents.parse str = NonEmptyList.parse str BuildIdent.parse '.'
Instances For
Defines pre-release identifiers in accordance with
<pre-release identifier> ::= <alphanumeric identifier>
| <numeric identifier>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
- alphanumIdent (val : AlphanumIdent) : PreRelIdent
- numIdent (val : NumIdent) : PreRelIdent
Instances For
Equations
- instDecidableEqPreRelIdent.decEq (PreRelIdent.alphanumIdent a) (PreRelIdent.alphanumIdent b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- instDecidableEqPreRelIdent.decEq (PreRelIdent.alphanumIdent val) (PreRelIdent.numIdent val_1) = isFalse ⋯
- instDecidableEqPreRelIdent.decEq (PreRelIdent.numIdent val) (PreRelIdent.alphanumIdent val_1) = isFalse ⋯
- instDecidableEqPreRelIdent.decEq (PreRelIdent.numIdent a) (PreRelIdent.numIdent b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Equations
- instBEqPreRelIdent = { beq := instBEqPreRelIdent.beq }
Equations
- instBEqPreRelIdent.beq (PreRelIdent.alphanumIdent a) (PreRelIdent.alphanumIdent b) = (a == b)
- instBEqPreRelIdent.beq (PreRelIdent.numIdent a) (PreRelIdent.numIdent b) = (a == b)
- instBEqPreRelIdent.beq x✝¹ x✝ = false
Instances For
Equations
- instReprPreRelIdent = { reprPrec := instReprPreRelIdent.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Less-then for pre-release identifiers. Numeric identifiers always have lower precedence than alphanumeric (non-numeric) identifiers (see https://semver.org/, section 11.4.3).
Equations
- (PreRelIdent.alphanumIdent val).lt (PreRelIdent.numIdent val_1) = False
- (PreRelIdent.numIdent val).lt (PreRelIdent.alphanumIdent val_1) = True
- (PreRelIdent.alphanumIdent s).lt (PreRelIdent.alphanumIdent t) = (s < t)
- (PreRelIdent.numIdent s).lt (PreRelIdent.numIdent t) = (s < t)
Instances For
Equations
- PreRelIdent.instLT = { lt := PreRelIdent.lt }
Decidable less-then for PreRelIdent.
Equations
- (PreRelIdent.alphanumIdent s).decLt (PreRelIdent.alphanumIdent t) = if h : s < t then isTrue h else isFalse h
- (PreRelIdent.numIdent s).decLt (PreRelIdent.numIdent t) = if h : s < t then isTrue h else isFalse h
- (PreRelIdent.alphanumIdent val).decLt (PreRelIdent.numIdent val_1) = isFalse ⋯
- (PreRelIdent.numIdent val).decLt (PreRelIdent.alphanumIdent val_1) = isTrue ⋯
Instances For
Returns the string representation of a pre-release identifier.
Equations
Instances For
Equations
- PreRelIdent.instToString = { toString := PreRelIdent.toString }
Parses the given string and if it is a valid pre-release identifier, returns
it wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Defines dot-separated pre-release identifiers in accordance with
<dot-separated pre-release identifiers> ::= <pre-release identifier>
| <pre-release identifier> "." <dot-separated pre-release identifiers>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Provides a representation for dot-separated pre-release identifiers
so that #eval can be used.
Instances For
Equations
- DotSepPreRelIdents.instRepr = { reprPrec := DotSepPreRelIdents.repr }
Equations
- a.lt b = NonEmptyList.lt a b
Instances For
Equations
Instances For
Equations
- DotSepPreRelIdents.instToString = { toString := DotSepPreRelIdents.toString }
Parses the given string and if it is a valid dot-separated pre-release
identifiers, returns it wrapped in a ParserResult.
Equations
- DotSepPreRelIdents.parse str = NonEmptyList.parse str PreRelIdent.parse '.'
Instances For
Defines the version core in accordance with
<version core> ::= <major> "." <minor> "." <patch>
<major> ::= <numeric identifier>
<minor> ::= <numeric identifier>
<patch> ::= <numeric identifier>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
Version cores default to 1.0.0.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- instBEqVersionCore = { beq := instBEqVersionCore.beq }
Equations
- instReprVersionCore = { reprPrec := instReprVersionCore.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- instInhabitedVersionCore = { default := instInhabitedVersionCore.default }
Equations
- VersionCore.instToString = { toString := VersionCore.toString }
Less-then for version cores.
Instances For
Equations
- VersionCore.instLT = { lt := VersionCore.lt }
Decides if < holds true for two version cores.
Equations
- v.decLt w = v.toList.decidableLT w.toList
Instances For
Parses the given string and if it is a valid version core, returns it
wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Defines a full semantic version in accordance with
<version> ::= <version core>
| <version core> "-" <pre-release>
| <version core> "+" <build>
| <version core> "-" <pre-release> "+" <build>
<pre-release> ::= <dot-separated pre-release identifiers>
<build> ::= <dot-separated build identifiers>
(see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions).
- preRelease : Option DotSepPreRelIdents
- build : Option DotSepBuildIdents
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- instReprVersion = { reprPrec := instReprVersion.repr }
Equations
Instances For
Equations
- instInhabitedVersion = { default := instInhabitedVersion.default }
Returns the string representation of a version.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Version.instToString = { toString := Version.toString }
Helper function for comparing the parts of versions outside the version core.
Equations
Instances For
Less-then for versions in accordance with section 11 of the SemVer specification.
Equations
- v.lt w = (v.toVersionCore < w.toVersionCore ∨ v.toVersionCore = w.toVersionCore ∧ v.ltPreRelease w = true)
Instances For
Decides if < holds true for two versions.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Helper function that parses the version core and optional pre-release part of a version string.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parses the given string and if it is a valid version, returns it
wrapped in a ParserResult.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if public API provided under this version is stable.
Equations
Instances For
Returns a version that is the subsequent pre-release version based on the provided version and pre-release string.
If the resulting version is not greater than the provided version, or if
the pre-release string is invalid, none is returned.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns a version that is the same as the provided version but with the pre-release part set to the provided string.
If the resulting version is not greater than the provided version, or if
the pre-release string is invalid, none is returned.
Equations
Instances For
Returns a version that is the same as the provided version but with the build part set to the provided string.
If the given string is not valid as build metadata, none is returned.
Equations
Instances For
Helper function that checks if a character can be the start of a version in a string, given the previous character (if any).
Equations
Instances For
Helper function that checks if a character is valid in a version string.
Equations
- c.isValidForVersion = (c.isAllowedForIdentifier || c == '.' || c == '+')
Instances For
Equations
- c.addPreRelease? suffix = (Version.parse (toString c ++ toString "-" ++ toString suffix)).to?
Instances For
Helper that cuts off the prefix of a string that cannot be part of a version.
Equations
- cutOffPrefix ch str = { data := cutOffPrefix.helper ch str.data }
Instances For
Extracts all versions that are contained in a given string.
Equations
- extractVersions str = extractVersions.helper (str.split (not ∘ Char.isValidForVersion))