The library stdlib-random
is a small compatibility library that provides compiler-independent implementations of the PRNGs used in the history of the standard library Random
:
- stdlib-random.v3: implement the PRNG used in OCaml 3.07 to 3.11
- stdlib-random.v4: implement the PRNG used in OCaml 3.12 to 4.14
- stdlib-random.v5: implement the PRNG currently used in OCaml 5
- stdlib-random.v5o: implement the PRNG currently used in OCaml 5 in pure OCaml
This library is targeted toward programs that need a deterministic and stable behaviour of the Random
module across OCaml versions.
The newly released version 1.2.0 updates all implementations to provide the new int_in_range
function (and its int32_in_range
, nativeint_in_range
, int64_in_range
variants) that will be available in OCaml 5.2.0.
Note however that the implementations on the pre-OCaml 5 PRNGs are not optimal, since I prioritised the maintenance cost over performance, but that could be changed if required.