module Releases : sig ... end
Module Ocaml_version
Manipulate, parse and generate OCaml version strings.
These are of the form major.minor.patch+extra
, where the patch
and extra
fields are optional.
val v : ?patch:int ‑> ?extra:string ‑> int ‑> int ‑> t
v ?patch ?extra major minor
will construct an OCaml version string with the appropriate parameters. Thepatch
andextra
indicators are optional, but it is conventional to include apatch
value of 0 for most recent OCaml releases.
Parsers and serializers
val to_string : ?sep:char ‑> t ‑> string
to_string ?sep t
will convert the versiont
into a human-readable representation. Thesep
will default to+
which is the normal representation of extra version strings, but can be changed to another character by supplyingsep
. One such usecase is to generate Docker container tags from OCaml version strings, where only dashes and alphanumeric characters are allowed.
val of_string : string ‑> (t, [> `Msg of string ]) Pervasives.result
of_string t
will parse the version string int
. The return value is compatible with theResult
combinators defined in therresult
library.
val of_string_exn : string ‑> t
of_string_exn t
behaves asof_string
but raisesInvalid_argument
if the string cannot be parsed.
val compare : t ‑> t ‑> int
compare a b
is the comparison function for two OCaml version strings. Returns-1
ifa<b
,0
if they are equal and1
ifa>b
. Comparison is done using integer comparison for the major, minor and patch versions, and lexical comparison for any extra version strings present.
val pp : Format.formatter ‑> t ‑> unit
pp fmt t
will output a human-readable version string oft
to thefmt
formatter.
Architecture Support
These definitions cover the CPU architectures that OCaml runs and is supported on.
type arch
=[
|
`X86_64
|
`Aarch64
|
`Ppc64le
]
Type of CPU architectures. TODO: This is currently an incomplete list, and lists just those used by the opam test systems. Contributions welcome to complete it.
val string_of_arch : arch ‑> string
string_of_arch arch
will convertarch
into a human-readable CPU architecture string. The result will follow the GOARCH convention used by Golang.
val arch_of_string : string ‑> (arch, [> `Msg of string ]) Pervasives.result
arch_of_string t
will parse the architecture string int
. The return value is compatible with theResult
combinators defined in therresult
library. This function is liberal and will attempt to understand variants of the same architecture. For example, bothaarch64
andarm64
are parsed into`Aarch64
.
val arch_of_string_exn : string ‑> arch
arch_of_string_exn t
is the same asarch_of_string
, except that it raisesInvalid_argument
in case of error.
Accessors
val major : t ‑> int
major t
will return the major version number of an OCaml release. For example,of_string "4.03.0" |> major
will return4
.
val minor : t ‑> int
minor t
will return the minor version number of an OCaml release. For example,of_string "4.03.0" |> minor
will return3
.
val patch : t ‑> int option
patch t
will return the patch version number of an OCaml release. For example,of_string "4.03.0" |> minor
will returnSome 0
.
val extra : t ‑> string option
extra t
will return the additional information string of an OCaml release. For example,of_string "4.03.0+flambda" |> extra
will returnSome "flambda"
.
val with_variant : t ‑> string option ‑> t
with_variant t extra
will return a fresh value with the extra version information int
toextra
, and remove it ifNone
is supplied.
val with_patch : t ‑> int option ‑> t
with_patch t patch
will return a fresh value with the patch number int
topatch
, and remove it ifNone
is supplied.
val without_patch : t ‑> t
without_patch t
is aswith_patch
t None
. It removes the least significant number from the version string. This is useful for the Docker OCaml containers, which are all named without a patch number and compiled using the latest patch release (e.g.4.06
instead of4.06.1
).
Constants
val sys_version : t
sys_version
is the version of OCaml that this library is currently compiled with, which will be the same asSys
.ocaml_version.
Feature Selection
module Since : sig ... end
module Has : sig ... end
module Opam : sig ... end