package semver2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Semantic version parsing and comparator following 2.0.0 specs. <https://semver.org/#semantic-versioning-200>

type t = private {
  1. major : int;
  2. minor : int;
  3. patch : int;
  4. prerelease : string list;
  5. build : string list;
}

A semantic version is composed of numeric major, minor and patch versions, optionnaly followed by a list of prerelease identifiers and a list of build identifiers.

val from_parts : int -> int -> int -> string list -> string list -> t option

Build a valid version from parts. Require positive values for major, minor and patch params.

val to_string : t -> string

Convert a version to its string representation.

val of_string : string -> t option

Parse a string version, returning None if format is invalid.

val is_valid : string -> bool

Check format validity.

val compare : t -> t -> int

Compare versions, returning 0 if equal, -1 if first has lower precedence, 1 otherwise.

val less_than : t -> t -> bool

Return true if first has lower precedence than second.

val greater_than : t -> t -> bool

Return true if first has higher precedence than second.

val equal : t -> t -> bool

Return whether versions are equal.

val pp : Format.formatter -> t -> unit

Pretty print version.

OCaml

Innovation. Community. Security.