Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Caml with Stdlib #427

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ unreleased

- Adopt the OCaml Code of Conduct on the repo (#426, @pitag-ha)

- Replace `Caml` with `Stdlib`. (#427, @ceastlund)

- Clean up misleading attribute hints when declared for proper context. (#425, @ceastlund)

- Ast_pattern now has ebool, pbool helper, and a new map.(#402, @burnleydev1)
Expand Down
30 changes: 15 additions & 15 deletions bench/drivers/identity/inputs/bap_knowledge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type conflict = exn = ..
module Conflict = struct
type t = conflict = ..

let to_string = Caml.Printexc.to_string
let to_string = Stdlib.Printexc.to_string
let pp ppf err = Format.fprintf ppf "%s" (to_string err)
let register_printer = Caml.Printexc.register_printer
let register_printer = Stdlib.Printexc.register_printer
let sexp_of_t err = Sexp.Atom (to_string err)
end

Expand Down Expand Up @@ -153,22 +153,22 @@ end = struct

let rec find_exn t k =
match t with
| Nil -> raise Caml.Not_found
| Nil -> raise Stdlib.Not_found
| Tip (k', v) when k = k' -> v
| Tip _ -> raise Caml.Not_found
| Tip _ -> raise Stdlib.Not_found
| Bin (k', l, r) -> (
match Key.compare k' k with
| NA -> raise Caml.Not_found
| NA -> raise Stdlib.Not_found
| LB -> find_exn l k
| RB -> find_exn r k)

let find t k = try Some (find_exn t k) with Caml.Not_found -> None
let find t k = try Some (find_exn t k) with Stdlib.Not_found -> None

let mem k t =
try
ignore (find_exn k t);
true
with Caml.Not_found -> false
with Stdlib.Not_found -> false

let node payload branching l r =
match (l, r) with
Expand Down Expand Up @@ -359,7 +359,7 @@ end = struct

let unescaped_exists_so_escape ?(skip_pos = -1) s =
let buf = Buffer.create (String.length s + 1) in
Caml.StringLabels.iteri s ~f:(fun p c ->
Stdlib.StringLabels.iteri s ~f:(fun p c ->
if p <> skip_pos && is_separator_unescaped s p c then
Buffer.add_char buf escape_char;
Buffer.add_char buf c);
Expand Down Expand Up @@ -555,7 +555,7 @@ end = struct
let register ?(desc = "no description provided") ?package
?(reliability = trustworthy) name =
let name = Name.create ?package name in
let agent = Caml.Digest.string (Name.show name) in
let agent = Stdlib.Digest.string (Name.show name) in
if Hashtbl.mem agents agent then
failwithf
"An agent with name `%a' already exists, please choose another name"
Expand Down Expand Up @@ -2577,7 +2577,7 @@ module Knowledge = struct
slot : Name.t;
repr : string;
error : Conflict.t;
trace : Caml.Printexc.raw_backtrace;
trace : Stdlib.Printexc.raw_backtrace;
}

let () =
Expand All @@ -2587,7 +2587,7 @@ module Knowledge = struct
@@ Format.asprintf
"Unable to update the slot %a of %s,\n%a\nBacktrace:\n%s" Name.pp
slot repr Conflict.pp error
(Caml.Printexc.raw_backtrace_to_string trace)
(Stdlib.Printexc.raw_backtrace_to_string trace)
| _ -> None)

let non_monotonic slot obj error trace =
Expand Down Expand Up @@ -2626,7 +2626,7 @@ module Knowledge = struct
};
}
with Record.Merge_conflict err ->
non_monotonic slot obj err @@ Caml.Printexc.get_raw_backtrace ())
non_monotonic slot obj err @@ Stdlib.Printexc.get_raw_backtrace ())

let notify { Slot.watchers } obj data =
Hashtbl.data watchers
Expand Down Expand Up @@ -2698,7 +2698,7 @@ module Knowledge = struct
fun slot obj ->
objects slot.cls >>| fun { vals } ->
match Oid.Tree.find_exn vals obj with
| exception Caml.Not_found -> Sleep
| exception Stdlib.Not_found -> Sleep
| { data; comp = slots } -> (
match Map.find slots (uid slot) with
| Some (Work _) -> Awoke
Expand Down Expand Up @@ -2771,7 +2771,7 @@ module Knowledge = struct
fun slot id ->
objects slot.cls >>| fun { Env.vals } ->
match Oid.Tree.find_exn vals id with
| exception Caml.Not_found -> slot.dom.empty
| exception Stdlib.Not_found -> slot.dom.empty
| { data } -> Record.get slot.key slot.dom data

let rec collect_inner : ('a, 'p) slot -> 'a obj -> _ -> _ =
Expand Down Expand Up @@ -3030,7 +3030,7 @@ module Knowledge = struct
compute_value cls obj >>= fun () ->
objects cls >>| fun { Env.vals } ->
match Oid.Tree.find_exn vals obj with
| exception Caml.Not_found -> Value.empty cls
| exception Stdlib.Not_found -> Value.empty cls
| { data = x } -> Value.create cls x

let run cls obj s =
Expand Down
30 changes: 15 additions & 15 deletions bench/drivers/ppx_sexp_conv/inputs/bap_knowledge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type conflict = exn = ..
module Conflict = struct
type t = conflict = ..

let to_string = Caml.Printexc.to_string
let to_string = Stdlib.Printexc.to_string
let pp ppf err = Format.fprintf ppf "%s" (to_string err)
let register_printer = Caml.Printexc.register_printer
let register_printer = Stdlib.Printexc.register_printer
let sexp_of_t err = Sexp.Atom (to_string err)
end

Expand Down Expand Up @@ -153,22 +153,22 @@ end = struct

let rec find_exn t k =
match t with
| Nil -> raise Caml.Not_found
| Nil -> raise Stdlib.Not_found
| Tip (k', v) when k = k' -> v
| Tip _ -> raise Caml.Not_found
| Tip _ -> raise Stdlib.Not_found
| Bin (k', l, r) -> (
match Key.compare k' k with
| NA -> raise Caml.Not_found
| NA -> raise Stdlib.Not_found
| LB -> find_exn l k
| RB -> find_exn r k)

let find t k = try Some (find_exn t k) with Caml.Not_found -> None
let find t k = try Some (find_exn t k) with Stdlib.Not_found -> None

let mem k t =
try
ignore (find_exn k t);
true
with Caml.Not_found -> false
with Stdlib.Not_found -> false

let node payload branching l r =
match (l, r) with
Expand Down Expand Up @@ -359,7 +359,7 @@ end = struct

let unescaped_exists_so_escape ?(skip_pos = -1) s =
let buf = Buffer.create (String.length s + 1) in
Caml.StringLabels.iteri s ~f:(fun p c ->
Stdlib.StringLabels.iteri s ~f:(fun p c ->
if p <> skip_pos && is_separator_unescaped s p c then
Buffer.add_char buf escape_char;
Buffer.add_char buf c);
Expand Down Expand Up @@ -555,7 +555,7 @@ end = struct
let register ?(desc = "no description provided") ?package
?(reliability = trustworthy) name =
let name = Name.create ?package name in
let agent = Caml.Digest.string (Name.show name) in
let agent = Stdlib.Digest.string (Name.show name) in
if Hashtbl.mem agents agent then
failwithf
"An agent with name `%a' already exists, please choose another name"
Expand Down Expand Up @@ -2577,7 +2577,7 @@ module Knowledge = struct
slot : Name.t;
repr : string;
error : Conflict.t;
trace : Caml.Printexc.raw_backtrace;
trace : Stdlib.Printexc.raw_backtrace;
}

let () =
Expand All @@ -2587,7 +2587,7 @@ module Knowledge = struct
@@ Format.asprintf
"Unable to update the slot %a of %s,\n%a\nBacktrace:\n%s" Name.pp
slot repr Conflict.pp error
(Caml.Printexc.raw_backtrace_to_string trace)
(Stdlib.Printexc.raw_backtrace_to_string trace)
| _ -> None)

let non_monotonic slot obj error trace =
Expand Down Expand Up @@ -2626,7 +2626,7 @@ module Knowledge = struct
};
}
with Record.Merge_conflict err ->
non_monotonic slot obj err @@ Caml.Printexc.get_raw_backtrace ())
non_monotonic slot obj err @@ Stdlib.Printexc.get_raw_backtrace ())

let notify { Slot.watchers } obj data =
Hashtbl.data watchers
Expand Down Expand Up @@ -2698,7 +2698,7 @@ module Knowledge = struct
fun slot obj ->
objects slot.cls >>| fun { vals } ->
match Oid.Tree.find_exn vals obj with
| exception Caml.Not_found -> Sleep
| exception Stdlib.Not_found -> Sleep
| { data; comp = slots } -> (
match Map.find slots (uid slot) with
| Some (Work _) -> Awoke
Expand Down Expand Up @@ -2771,7 +2771,7 @@ module Knowledge = struct
fun slot id ->
objects slot.cls >>| fun { Env.vals } ->
match Oid.Tree.find_exn vals id with
| exception Caml.Not_found -> slot.dom.empty
| exception Stdlib.Not_found -> slot.dom.empty
| { data } -> Record.get slot.key slot.dom data

let rec collect_inner : ('a, 'p) slot -> 'a obj -> _ -> _ =
Expand Down Expand Up @@ -3030,7 +3030,7 @@ module Knowledge = struct
compute_value cls obj >>= fun () ->
objects cls >>| fun { Env.vals } ->
match Oid.Tree.find_exn vals obj with
| exception Caml.Not_found -> Value.empty cls
| exception Stdlib.Not_found -> Value.empty cls
| { data = x } -> Value.create cls x

let run cls obj s =
Expand Down
2 changes: 1 addition & 1 deletion src/attribute.ml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ let declare_flag name context =
let continuation ~attr_loc:_ ~name_loc:_ = () in
declare_with_all_args name context payload_pattern continuation

module Attribute_table = Caml.Hashtbl.Make (struct
module Attribute_table = Stdlib.Hashtbl.Make (struct
type t = string loc

let hash : t -> int = Hashtbl.hash
Expand Down
2 changes: 1 addition & 1 deletion src/caller_id.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(** Small helper to find out who is the caller of a function *)

open! Import
module Printexc = Caml.Printexc
module Printexc = Stdlib.Printexc

type t = Printexc.location option

Expand Down
12 changes: 7 additions & 5 deletions src/code_matcher.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(*$ open Ppxlib_cinaps_helpers $*)
open! Import
module Format = Caml.Format
module Filename = Caml.Filename
module Format = Stdlib.Format
module Filename = Stdlib.Filename

(* TODO: make the "deriving." depend on the matching attribute name. *)
let end_marker_sig =
Expand Down Expand Up @@ -72,7 +72,9 @@ struct

let diff_asts ~generated ~round_trip =
let with_temp_file f =
Exn.protectx (Filename.temp_file "ppxlib" "") ~finally:Caml.Sys.remove ~f
Exn.protectx
(Filename.temp_file "ppxlib" "")
~finally:Stdlib.Sys.remove ~f
in
with_temp_file (fun fn1 ->
with_temp_file (fun fn2 ->
Expand All @@ -93,7 +95,7 @@ struct
(Filename.quote out)
in
let ok =
Caml.Sys.command cmd = 1
Stdlib.Sys.command cmd = 1
||
let cmd =
Printf.sprintf
Expand All @@ -102,7 +104,7 @@ struct
(Filename.quote fn1) (Filename.quote fn2)
(Filename.quote out)
in
Caml.Sys.command cmd = 1
Stdlib.Sys.command cmd = 1
in
if ok then In_channel.read_all out
else "<no differences produced by diff>")))
Expand Down
2 changes: 1 addition & 1 deletion src/code_path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type t = {

let top_level ~file_path =
let main_module_name =
file_path |> Caml.Filename.basename |> Caml.Filename.remove_extension
file_path |> Stdlib.Filename.basename |> Stdlib.Filename.remove_extension
|> String.capitalize_ascii
in
{
Expand Down
4 changes: 2 additions & 2 deletions src/common.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open! Import
open Ast_builder.Default
module Buffer = Caml.Buffer
module Format = Caml.Format
module Buffer = Stdlib.Buffer
module Format = Stdlib.Format

let lident x = Longident.Lident x

Expand Down
6 changes: 3 additions & 3 deletions src/deriving.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let keep_w32_intf = ref false

let () =
let keep_w32_spec =
Caml.Arg.Symbol
Stdlib.Arg.Symbol
( [ "impl"; "intf"; "both" ],
function
| "impl" -> keep_w32_impl := true
Expand All @@ -21,7 +21,7 @@ let () =
| _ -> assert false )
in
let conv_w32_spec =
Caml.Arg.Symbol
Stdlib.Arg.Symbol
( [ "code"; "attribute" ],
function
| "code" -> do_insert_unused_warning_attribute := false
Expand All @@ -44,7 +44,7 @@ let keep_w60_intf = ref false

let () =
let keep_w60_spec =
Caml.Arg.Symbol
Stdlib.Arg.Symbol
( [ "impl"; "intf"; "both" ],
function
| "impl" -> keep_w60_impl := true
Expand Down
Loading
Loading