package ocaml-version
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=6a8cce4bd5b60149ca4302ce587bff94
sha512=199533647516b1bea700046437c3b1f0d605e593c4bfd3b694f16944a6bfdba44297a45d696da1742c57bc621ecaafa2237cb3dc379f66f7fa2e1b2d93743022
doc/ocaml-version/Ocaml_version/index.html
Module Ocaml_versionSource
Manipulate, parse and generate OCaml version strings.
These are of the form major.minor.patch+extra, where the patch and extra fields are optional.
Type of an OCaml version string
v ?patch ?prerelease ?extra major minor will construct an OCaml version string with the appropriate parameters. The patch, prerelease, and extra indicators are optional, but it is conventional to include a patch value of 0 for most recent OCaml releases.
Parsers and serializers
to_string ?sep t will convert the version t into a human-readable representation. The sep will default to the normal representation of extra version strings:
~for prerelease version+otherwise This can be changed to another character by supplyingsepand potentiallyprerelease_sep. Ifsepis defined but notprerelease_sep, the prerelease separator is represented by twosepcharacters. One such use case is to generate Docker container tags from OCaml version strings, where only dashes and alphanumeric characters are allowed.
of_string t will parse the version string in t. The return value is compatible with the Result combinators defined in the rresult library.
of_string_exn t behaves as of_string but raises Invalid_argument if the string cannot be parsed.
equal a b is the equality function for two OCaml version strings. Returns true if they are equal, false if they are not.
compare a b is the comparison function for two OCaml version strings. Returns -1 if a<b, 0 if they are equal and 1 if a>b. Comparison is done using integer comparison for the major, minor and patch versions, and lexical comparison for any extra version strings present.
pp fmt t will output a human-readable version string of t to the fmt formatter.
Architecture Support
These definitions cover the CPU architectures that OCaml runs and is supported on.
Type of CPU architectures. This is currently an incomplete list, and lists just those used by the opam test systems. Contributions welcome to complete it.
string_of_arch arch will convert arch into a human-readable CPU architecture string. The result will follow the GOARCH convention used by Golang.
arch_of_string t will parse the architecture string in t. The return value is compatible with the Result combinators defined in the rresult library. This function is liberal and will attempt to understand variants of the same architecture. For example, both aarch64 and arm64 are parsed into Aarch64.
arch_of_string_exn t is the same as arch_of_string, except that it raises Invalid_argument in case of error.
arch_is_32bit t will return true if the architecture has a 32-bit wordsize.
to_opam_arch arch will return a string that is compatible with opam's %{arch}% variable.
of_opam_arch s will try to convert s that represents an opam %{arch}% variable to an arch value.
to_docker_arch arch will return a string that is compatible with a Docker multiarch property. This can be used in --platform flags to docker run, for example.
of_docker_arch s will try to convert s that represents a Docker multiarch variable to an arch value.
Accessors
major t will return the major version number of an OCaml release. For example, of_string "4.03.0" |> major will return 4.
minor t will return the minor version number of an OCaml release. For example, of_string "4.03.0" |> minor will return 3.
patch t will return the patch version number of an OCaml release. For example, of_string "4.03.0" |> minor will return Some 0.
prerelease t will return the prerelease extra string of an OCaml prerelease. For example, of_string "4.12.0~beta+flambda" |> prerelease will return Some "beta".
extra t will return the additional information string of an OCaml release. For example, of_string "4.03.0+flambda" |> extra will return Some "flambda".
with_variant t extra will return a fresh value with the extra version information in t to extra, and remove it if None is supplied.
without_variant t is with_variant t None. It removes any extra version information from the version string t.
with_patch t patch will return a fresh value with the patch number in t to patch, and remove it if None is supplied.
without_patch t is as with_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 of 4.06.1).
with_just_major_and_minor t strips out any patch and extra version information to return the X.Y form of the OCaml release. For example, 4.08.0+trunk+flambda will return the version representing 4.08.
Constants
sys_version is the version of OCaml that this library is currently compiled with, which will be the same as Sys.ocaml_version.
Feature Selection
Determine which release a feature or architecture first appeared in.
Configuration parameters that affect the behaviour of OCaml at compiler-build-time.
compiler_variants v returns a list of configuration options that are available and useful for version v of the compiler.
trunk_variants v returns a list of OCaml version configurations that should be working and tested on the trunk version of the compiler.
Opam compiler switches. These are available from the public opam-repository.