Skip to content

Commit

Permalink
v0.17~preview.128.37+01
Browse files Browse the repository at this point in the history
  • Loading branch information
public-release committed Aug 30, 2023
1 parent e3c05d3 commit 842bb24
Show file tree
Hide file tree
Showing 162 changed files with 5,269 additions and 5,371 deletions.
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
profile=janestreet
17 changes: 11 additions & 6 deletions hash_types/src/base_internalhash_types.ml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
(** [state] is defined as a subtype of [int] using the [private] keyword. This makes it an
opaque type for most purposes, and tells the compiler that the type is immediate. *)
type state = private int

type seed = int
type hash_value = int

external create_seeded : seed -> state = "%identity" [@@noalloc]
external fold_int64 : state -> int64 -> state = "Base_internalhash_fold_int64" [@@noalloc]
external fold_int : state -> int -> state = "Base_internalhash_fold_int" [@@noalloc]
external fold_float : state -> float -> state = "Base_internalhash_fold_float" [@@noalloc]
external fold_string : state -> string -> state = "Base_internalhash_fold_string" [@@noalloc]
external get_hash_value : state -> hash_value = "Base_internalhash_get_hash_value" [@@noalloc]
external create_seeded : seed -> state = "%identity" [@@noalloc]
external fold_int64 : state -> int64 -> state = "Base_internalhash_fold_int64" [@@noalloc]
external fold_int : state -> int -> state = "Base_internalhash_fold_int" [@@noalloc]
external fold_float : state -> float -> state = "Base_internalhash_fold_float" [@@noalloc]

external fold_string : state -> string -> state = "Base_internalhash_fold_string"
[@@noalloc]

external get_hash_value : state -> hash_value = "Base_internalhash_get_hash_value"
[@@noalloc]
6 changes: 4 additions & 2 deletions hash_types/test/test_immediate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ let%expect_test "[Base.Hash.state] is still immediate" =
require_no_allocation [%here] (fun () ->
ignore (Sys.opaque_identity (Base.Hash.create ())));
[%expect {| |}]
;;

let%expect_test _ =
print_s [%sexp (Stdlib.Obj.is_int (Stdlib.Obj.repr (Base.Hash.create ~seed:1 ())) : bool)];
[%expect {| true |}];
print_s
[%sexp (Stdlib.Obj.is_int (Stdlib.Obj.repr (Base.Hash.create ~seed:1 ())) : bool)];
[%expect {| true |}]
;;
18 changes: 9 additions & 9 deletions lint/ppx_base_lint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let zero_modules () =
|> Array.to_list
|> List.filter ~f:(fun fn -> Stdlib.Filename.check_suffix fn "0.ml")
|> List.map ~f:(fun fn ->
String.capitalize (String.sub fn ~pos:0 ~len:(String.length fn - 4)))
String.capitalize (String.sub fn ~pos:0 ~len:(String.length fn - 4)))
|> Set.of_list (module String)
;;

Expand Down Expand Up @@ -114,14 +114,14 @@ let check current_module =
let expansion =
Ppx_cold.expand_cold_attribute attr
|> List.map ~f:(fun a ->
{ a with
attr_name =
{ a.attr_name with
txt =
String.chop_prefix a.attr_name.txt ~prefix:"ocaml."
|> Option.value ~default:a.attr_name.txt
}
})
{ a with
attr_name =
{ a.attr_name with
txt =
String.chop_prefix a.attr_name.txt ~prefix:"ocaml."
|> Option.value ~default:a.attr_name.txt
}
})
in
let is_part_of_expansion attr =
List.exists expansion ~f:(fun a ->
Expand Down
20 changes: 7 additions & 13 deletions md5/src/md5_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@ type t = string

(* Share the digest of the empty string *)
let empty = Digest.string ""
let make s =
if s = empty then
empty
else
s

let make s = if s = empty then empty else s
let compare = compare

let length = 16

let to_binary s = s
let to_binary_local s = s
let of_binary_exn s = assert (String.length s = length); make s
let unsafe_of_binary = make

let of_binary_exn s =
assert (String.length s = length);
make s
;;

let unsafe_of_binary = make
let to_hex = Digest.to_hex
let of_hex_exn s = make (Digest.from_hex s)

let string s = make (Digest.string s)

let bytes s = make (Digest.bytes s)

let subbytes bytes ~pos ~len = make (Digest.subbytes bytes pos len)
3 changes: 0 additions & 3 deletions md5/src/md5_lib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ val unsafe_of_binary : string -> t

val to_hex : t -> string
val of_hex_exn : string -> t

val string : string -> t

val bytes : bytes -> t

val subbytes : bytes -> pos:int -> len:int -> t
112 changes: 56 additions & 56 deletions src/applicative.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ module Make3 (X : Basic3) : S3 with type ('a, 'd, 'e) t := ('a, 'd, 'e) X.t = st
end

module Make2 (X : Basic2) : S2 with type ('a, 'e) t := ('a, 'e) X.t = Make3 (struct
include X
include X

type ('a, 'd, 'e) t = ('a, 'd) X.t
end)
type ('a, 'd, 'e) t = ('a, 'd) X.t
end)

module Make (X : Basic) : S with type 'a t := 'a X.t = Make2 (struct
include X
include X

type ('a, 'e) t = 'a X.t
end)
type ('a, 'e) t = 'a X.t
end)

module Make_let_syntax3
(X : For_let_syntax3) (Intf : sig
module type S
end)
(Impl : Intf.S) =
(X : For_let_syntax3) (Intf : sig
module type S
end)
(Impl : Intf.S) =
struct
module Let_syntax = struct
include X
Expand All @@ -93,10 +93,10 @@ struct
end

module Make_let_syntax2
(X : For_let_syntax2) (Intf : sig
module type S
end)
(Impl : Intf.S) =
(X : For_let_syntax2) (Intf : sig
module type S
end)
(Impl : Intf.S) =
Make_let_syntax3
(struct
include X
Expand All @@ -107,10 +107,10 @@ module Make_let_syntax2
(Impl)

module Make_let_syntax
(X : For_let_syntax) (Intf : sig
module type S
end)
(Impl : Intf.S) =
(X : For_let_syntax) (Intf : sig
module type S
end)
(Impl : Intf.S) =
Make_let_syntax2
(struct
include X
Expand Down Expand Up @@ -158,17 +158,17 @@ end

module Make2_using_map2 (X : Basic2_using_map2) :
S2 with type ('a, 'e) t := ('a, 'e) X.t = Make3_using_map2 (struct
include X
include X

type ('a, 'd, 'e) t = ('a, 'd) X.t
end)
type ('a, 'd, 'e) t = ('a, 'd) X.t
end)

module Make_using_map2 (X : Basic_using_map2) : S with type 'a t := 'a X.t =
Make2_using_map2 (struct
include X
Make2_using_map2 (struct
include X

type ('a, 'e) t = 'a X.t
end)
type ('a, 'e) t = 'a X.t
end)

module Make3_using_map2_local (X : Basic3_using_map2_local) :
S3_local with type ('a, 'd, 'e) t := ('a, 'd, 'e) X.t = struct
Expand Down Expand Up @@ -207,66 +207,66 @@ end

module Make2_using_map2_local (X : Basic2_using_map2_local) :
S2_local with type ('a, 'e) t := ('a, 'e) X.t = Make3_using_map2_local (struct
include X
include X

type ('a, 'd, 'e) t = ('a, 'd) X.t
end)
type ('a, 'd, 'e) t = ('a, 'd) X.t
end)

module Make_using_map2_local (X : Basic_using_map2_local) :
S_local with type 'a t := 'a X.t = Make2_using_map2_local (struct
include X
include X

type ('a, 'e) t = 'a X.t
end)
type ('a, 'e) t = 'a X.t
end)

module Of_monad2 (M : Monad.S2) : S2 with type ('a, 'e) t := ('a, 'e) M.t = Make2 (struct
type ('a, 'e) t = ('a, 'e) M.t
type ('a, 'e) t = ('a, 'e) M.t

let return = M.return
let apply mf mx = M.bind mf ~f:(fun f -> M.map mx ~f)
let map = `Custom M.map
end)
let return = M.return
let apply mf mx = M.bind mf ~f:(fun f -> M.map mx ~f)
let map = `Custom M.map
end)

module Of_monad (M : Monad.S) : S with type 'a t := 'a M.t = Of_monad2 (struct
include M
include M

type ('a, _) t = 'a M.t
end)
type ('a, _) t = 'a M.t
end)

module Compose (F : S) (G : S) : S with type 'a t = 'a F.t G.t = struct
type 'a t = 'a F.t G.t

include Make (struct
type nonrec 'a t = 'a t
type nonrec 'a t = 'a t

let return a = G.return (F.return a)
let apply tf tx = G.apply (G.map ~f:F.apply tf) tx
let custom_map t ~f = G.map ~f:(F.map ~f) t
let map = `Custom custom_map
end)
let return a = G.return (F.return a)
let apply tf tx = G.apply (G.map ~f:F.apply tf) tx
let custom_map t ~f = G.map ~f:(F.map ~f) t
let map = `Custom custom_map
end)
end

module Pair (F : S) (G : S) : S with type 'a t = 'a F.t * 'a G.t = struct
type 'a t = 'a F.t * 'a G.t

include Make (struct
type nonrec 'a t = 'a t
type nonrec 'a t = 'a t

let return a = F.return a, G.return a
let apply tf tx = F.apply (fst tf) (fst tx), G.apply (snd tf) (snd tx)
let custom_map t ~f = F.map ~f (fst t), G.map ~f (snd t)
let map = `Custom custom_map
end)
let return a = F.return a, G.return a
let apply tf tx = F.apply (fst tf) (fst tx), G.apply (snd tf) (snd tx)
let custom_map t ~f = F.map ~f (fst t), G.map ~f (snd t)
let map = `Custom custom_map
end)
end

module Ident = struct
type 'a t = 'a

include Make_using_map2_local (struct
type nonrec 'a t = 'a t
type nonrec 'a t = 'a t

let return = Fn.id
let map2 a b ~f = f a b
let map = `Custom (fun a ~f -> f a)
end)
let return = Fn.id
let map2 a b ~f = f a b
let map = `Custom (fun a ~f -> f a)
end)
end
Loading

0 comments on commit 842bb24

Please sign in to comment.