Skip to content

Commit

Permalink
Add OCaml 5.2 support (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Feb 28, 2024
1 parent f879df6 commit 82942af
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/batArray.mli
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ external make : int -> 'a -> 'a array = "caml_make_vect"
@since 2.3.0
*)

##V>=5.2##val init_matrix : int -> int -> (int -> int -> 'a) -> 'a array array

##V>=4.07##val of_seq: 'a Seq.t -> 'a array
##V>=4.07##val to_seq: 'a array -> 'a Seq.t
##V>=4.07##val to_seqi: 'a array -> (int * 'a) Seq.t
Expand Down
2 changes: 2 additions & 0 deletions src/batBigarray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module A = struct include BatArray include BatArray.Labels end
module _ = (BatBigarray : module type of Bigarray)
because of the somewhat strange interpretation of strengthening in (module type of),
we need to explicitly equate each type with its constructor *)
##V>=5.2##type float16_elt = Bigarray.float16_elt = Float16_elt
type float32_elt = Bigarray.float32_elt
##V>=4.2## = Float32_elt
type float64_elt = Bigarray.float64_elt
Expand Down Expand Up @@ -68,6 +69,7 @@ type ('a, 'b) kind = ('a,'b) Bigarray.kind
##V>=4.2## | Complex32 : (Complex.t, complex32_elt) kind
##V>=4.2## | Complex64 : (Complex.t, complex64_elt) kind
##V>=4.2## | Char : (char, int8_unsigned_elt) kind
##V>=5.2## | Float16 : (float, float16_elt) kind

(* this type is local to Batteries,
it is meant to make it easier to port code
Expand Down
2 changes: 2 additions & 0 deletions src/batBigarray.mli
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
module _ = (BatBigarray : module type of Bigarray)
because of the somewhat strange interpretation of strengthening in (module type of),
we need to explicitly equate each type with its constructor *)
##V>=5.2##type float16_elt = Bigarray.float16_elt = Float16_elt
type float32_elt = Bigarray.float32_elt
##V>=4.2## = Float32_elt
type float64_elt = Bigarray.float64_elt
Expand Down Expand Up @@ -122,6 +123,7 @@ type ('a, 'b) kind = ('a,'b) Bigarray.kind
##V>=4.2## | Complex32 : (Complex.t, complex32_elt) kind
##V>=4.2## | Complex64 : (Complex.t, complex64_elt) kind
##V>=4.2## | Char : (char, int8_unsigned_elt) kind (**)
##V>=5.2## | Float16 : (float, float16_elt) kind
(** To each element kind is associated an OCaml type, which is
the type of OCaml values that can be stored in the big array
or read back from it. This type is not necessarily the same
Expand Down
23 changes: 23 additions & 0 deletions src/batDigest.mli
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,26 @@ val compare : t -> t -> int
val equal : t -> t -> bool
(** The equal function for digests.
@since 2.5.0 *)

##V>=5.2##val of_hex : string -> t

##V>=5.2##module type S = sig
##V>=5.2## type t = string
##V>=5.2## val hash_length : int
##V>=5.2## val compare : t -> t -> int
##V>=5.2## val equal : t -> t -> bool
##V>=5.2## val string : string -> t
##V>=5.2## val bytes : bytes -> t
##V>=5.2## val substring : string -> int -> int -> t
##V>=5.2## val subbytes : bytes -> int -> int -> t
##V>=5.2## val channel : Stdlib.in_channel -> int -> t
##V>=5.2## val file : string -> t
##V>=5.2## val output : Stdlib.out_channel -> t -> unit
##V>=5.2## val input : Stdlib.in_channel -> t
##V>=5.2## val to_hex : t -> string
##V>=5.2## val of_hex : string -> t
##V>=5.2##end
##V>=5.2##module BLAKE128 : S
##V>=5.2##module BLAKE256 : S
##V>=5.2##module BLAKE512 : S
##V>=5.2##module MD5 : S
5 changes: 4 additions & 1 deletion src/batGc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ val delete_alarm : alarm -> unit
##V>=4.11## notice. *)
##V>=4.11##module Memprof :
##V>=4.11## sig
##V>=5.2## type t = Gc.Memprof.t
##V>=4.12## type allocation_source = Gc.Memprof.allocation_source = Normal | Marshal | Custom
##V>=4.11## type allocation = Gc.Memprof.allocation = private
##V>=4.11## { n_samples : int;
Expand Down Expand Up @@ -476,7 +477,8 @@ val delete_alarm : alarm -> unit
##V>=4.11## sampling_rate:float ->
##V>=4.11## ?callstack_size:int ->
##V>=4.11## ('minor, 'major) tracker ->
##V>=4.11## unit
##V>=4.11####V<5.2## unit
##V>=5.2## t
##V>=4.11## (** Start the sampling with the given parameters. Fails if
##V>=4.11## sampling is already active.
##V>=4.11##
Expand Down Expand Up @@ -515,4 +517,5 @@ val delete_alarm : alarm -> unit
##V>=4.11##
##V>=4.11## Calling [stop] when a callback is running can lead to
##V>=4.11## callbacks not being called even though some events happened. *)
##V>=5.2## val discard : t -> unit
##V>=4.11##end
2 changes: 2 additions & 0 deletions src/batPrintexc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ val print : _ BatInnerIO.output -> exn -> unit
##V>=4.2## line_number : int;
##V>=4.2## start_char : int;
##V>=4.2## end_char : int;
##V>=5.2## end_line : int;
##V>=5.2## end_col : int;
##V>=4.2##}
##V>=4.2##(** The type of location information found in backtraces. [start_char]
##V>=4.2## and [end_char] are positions relative to the beginning of the
Expand Down
6 changes: 5 additions & 1 deletion src/batRandom.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ let self_init = Random.self_init
let bits = Random.bits
let int = Random.int
##V>=4.13##let full_int = Random.full_int
##V>=5.2##let int_in_range = Random.int_in_range
let int32 = Random.int32
##V>=5.2##let int32_in_range = Random.int32_in_range
let int64 = Random.int64
##V>=5.2##let int64_in_range = Random.int64_in_range
let nativeint = Random.nativeint
##V>=5.2##let nativeint_in_range = Random.nativeint_in_range
let float = Random.float
let bool = Random.bool
let char () = Char.chr (int 256)
Expand Down Expand Up @@ -70,7 +74,7 @@ struct

##V>=5## external next: t -> (int64[@unboxed])
##V>=5## = "caml_lxm_next" "caml_lxm_next_unboxed" [@@noalloc]

end

let enum_bits () = BatEnum.from bits
Expand Down
12 changes: 12 additions & 0 deletions src/batRandom.mli
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ val int : int -> int
##V>=4.13##
##V>=4.13## @since 3.4.0 and OCaml 4.13.0 *)

##V>=5.2##val int_in_range : min:int -> max:int -> int

val int32 : Int32.t -> Int32.t
(** [Random.int32 bound] returns a random integer between 0 (inclusive)
and [bound] (exclusive). [bound] must be greater than 0. *)

##V>=5.2##val int32_in_range : min:int32 -> max:int32 -> int32

val nativeint : Nativeint.t -> Nativeint.t
(** [Random.nativeint bound] returns a random integer between 0 (inclusive)
and [bound] (exclusive). [bound] must be greater than 0. *)

##V>=5.2##val nativeint_in_range : min:nativeint -> max:nativeint -> nativeint

val int64 : Int64.t -> Int64.t
(** [Random.int64 bound] returns a random integer between 0 (inclusive)
and [bound] (exclusive). [bound] must be greater than 0. *)
Expand All @@ -83,6 +89,8 @@ val float : float -> float
negative, the result is negative or zero. If [bound] is 0,
the result is 0. *)

##V>=5.2##val int64_in_range : min:int64 -> max:int64 -> int64

val bool : unit -> bool
(** [Random.bool ()] returns [true] or [false] with probability 0.5 each. *)

Expand Down Expand Up @@ -184,9 +192,13 @@ module State : sig
val bits : t -> int
val int : t -> int -> int
##V>=4.13##val full_int : t -> int -> int
##V>=5.2##val int_in_range : t -> min:int -> max:int -> int
val int32 : t -> Int32.t -> Int32.t
##V>=5.2##val int32_in_range : t -> min:int32 -> max:int32 -> int32
val nativeint : t -> Nativeint.t -> Nativeint.t
##V>=5.2##val nativeint_in_range : t -> min:nativeint -> max:nativeint -> nativeint
val int64 : t -> Int64.t -> Int64.t
##V>=5.2##val int64_in_range : t -> min:int64 -> max:int64 -> int64
val float : t -> float -> float
val bool : t -> bool
val char : t -> char
Expand Down
15 changes: 15 additions & 0 deletions src/batUnix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,23 @@ val read : file_descr -> Bytes.t -> int -> int -> int
[fd], storing them in string [buff], starting at position [ofs]
in string [buff]. Return the number of characters actually read. *)

##V>=5.2##val read_bigarray :
##V>=5.2## file_descr ->
##V>=5.2## (_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
##V>=5.2## int -> int -> int

val write : file_descr -> Bytes.t -> int -> int -> int
(** [write fd buff ofs len] writes [len] characters to descriptor
[fd], taking them from string [buff], starting at position [ofs]
in string [buff]. Return the number of characters actually
written. [write] repeats the writing operation until all characters
have been written or an error occurs. *)

##V>=5.2##val write_bigarray :
##V>=5.2## file_descr ->
##V>=5.2## (_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
##V>=5.2## int -> int -> int

val single_write : file_descr -> Bytes.t -> int -> int -> int
(** Same as [write], but attempts to write only once.
Thus, if an error occurs, [single_write] guarantees that no data
Expand All @@ -363,6 +373,11 @@ val single_write_substring : file_descr -> string -> int -> int -> int
@since 2.3.0
*)

##V>=5.2##val single_write_bigarray :
##V>=5.2## file_descr ->
##V>=5.2## (_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
##V>=5.2## int -> int -> int

(** {6 Interfacing with the standard input/output library} *)

val in_channel_of_descr : file_descr -> in_channel
Expand Down
6 changes: 5 additions & 1 deletion src/batteries_compattest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ open Batteries
module Stdlib_verifications = struct
(* This module asserts that all the BatFoo modules are actually
extensions of stdlib modules, and that no functionality is lost. *)
module Array_t = (Array : module type of Legacy.Array)
module Array_t =
(Array : sig
include module type of Legacy.Array
val shuffle : ?state:Random.State.t -> 'a array -> unit
end)
module Buffer_t =
(Buffer: sig
include module type of Legacy.Buffer
Expand Down

0 comments on commit 82942af

Please sign in to comment.