lilpack.semver

index ยท lilpack

Overview

Minimal semantic-version parsing and constraint matching for LILPACK dependency resolution.

Versions are X.Y.Z with optional missing minor/patch (defaulting to 0), an optional leading v, and an optional -prerelease suffix (build metadata after + is parsed and ignored, per the semver spec).

Constraint syntax is a single clause using one of >=, >, <=, <, =, ~>, or a bare version (treated as >=).

Functions

NameSignature
parseparse(s) -> version, err
comparecompare(a, b) -> order
satisfiessatisfies(version, constraint) -> ok

parse(s) -> version, err

Parse a version string into a normalized table

Parses s into { major, minor, patch, prerelease }. Missing minor or patch components default to 0. A single leading v is stripped. Build metadata (+...) is discarded. Returns nil and an error if the core triple contains non-numeric components.

compare(a, b) -> order

Compare two versions

Returns -1 if a < b, 0 if equal, 1 if a > b. Both arguments may be version strings or already-parsed tables. A version with a prerelease sorts below the same version without one.

satisfies(version, constraint) -> ok

Check whether a version satisfies a constraint

Returns true if version satisfies constraint. A nil or empty constraint matches anything. A bare version (no operator) is treated as >=. Supported operators: >=, >, <=, <, =, and ~> (pessimistic: ~>1.2 means >=1.2.0 <2.0.0; ~>1.2.3 means >=1.2.3 <1.3.0).