From 7c8adbd9fc47ae662a9a4886aa615bb7cbcc703d Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 25 Nov 2025 20:11:35 -0500 Subject: [PATCH] move to ocamlformat 0.27, format code --- .ocamlformat | 3 ++- benchs/ref_impl.ml | 5 +++-- benchs/run_benchs.ml | 9 ++++----- src/codegen/containers_codegen.ml | 3 ++- src/core/CCUtf8_string.ml | 6 ++++-- src/data/CCFQueue.ml | 3 +-- src/data/CCGraph.ml | 3 +-- src/data/CCGraph.mli | 3 +-- src/data/CCHashTrie.ml | 6 ++++-- src/pvec/containers_pvec.ml | 3 +-- src/pvec/containers_pvec.mli | 1 - tests/pvec/t_pvec.ml | 8 ++++---- 12 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 187ce702..64d99bb3 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version = 0.26.2 +version = 0.27.0 profile=conventional margin=80 if-then-else=k-r @@ -12,3 +12,4 @@ field-space=tight-decl leading-nested-match-parens=true module-item-spacing=compact quiet=true +parse-docstrings=false diff --git a/benchs/ref_impl.ml b/benchs/ref_impl.ml index 645d5e04..890165bb 100644 --- a/benchs/ref_impl.ml +++ b/benchs/ref_impl.ml @@ -128,8 +128,9 @@ module PersistentHashtbl (H : Hashtbl.HashedType) = struct t := Add (k, v', t'); Table.remove tbl k; t' - with Not_found -> (* not member, nothing to do *) - t + with Not_found -> + (* not member, nothing to do *) + t (*$R let h = H.of_seq my_seq in diff --git a/benchs/run_benchs.ml b/benchs/run_benchs.ml index d22a820a..a341140b 100644 --- a/benchs/run_benchs.ml +++ b/benchs/run_benchs.ml @@ -97,7 +97,6 @@ module L = struct else Sek.Persistent.of_list 0 [ x; x + 1; x + 2; x + 3 ] - let f_pvec x = if x mod 10 = 0 then Pvec.empty @@ -149,7 +148,7 @@ module L = struct "flatten o map", flatten_map_ l, (); "ral_flatmap", flatmap_ral_ ral, (); "sek_flatmap", flatmap_sek sek, (); - "pvec.flatmap", flat_map_pvec pvec, () + "pvec.flatmap", flat_map_pvec pvec, (); ] (* APPEND *) @@ -297,7 +296,7 @@ module L = struct for i = 0 to n - 1 do opaque_ignore (CCRAL.set l i (-i)) done - (* TODO: implement set + (* TODO: implement set and bench_funvec l () = for _i = 0 to n-1 do opaque_ignore (CCFun_vec.set (* TODO *)) done *) @@ -823,8 +822,8 @@ module Tbl = struct end in (module T) - let persistent_hashtbl_ref : - type a. a key_type -> (module MUT with type key = a) = + let persistent_hashtbl_ref : type a. + a key_type -> (module MUT with type key = a) = fun key -> let (module Key), name = arg_make key in let module T = Ref_impl.PersistentHashtbl (Key) in diff --git a/src/codegen/containers_codegen.ml b/src/codegen/containers_codegen.ml index aa568170..3ae6ed50 100644 --- a/src/codegen/containers_codegen.ml +++ b/src/codegen/containers_codegen.ml @@ -108,7 +108,8 @@ module Bitfield = struct if self.emit_failure_if_too_wide then fpf out "(* check that int size is big enough *)@,\ - @[let () = assert (Sys.int_size >= %d);;@]" (total_width self); + @[let () = assert (Sys.int_size >= %d);;@]" + (total_width self); fpf out "@]" let gen_mli self : code = diff --git a/src/core/CCUtf8_string.ml b/src/core/CCUtf8_string.ml index 80482d57..2d82a667 100644 --- a/src/core/CCUtf8_string.ml +++ b/src/core/CCUtf8_string.ml @@ -65,8 +65,10 @@ let next_ (type a) (st : Dec.t) ~(yield : uchar -> a) ~(stop : unit -> a) () : a (* except for first, each char gives 6 bits *) let next = (acc lsl 6) lor (c land 0b111111) in if j = n_bytes then - if (* done reading the codepoint *) - Uchar.is_valid next then ( + if + (* done reading the codepoint *) + Uchar.is_valid next + then ( st.i <- st.i + j + 1; (* +1 for first char *) yield (Uchar.unsafe_of_int next) diff --git a/src/data/CCFQueue.ml b/src/data/CCFQueue.ml index e7542374..2fdf0234 100644 --- a/src/data/CCFQueue.ml +++ b/src/data/CCFQueue.ml @@ -37,8 +37,7 @@ let _empty = Shallow Zero let _single x = Shallow (One x) let _double x y = Shallow (Two (x, y)) -let _deep : - type l0 l1. +let _deep : type l0 l1. int -> ('a, l0 succ) digit -> ('a * 'a) t lazy_t -> diff --git a/src/data/CCGraph.ml b/src/data/CCGraph.ml index 5bd22b06..362b77e1 100644 --- a/src/data/CCGraph.ml +++ b/src/data/CCGraph.ml @@ -221,8 +221,7 @@ module Traverse = struct ] type ('v, 'e) t = - [ `Enter of - 'v * int * ('v, 'e) path + [ `Enter of 'v * int * ('v, 'e) path (* unique index in traversal, path from start *) | `Exit of 'v | `Edge of 'v * 'e * 'v * edge_kind diff --git a/src/data/CCGraph.mli b/src/data/CCGraph.mli index 74bb7f1a..0ba056b9 100644 --- a/src/data/CCGraph.mli +++ b/src/data/CCGraph.mli @@ -150,8 +150,7 @@ module Traverse : sig ] type ('v, 'e) t = - [ `Enter of - 'v * int * ('v, 'e) path + [ `Enter of 'v * int * ('v, 'e) path (* unique index in traversal, path from start *) | `Exit of 'v | `Edge of 'v * 'e * 'v * edge_kind diff --git a/src/data/CCHashTrie.ml b/src/data/CCHashTrie.ml index b13e2c63..6b5c8266 100644 --- a/src/data/CCHashTrie.ml +++ b/src/data/CCHashTrie.ml @@ -202,8 +202,10 @@ module A_SPARSE = struct let open Stdlib in Array.blit a.arr real_idx arr (real_idx + 1) (n - real_idx)); { a with bits; arr } - ) else if (* replace element at [real_idx] *) - mut then ( + ) else if + (* replace element at [real_idx] *) + mut + then ( a.arr.(real_idx) <- x; a ) else ( diff --git a/src/pvec/containers_pvec.ml b/src/pvec/containers_pvec.ml index 6de797fe..01b2ca35 100644 --- a/src/pvec/containers_pvec.ml +++ b/src/pvec/containers_pvec.ml @@ -352,8 +352,7 @@ let append a b = else fold_left push a b -let flat_map f v : _ t = - fold_left (fun acc x -> append acc (f x)) empty v +let flat_map f v : _ t = fold_left (fun acc x -> append acc (f x)) empty v let rec equal_tree eq t1 t2 = match t1, t2 with diff --git a/src/pvec/containers_pvec.mli b/src/pvec/containers_pvec.mli index 52a9e8b2..096de0b7 100644 --- a/src/pvec/containers_pvec.mli +++ b/src/pvec/containers_pvec.mli @@ -82,7 +82,6 @@ val append : 'a t -> 'a t -> 'a t (** [append a b] adds all elements of [b] at the end of [a]. This is at least linear in the length of [b]. *) - val map : ('a -> 'b) -> 'a t -> 'b t val flat_map : ('a -> 'b t) -> 'a t -> 'b t diff --git a/tests/pvec/t_pvec.ml b/tests/pvec/t_pvec.ml index dc02a7d6..a51f3346 100644 --- a/tests/pvec/t_pvec.ml +++ b/tests/pvec/t_pvec.ml @@ -120,7 +120,7 @@ module Ref_impl = struct let to_seq = CCSeq.of_list let add_list l l2 : _ t = List.append l l2 let append self l2 : _ t = List.append self l2 - let flat_map sub l : _ t = CCList.flat_map (fun x -> sub @ [x]) l + let flat_map sub l : _ t = CCList.flat_map (fun x -> sub @ [ x ]) l let to_list_via_reviter m = let l = ref [] in @@ -181,7 +181,7 @@ module Op = struct | Pop :: tl -> size >= 0 && loop (size - 1) tl | Add_list l :: tl -> loop (size + List.length l) tl | Append l :: tl -> loop (size + List.length l) tl - | Flat_map sub :: tl -> loop (size * (1+ List.length sub)) tl + | Flat_map sub :: tl -> loop (size * (1 + List.length sub)) tl | Check_get x :: tl -> x < size && loop size tl | Check_choose :: tl | Check_is_empty :: tl @@ -266,8 +266,8 @@ module Op = struct small_list gen_x >|= fun l -> Append l, size + List.length l ); ( 1, - list_size (0--5) gen_x >|= fun l -> - Flat_map l, size * (1+ List.length l )); + list_size (0 -- 5) gen_x >|= fun l -> + Flat_map l, size * (1 + List.length l) ); ]; ] in