Skip to content

Commit

Permalink
v0.18~preview.129.38+45
Browse files Browse the repository at this point in the history
  • Loading branch information
public-release committed Aug 23, 2024
1 parent 5154f5d commit b6ea401
Show file tree
Hide file tree
Showing 151 changed files with 2,049 additions and 1,395 deletions.
2 changes: 1 addition & 1 deletion md5/src/md5_lib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val compare : t -> t -> int
val length : int

val to_binary : t -> string
val to_binary_local : t -> string
val to_binary_local : local_ t -> local_ string
val of_binary_exn : string -> t

(** assumes the input is 16 bytes without checking *)
Expand Down
67 changes: 38 additions & 29 deletions src/applicative_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module type Basic_local = sig

val return : 'a -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val map : 'a t -> f:('a -> 'b) -> 'b t
val map : 'a t -> f:local_ ('a -> 'b) -> 'b t
end

module type Basic_using_map2 = sig
Expand All @@ -64,8 +64,8 @@ module type Basic_using_map2_local = sig
type 'a t

val return : 'a -> 'a t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val map : [ `Define_using_map2 | `Custom of 'a t -> f:('a -> 'b) -> 'b t ]
val map2 : 'a t -> 'b t -> f:local_ ('a -> 'b -> 'c) -> 'c t
val map : [ `Define_using_map2 | `Custom of 'a t -> f:local_ ('a -> 'b) -> 'b t ]
end

module type Applicative_infix_gen = sig
Expand All @@ -83,7 +83,7 @@ end
module type Applicative_infix = Applicative_infix_gen with type ('a, 'b) fn := 'a -> 'b

module type Applicative_infix_local =
Applicative_infix_gen with type ('a, 'b) fn := 'a -> 'b
Applicative_infix_gen with type ('a, 'b) fn := local_ 'a -> 'b

module type For_let_syntax_gen = sig
type 'a t
Expand All @@ -104,8 +104,8 @@ module type For_let_syntax =

module type For_let_syntax_local =
For_let_syntax_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b

module type S_gen = sig
include For_let_syntax_gen
Expand All @@ -132,10 +132,10 @@ module type S =

module type S_local =
S_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> 'b -> 'c
and type ('a, 'b, 'c, 'd) fun3 := 'a -> 'b -> 'c -> 'd
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> local_ ('b -> 'c)
and type ('a, 'b, 'c, 'd) fun3 := 'a -> local_ ('b -> local_ ('c -> 'd))

module type Let_syntax = sig
type 'a t
Expand Down Expand Up @@ -172,7 +172,7 @@ module type Basic2_local = sig

val return : 'a -> ('a, _) t
val apply : ('a -> 'b, 'e) t -> ('a, 'e) t -> ('b, 'e) t
val map : ('a, 'e) t -> f:('a -> 'b) -> ('b, 'e) t
val map : ('a, 'e) t -> f:local_ ('a -> 'b) -> ('b, 'e) t
end

module type Basic2_using_map2 = sig
Expand All @@ -187,8 +187,10 @@ module type Basic2_using_map2_local = sig
type ('a, 'e) t

val return : 'a -> ('a, _) t
val map2 : ('a, 'e) t -> ('b, 'e) t -> f:('a -> 'b -> 'c) -> ('c, 'e) t
val map : [ `Define_using_map2 | `Custom of ('a, 'e) t -> f:('a -> 'b) -> ('b, 'e) t ]
val map2 : ('a, 'e) t -> ('b, 'e) t -> f:local_ ('a -> 'b -> 'c) -> ('c, 'e) t

val map
: [ `Define_using_map2 | `Custom of ('a, 'e) t -> f:local_ ('a -> 'b) -> ('b, 'e) t ]
end

module type Applicative_infix2_gen = sig
Expand All @@ -204,7 +206,7 @@ end
module type Applicative_infix2 = Applicative_infix2_gen with type ('a, 'b) fn := 'a -> 'b

module type Applicative_infix2_local =
Applicative_infix2_gen with type ('a, 'b) fn := 'a -> 'b
Applicative_infix2_gen with type ('a, 'b) fn := local_ 'a -> 'b

module type For_let_syntax2_gen = sig
type ('a, 'e) t
Expand All @@ -228,8 +230,8 @@ module type For_let_syntax2 =

module type For_let_syntax2_local =
For_let_syntax2_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b

module type S2_gen = sig
include For_let_syntax2_gen
Expand Down Expand Up @@ -264,10 +266,10 @@ module type S2 =

module type S2_local =
S2_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> 'b -> 'c
and type ('a, 'b, 'c, 'd) fun3 := 'a -> 'b -> 'c -> 'd
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> local_ ('b -> 'c)
and type ('a, 'b, 'c, 'd) fun3 := 'a -> local_ ('b -> local_ ('c -> 'd))

module type Let_syntax2 = sig
type ('a, 'e) t
Expand Down Expand Up @@ -317,10 +319,17 @@ module type Basic3_using_map2_local = sig
type ('a, 'd, 'e) t

val return : 'a -> ('a, _, _) t
val map2 : ('a, 'd, 'e) t -> ('b, 'd, 'e) t -> f:('a -> 'b -> 'c) -> ('c, 'd, 'e) t

val map2
: ('a, 'd, 'e) t
-> ('b, 'd, 'e) t
-> f:local_ ('a -> 'b -> 'c)
-> ('c, 'd, 'e) t

val map
: [ `Define_using_map2 | `Custom of ('a, 'd, 'e) t -> f:('a -> 'b) -> ('b, 'd, 'e) t ]
: [ `Define_using_map2
| `Custom of ('a, 'd, 'e) t -> f:local_ ('a -> 'b) -> ('b, 'd, 'e) t
]
end

module type Applicative_infix3_gen = sig
Expand All @@ -336,7 +345,7 @@ end
module type Applicative_infix3 = Applicative_infix3_gen with type ('a, 'b) fn := 'a -> 'b

module type Applicative_infix3_local =
Applicative_infix3_gen with type ('a, 'b) fn := 'a -> 'b
Applicative_infix3_gen with type ('a, 'b) fn := local_ 'a -> 'b

module type For_let_syntax3_gen = sig
type ('a, 'd, 'e) t
Expand All @@ -360,8 +369,8 @@ module type For_let_syntax3 =

module type For_let_syntax3_local =
For_let_syntax3_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b

module type S3_gen = sig
include For_let_syntax3_gen
Expand Down Expand Up @@ -400,10 +409,10 @@ module type S3 =

module type S3_local =
S3_gen
with type ('a, 'b) fn := 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> 'b -> 'c
and type ('a, 'b, 'c, 'd) fun3 := 'a -> 'b -> 'c -> 'd
with type ('a, 'b) fn := local_ 'a -> 'b
and type ('a, 'b) f_labeled_fn := f:local_ 'a -> 'b
and type ('a, 'b, 'c) fun2 := 'a -> local_ ('b -> 'c)
and type ('a, 'b, 'c, 'd) fun3 := 'a -> local_ ('b -> local_ ('c -> 'd))

module type Let_syntax3 = sig
type ('a, 'd, 'e) t
Expand Down
44 changes: 25 additions & 19 deletions src/array.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ include Array0

type 'a t = 'a array [@@deriving_inline compare ~localize, globalize, sexp, sexp_grammar]

let compare__local : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int = compare_array__local
let compare__local
: 'a. (local_ 'a -> local_ 'a -> int) -> local_ 'a t -> local_ 'a t -> int
=
compare_array__local
;;

let compare : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int = compare_array

let globalize : 'a. ('a -> 'a) -> 'a t -> 'a t =
fun (type a__009_) : ((a__009_ -> a__009_) -> a__009_ t -> a__009_ t) -> globalize_array
let globalize : 'a. (local_ 'a -> 'a) -> local_ 'a t -> 'a t =
fun (type a__009_) : ((local_ a__009_ -> a__009_) -> local_ a__009_ t -> a__009_ t) ->
globalize_array
;;

let t_of_sexp : 'a. (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t = array_of_sexp
Expand Down Expand Up @@ -50,9 +56,9 @@ let t_sexp_grammar : 'a. 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_gramma
module Sorter (S : sig
type 'a t

val get : 'a t -> int -> 'a
val set : 'a t -> int -> 'a -> unit
val length : 'a t -> int
val get : local_ 'a t -> int -> 'a
val set : local_ 'a t -> int -> 'a -> unit
val length : local_ 'a t -> int
end) =
struct
include S
Expand All @@ -65,8 +71,8 @@ struct

module type Sort = sig
val sort
: 'a t
-> compare:('a -> 'a -> int)
: local_ 'a t
-> compare:local_ ('a -> 'a -> int)
-> left:int (* leftmost index of sub-array to sort *)
-> right:int (* rightmost index of sub-array to sort *)
-> unit
Expand Down Expand Up @@ -150,16 +156,16 @@ struct
include Sort

val five_element_sort
: 'a t
-> compare:('a -> 'a -> int)
: local_ 'a t
-> compare:local_ ('a -> 'a -> int)
-> int
-> int
-> int
-> int
-> int
-> unit
end = struct
let five_element_sort arr ~(compare : _ -> _ -> _) m1 m2 m3 m4 m5 =
let five_element_sort arr ~(local_ compare : _ -> _ -> _) m1 m2 m3 m4 m5 =
let compare_and_swap i j =
if compare (get arr i) (get arr j) > 0 then swap arr i j
in
Expand Down Expand Up @@ -195,7 +201,7 @@ struct
by itself
To this end we look at the center 3 elements of the 5 and return pairs of equal
elements or the widest range *)
let choose_pivots arr ~(compare : _ -> _ -> _) ~left ~right =
let choose_pivots arr ~(local_ compare : _ -> _ -> _) ~left ~right =
let sixth = (right - left) / 6 in
let m1 = left + sixth in
let m2 = m1 + sixth in
Expand All @@ -213,7 +219,7 @@ struct
else m2_val, m4_val, false
;;

let dual_pivot_partition arr ~(compare : _ -> _ -> _) ~left ~right =
let dual_pivot_partition arr ~(local_ compare : _ -> _ -> _) ~left ~right =
let pivot1, pivot2, pivots_equal = choose_pivots arr ~compare ~left ~right in
(* loop invariants:
1. left <= l < r <= right
Expand Down Expand Up @@ -283,7 +289,7 @@ struct
;;
end

let sort ?pos ?len arr ~(compare : _ -> _ -> _) =
let sort ?pos ?len arr ~(local_ compare : _ -> _ -> _) =
let pos, len =
Ordered_collection_common.get_pos_len_exn () ?pos ?len ~total_length:(length arr)
in
Expand Down Expand Up @@ -398,7 +404,7 @@ let[@inline always] extremal_element t ~compare ~keep_left_if =
if is_empty t
then None
else (
let result = ref (unsafe_get t 0) in
let local_ result = ref (unsafe_get t 0) in
for i = 1 to length t - 1 do
let x = unsafe_get t i in
result := Bool.select ((keep_left_if [@inlined]) (compare x !result)) x !result
Expand Down Expand Up @@ -443,16 +449,16 @@ let fold_mapi t ~init ~f =
!acc, result
;;

let count t ~f =
let result = ref 0 in
let count t ~(local_ f) =
let local_ result = ref 0 in
for i = 0 to Array.length t - 1 do
result := !result + (f (Array.unsafe_get t i) |> Bool.to_int)
done;
!result
;;

let counti t ~f =
let result = ref 0 in
let counti t ~(local_ f) =
let local_ result = ref 0 in
for i = 0 to Array.length t - 1 do
result := !result + (f i (Array.unsafe_get t i) |> Bool.to_int)
done;
Expand Down
Loading

0 comments on commit b6ea401

Please sign in to comment.