Skip to content

Commit

Permalink
Add support for OCaml 5.3 (#1134)
Browse files Browse the repository at this point in the history
* Add support for OCaml 5.3

* Make the opam file pass the opam linter
  • Loading branch information
kit-ty-kate authored Nov 26, 2024
1 parent d22f5ed commit 00c591e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
4 changes: 2 additions & 2 deletions batteries.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ maintainer: [
"Simmo Saan <[email protected]>"
]
authors: ["OCaml batteries-included team"]
license: "LGPL-2.1-or-later with OCaml-LGPL-linking-exception"
license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
homepage: "https://github.com/ocaml-batteries-team/batteries-included"
doc: "http://ocaml-batteries-team.github.io/batteries-included/hdoc2/"
bug-reports:
Expand All @@ -25,7 +25,7 @@ depends: [
"num"
"odoc" {with-doc}
]
conflicts: ["base-effects" "ocaml-option-no-flat-float-array"]
conflicts: ["ocaml-option-no-flat-float-array"]
build: [
["dune" "subst"] {dev}
[
Expand Down
6 changes: 3 additions & 3 deletions benchsuite/lib/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ module Outliers = struct
(*note_outliers IO.stdout a;*)
mean a

type effect =
type eff =
| Unaffected (* less then 1% effect *)
| Slight (* between 1% and 10% *)
| Moderate (* between 10% and 50% *)
Expand Down Expand Up @@ -363,9 +363,9 @@ module Outliers = struct

let print_effect oc ov =
if ov > 0.00001 then (
let effect = effect_of_var ov |> effect_to_string in
let eff = effect_of_var ov |> effect_to_string in
fprintf oc "variance introduced by outliers: %.5f%%\n" (ov *. 100.);
fprintf oc "variance is %s by outliers\n" effect;
fprintf oc "variance is %s by outliers\n" eff;
)

end
Expand Down
3 changes: 1 addition & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"Gabriel Scherer <[email protected]>"
"Thibault Suzanne <[email protected]>"
"Simmo Saan <[email protected]>")
(license "LGPL-2.1-or-later with OCaml-LGPL-linking-exception")
(license "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception")

(package
(name batteries)
Expand All @@ -28,5 +28,4 @@
(benchmark (and :with-test (>= 1.6)))
num)
(conflicts
base-effects
ocaml-option-no-flat-float-array))
12 changes: 8 additions & 4 deletions src/batArray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ type 'a mappable = 'a t
##V=4.2##external make_float: int -> float array = "caml_make_float_vect"
##V=4.2##external create_float: int -> float array = "caml_make_float_vect"

##V>=4.3##external create_float: int -> float array = "caml_make_float_vect"
##V>=5.3##external create_float: int -> float array = "caml_array_create_float"
##V>=4.3####V<5.3##external create_float: int -> float array = "caml_make_float_vect"
##V>=4.3##let make_float = create_float

let singleton x = [|x|]
Expand Down Expand Up @@ -1038,11 +1039,14 @@ struct
external length : ('a, [> ]) t -> int = "%array_length"
external get : ('a, [> `Read]) t -> int -> 'a = "%array_safe_get"
external set : ('a, [> `Write]) t -> int -> 'a -> unit = "%array_safe_set"
external make : int -> 'a -> ('a, _) t = "caml_make_vect"
external create : int -> 'a -> ('a, _) t = "caml_make_vect"
##V>=5.3## external make : int -> 'a -> ('a, _) t = "caml_array_make"
##V<5.3## external make : int -> 'a -> ('a, _) t = "caml_make_vect"
##V>=5.3## external create : int -> 'a -> ('a, _) t = "caml_array_make"
##V<5.3## external create : int -> 'a -> ('a, _) t = "caml_make_vect"


##V>=4.2## external make_float: int -> (float, _) t = "caml_make_float_vect"
##V>=5.3## external make_float: int -> (float, _) t = "caml_array_create_float"
##V>=4.2####V<5.3## external make_float: int -> (float, _) t = "caml_make_float_vect"
##V<4.2## let make_float n = make n 0.

let init = init
Expand Down
15 changes: 10 additions & 5 deletions src/batArray.mli
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ external set : 'a array -> int -> 'a -> unit = "%array_safe_set"
@raise Invalid_argument
if [n] is outside the range 0 to [Array.length a - 1]. *)

external make : int -> 'a -> 'a array = "caml_make_vect"
##V>=5.3##external make : int -> 'a -> 'a array = "caml_array_make"
##V<5.3##external make : int -> 'a -> 'a array = "caml_make_vect"
(** [Array.make n x] returns a fresh array of length [n],
initialized with [x].
All the elements of this new array are initially
Expand All @@ -88,7 +89,8 @@ external make : int -> 'a -> 'a array = "caml_make_vect"
##V=4.2##external make_float: int -> float array = "caml_make_float_vect"
##V=4.2##val create_float: int -> float array

##V>=4.3##external create_float: int -> float array = "caml_make_float_vect"
##V>=5.3##external create_float : int -> float array = "caml_array_create_float"
##V>=4.3####V<5.3##external create_float: int -> float array = "caml_make_float_vect"
##V>=4.3##val make_float: int -> float array
(** [Array.make_float n] returns a fresh float array of length [n],
with uninitialized data.
Expand Down Expand Up @@ -730,11 +732,14 @@ sig

(**{1 Constructors}*)

external make : int -> 'a -> ('a, _) t = "caml_make_vect"
external create : int -> 'a -> ('a, _) t = "caml_make_vect"
##V>=5.3## external make : int -> 'a -> ('a, _) t = "caml_array_make"
##V<5.3## external make : int -> 'a -> ('a, _) t = "caml_make_vect"
##V>=5.3## external create : int -> 'a -> ('a, _) t = "caml_array_make"
##V<5.3## external create : int -> 'a -> ('a, _) t = "caml_make_vect"

##V<4.2## val make_float : int -> (float, _) t
##V>=4.2## external make_float : int -> (float, _) t = "caml_make_float_vect"
##V>=5.3## external make_float : int -> (float, _) t = "caml_array_create_float"
##V>=4.2####V<5.3## external make_float : int -> (float, _) t = "caml_make_float_vect"
(** [Array.make_float n] returns a fresh float array of length [n],
with uninitialized data.
Expand Down
5 changes: 5 additions & 0 deletions src/batQueue.mli
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ val peek : 'a t -> 'a
val top : 'a t -> 'a
(** [top] is a synonym for [peek]. *)

##V>=5.3##val drop : 'a t -> unit
##V>=5.3##(** [drop q] removes the first element in queue [q], or raises {!Empty}
##V>=5.3## if the queue is empty.
##V>=5.3## @since 3.9.0 and OCaml 5.3 *)

val clear : 'a t -> unit
(** Discard all elements from a queue. *)

Expand Down
6 changes: 6 additions & 0 deletions src/batSys.mli
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ val max_array_length : int
##V>=4.3## as the contents of the [OCAMLRUNPARAM] environment variable.
##V>=4.3## @since 2.5.0 and OCaml 4.03.0 *)

##V>=5.3##external poll_actions : unit -> unit = "%poll"
##V>=5.3##(** Run any pending runtime actions, such as minor collections, major
##V>=5.3## GC slices, signal handlers, finalizers, or memprof callbacks.
##V>=5.3## @since 3.9.0 and OCaml 5.3 *)


##V>=5.1##external is_regular_file : string -> bool = "caml_sys_is_regular_file"

(** {1 Signal handling} *)
Expand Down

0 comments on commit 00c591e

Please sign in to comment.