From cad41d70d6747a163ee3bd89d31bcfd010e8efef Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 13 Dec 2024 00:17:53 -0500 Subject: [PATCH] ocamlformat --- .github/workflows/main.yml | 4 ++-- .ocamlformat | 2 +- src/core/CCHash.ml | 6 +++--- src/core/CCList.mli | 2 +- src/core/CCListLabels.mli | 2 +- src/core/CCOption.mli | 2 +- src/core/CCOrd.mli | 2 +- src/core/CCParse.mli | 2 +- src/core/CCVector.ml | 2 +- src/data/CCBV.ml | 6 +++--- src/data/CCHashTrie.ml | 8 ++++---- src/data/CCKTree.ml | 9 ++++----- src/data/CCKTree.mli | 9 ++++----- src/data/CCPersistentHashtbl.ml | 6 +++--- src/data/CCTrie.ml | 18 +++++++++--------- src/monomorphic/CCMonomorphic.mli | 5 ++--- src/pp/containers_pp.ml | 6 +++--- tests/core/t_cbor.ml | 6 +++--- tests/core/t_sexp.ml | 9 +++++---- tests/core/t_string.ml | 6 +++--- tests/core/t_utf8string.ml | 4 ++-- tests/data/t_bv.ml | 18 +++++++++--------- tests/data/t_fun_vec.ml | 12 ++++++------ tests/data/t_persistenthashtbl.ml | 17 ++++++++--------- tests/data/t_trie.ml | 6 +++--- tests/pvec/t_pvec.ml | 12 ++++++------ 26 files changed, 89 insertions(+), 92 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b95929c..c2fceb3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,7 +68,7 @@ jobs: strategy: matrix: ocaml-compiler: - - '5.1' + - '5.2' runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@main @@ -79,6 +79,6 @@ jobs: dune-cache: true allow-prerelease-opam: true - - run: opam install ocamlformat.0.24.1 + - run: opam install ocamlformat.0.26.2 - run: opam exec -- make format-check diff --git a/.ocamlformat b/.ocamlformat index c611b8d9..187ce702 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version = 0.24.1 +version = 0.26.2 profile=conventional margin=80 if-then-else=k-r diff --git a/src/core/CCHash.ml b/src/core/CCHash.ml index a65959ff..87415fb1 100644 --- a/src/core/CCHash.ml +++ b/src/core/CCHash.ml @@ -77,9 +77,9 @@ let int = hash_int_ let bool b = hash_int_ (if b then - 1 - else - 2) + 1 + else + 2) let char x = hash_int_ (Char.code x) diff --git a/src/core/CCList.mli b/src/core/CCList.mli index cf7d55ab..f1d31605 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -248,7 +248,7 @@ val partition_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c list - [@@ocaml.deprecated "use CCList.partition_filter_map instead"] +[@@ocaml.deprecated "use CCList.partition_filter_map instead"] (** @deprecated use {!partition_filter_map} instead @since 0.11 *) diff --git a/src/core/CCListLabels.mli b/src/core/CCListLabels.mli index b7964efd..83421d6c 100644 --- a/src/core/CCListLabels.mli +++ b/src/core/CCListLabels.mli @@ -281,7 +281,7 @@ val partition_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c list - [@@ocaml.deprecated "use CCList.partition_filter_map instead"] +[@@ocaml.deprecated "use CCList.partition_filter_map instead"] (** @deprecated use {!partition_filter_map} instead *) val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t diff --git a/src/core/CCOption.mli b/src/core/CCOption.mli index 6ee5a6ee..13e6defd 100644 --- a/src/core/CCOption.mli +++ b/src/core/CCOption.mli @@ -107,7 +107,7 @@ val value : 'a t -> default:'a -> 'a @since 2.8 *) val get_exn : 'a t -> 'a - [@@ocaml.deprecated "use CCOption.get_exn_or instead"] +[@@ocaml.deprecated "use CCOption.get_exn_or instead"] (** [get_exn o] returns [x] if [o] is [Some x] or fails if [o] is [None]. @raise Invalid_argument if the option is [None]. @deprecated use {!get_exn_or} instead diff --git a/src/core/CCOrd.mli b/src/core/CCOrd.mli index c4d7d728..adf94fa1 100644 --- a/src/core/CCOrd.mli +++ b/src/core/CCOrd.mli @@ -13,7 +13,7 @@ val poly : 'a t @since 3.6 *) val compare : 'a t - [@@deprecated "use CCOrd.poly instead, this name is too general"] +[@@deprecated "use CCOrd.poly instead, this name is too general"] (** Polymorphic "magic" comparison. @deprecated since 3.6 in favor of {!poly}. The reason is that [compare] is easily shadowed, can shadow other comparators, and is just diff --git a/src/core/CCParse.mli b/src/core/CCParse.mli index e9c5538d..8d88f05f 100644 --- a/src/core/CCParse.mli +++ b/src/core/CCParse.mli @@ -404,7 +404,7 @@ val optional : _ t -> unit t @since 3.6 *) val try_ : 'a t -> 'a t - [@@deprecated "plays no role anymore, just replace [try foo] with [foo]"] +[@@deprecated "plays no role anymore, just replace [try foo] with [foo]"] (** [try_ p] is just like [p] (it used to play a role in backtracking semantics but no more). diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index a31d7621..be20260e 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -498,7 +498,7 @@ let find_internal_i_ p v = else ( let x = v.vec.(i) in if p x then - i,x + i, x else check (i + 1) ) diff --git a/src/data/CCBV.ml b/src/data/CCBV.ml index 8eeed88c..76b372b2 100644 --- a/src/data/CCBV.ml +++ b/src/data/CCBV.ml @@ -407,9 +407,9 @@ let pp out bv = iter bv (fun _i b -> Format.pp_print_char out (if b then - '1' - else - '0')); + '1' + else + '0')); Format.pp_print_string out "}" module Internal_ = struct diff --git a/src/data/CCHashTrie.ml b/src/data/CCHashTrie.ml index 786c2f45..b13e2c63 100644 --- a/src/data/CCHashTrie.ml +++ b/src/data/CCHashTrie.ml @@ -199,8 +199,8 @@ module A_SPARSE = struct arr.(real_idx) <- x; if real_idx > 0 then Array.blit a.arr 0 arr 0 real_idx; (if real_idx < n then - let open Stdlib in - Array.blit a.arr real_idx arr (real_idx + 1) (n - real_idx)); + 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 ( @@ -230,8 +230,8 @@ module A_SPARSE = struct let arr = Array.make Stdlib.(n + 1) x in if real_idx > 0 then Array.blit a.arr 0 arr 0 real_idx; (if real_idx < n then - let open Stdlib in - Array.blit a.arr real_idx arr (real_idx + 1) (n - real_idx)); + let open Stdlib in + Array.blit a.arr real_idx arr (real_idx + 1) (n - real_idx)); { a with bits; arr } ) else ( let x = f a.arr.(real_idx) in diff --git a/src/data/CCKTree.ml b/src/data/CCKTree.ml index 5b83a1d2..6d559ce1 100644 --- a/src/data/CCKTree.ml +++ b/src/data/CCKTree.ml @@ -66,11 +66,10 @@ let rec cut_depth n t () = (** {2 Graph Traversals} *) (** Abstract Set structure *) -class type ['a] pset = - object - method add : 'a -> 'a pset - method mem : 'a -> bool - end +class type ['a] pset = object + method add : 'a -> 'a pset + method mem : 'a -> bool +end let set_of_cmp (type elt) ~cmp () = let module S = Set.Make (struct diff --git a/src/data/CCKTree.mli b/src/data/CCKTree.mli index 38ecd7d0..bfce882c 100644 --- a/src/data/CCKTree.mli +++ b/src/data/CCKTree.mli @@ -49,11 +49,10 @@ val cut_depth : int -> 'a t -> 'a t (** {2 Graph Traversals} *) (** Abstract Set structure *) -class type ['a] pset = - object - method add : 'a -> 'a pset - method mem : 'a -> bool - end +class type ['a] pset = object + method add : 'a -> 'a pset + method mem : 'a -> bool +end val set_of_cmp : cmp:('a -> 'a -> int) -> unit -> 'a pset (** Build a set structure given a total ordering. *) diff --git a/src/data/CCPersistentHashtbl.ml b/src/data/CCPersistentHashtbl.ml index 31f8ff4b..dc11aaec 100644 --- a/src/data/CCPersistentHashtbl.ml +++ b/src/data/CCPersistentHashtbl.ml @@ -295,9 +295,9 @@ module Make (H : HashedType) : S with type key = H.t = struct { length = (if is_new then - t.length + 1 - else - t.length); + t.length + 1 + else + t.length); arr = Arr a; } in diff --git a/src/data/CCTrie.ml b/src/data/CCTrie.ml index b8f6a3ed..8f561594 100644 --- a/src/data/CCTrie.ml +++ b/src/data/CCTrie.ml @@ -225,12 +225,12 @@ module Make (W : WORD) : S with type char_ = W.char_ and type key = W.t = struct let rebuild' new_child = rebuild (if is_empty new_child then - t - else ( - let map = M.singleton c new_child in - let map = M.add c' t' map in - _mk_node None map - )) + t + else ( + let map = M.singleton c new_child in + let map = M.add c' t' map in + _mk_node None map + )) in empty, rebuild' ) @@ -242,9 +242,9 @@ module Make (W : WORD) : S with type char_ = W.char_ and type key = W.t = struct let rebuild' new_child = rebuild (if is_empty new_child then - _mk_node value (M.remove c map) - else - _mk_node value (M.add c new_child map)) + _mk_node value (M.remove c map) + else + _mk_node value (M.add c new_child map)) in t', rebuild' with Not_found -> diff --git a/src/monomorphic/CCMonomorphic.mli b/src/monomorphic/CCMonomorphic.mli index dbbfcbb6..b788c378 100644 --- a/src/monomorphic/CCMonomorphic.mli +++ b/src/monomorphic/CCMonomorphic.mli @@ -37,9 +37,8 @@ val ( >=. ) : float -> float -> bool (** {2 Shadow Dangerous Operators} *) val ( == ) : [ `Consider_using_CCEqual_physical ] - [@@ocaml.deprecated "Please use CCEqual.physical or Stdlib.(==) instead."] +[@@ocaml.deprecated "Please use CCEqual.physical or Stdlib.(==) instead."] val ( != ) : [ `Consider_using_CCEqual_physical ] - [@@ocaml.deprecated - "Please use [not CCEqual.physical] or Stdlib.(!=) instead."] +[@@ocaml.deprecated "Please use [not CCEqual.physical] or Stdlib.(!=) instead."] (** @since 2.1 *) diff --git a/src/pp/containers_pp.ml b/src/pp/containers_pp.ml index 621b7ecf..ae31b5d7 100644 --- a/src/pp/containers_pp.ml +++ b/src/pp/containers_pp.ml @@ -455,9 +455,9 @@ let of_seq ?(sep = nil) f seq : t = | Seq.Cons (x, tl) -> let x = f x in (if first then - x - else - sep ^ x) + x + else + sep ^ x) ^ loop false tl in loop true seq diff --git a/tests/core/t_cbor.ml b/tests/core/t_cbor.ml index 1e9dea8a..17527159 100644 --- a/tests/core/t_cbor.ml +++ b/tests/core/t_cbor.ml @@ -61,9 +61,9 @@ let gen_c : Cbor.t Q.Gen.t = in frequency (if size > 0 then - base @ rec_ - else - base) + base @ rec_ + else + base) let rec shrink (c : Cbor.t) : Cbor.t Q.Iter.t = let open Q.Iter in diff --git a/tests/core/t_sexp.ml b/tests/core/t_sexp.ml index 5b1e53ca..ffc75184 100644 --- a/tests/core/t_sexp.ml +++ b/tests/core/t_sexp.ml @@ -183,10 +183,11 @@ let arb_csexp_arb = let genstr = Q.Gen.(string_size ~gen:genchar (0 -- 15)) in Q.make ~print:Sexp0.to_string ~shrink:shrink_csexp (gen_csexp genstr) -module Make (X : sig - val arb : Csexp.t Q.arbitrary -end) -() = +module Make + (X : sig + val arb : Csexp.t Q.arbitrary + end) + () = struct open X;; diff --git a/tests/core/t_string.ml b/tests/core/t_string.ml index ec84633c..4db9bea5 100644 --- a/tests/core/t_string.ml +++ b/tests/core/t_string.ml @@ -162,9 +162,9 @@ q let e = edit_distance s1 s2 in let e' = edit_distance ~cutoff:3 s1 s2 in (if e' < 3 then - e = e' - else - e >= 3) + e = e' + else + e >= 3) && if e <= 3 then e = e' diff --git a/tests/core/t_utf8string.ml b/tests/core/t_utf8string.ml index fffce0b2..0210540c 100644 --- a/tests/core/t_utf8string.ml +++ b/tests/core/t_utf8string.ml @@ -26,8 +26,8 @@ let arb_uchar = let rec gen = lazy (let open Q.Gen in - Q.Gen.int_range Uchar.(to_int min) Uchar.(to_int max) >>= fun n -> - try return (Uchar.of_int n) with _ -> Lazy.force gen) + Q.Gen.int_range Uchar.(to_int min) Uchar.(to_int max) >>= fun n -> + try return (Uchar.of_int n) with _ -> Lazy.force gen) in Q.make ~print:(fun c -> Printf.sprintf "" (Uchar.to_int c)) diff --git a/tests/data/t_bv.ml b/tests/data/t_bv.ml index 36bf278e..1de6b527 100644 --- a/tests/data/t_bv.ml +++ b/tests/data/t_bv.ml @@ -640,9 +640,9 @@ module Op = struct @@ List.flatten [ (if size > 0 then - nonzero - else - []); + nonzero + else + []); [ 1, return Clear; 1, return Clear_and_shrink; @@ -747,16 +747,16 @@ module Ref_ = struct | Set_bool (i, b) -> apply_op self (if b then - Set i - else - Reset i) + Set i + else + Reset i) | Flip i -> self.size <- max self.size (i + 1); apply_op self (if Intset.mem i self.set then - Reset i - else - Set i) + Reset i + else + Set i) | Clear -> self.set <- Intset.empty | Clear_and_shrink -> self.set <- Intset.empty; diff --git a/tests/data/t_fun_vec.ml b/tests/data/t_fun_vec.ml index cd5d181b..c719534e 100644 --- a/tests/data/t_fun_vec.ml +++ b/tests/data/t_fun_vec.ml @@ -173,12 +173,12 @@ module Op = struct 1, return (Check_to_gen, size); ]; (if size > 0 then - [ - 1, return (Pop, size - 1); - (1, 0 -- (size - 1) >|= fun x -> Check_get x, size); - ] - else - []); + [ + 1, return (Pop, size - 1); + (1, 0 -- (size - 1) >|= fun x -> Check_get x, size); + ] + else + []); [ ( 1, small_list gen_x >|= fun l -> diff --git a/tests/data/t_persistenthashtbl.ml b/tests/data/t_persistenthashtbl.ml index cee995a6..170096f6 100644 --- a/tests/data/t_persistenthashtbl.ml +++ b/tests/data/t_persistenthashtbl.ml @@ -108,15 +108,14 @@ let t1 = H.of_list [ 1, "a"; 2, "b1" ] in let t2 = H.of_list [ 2, "b2"; 3, "c" ] in let t = H.merge - ~f: - (fun _ -> function - | `Right v2 -> Some v2 - | `Left v1 -> Some v1 - | `Both (s1, s2) -> - if s1 < s2 then - Some s1 - else - Some s2) + ~f:(fun _ -> function + | `Right v2 -> Some v2 + | `Left v1 -> Some v1 + | `Both (s1, s2) -> + if s1 < s2 then + Some s1 + else + Some s2) t1 t2 in assert_equal ~printer:string_of_int 3 (H.length t); diff --git a/tests/data/t_trie.ml b/tests/data/t_trie.ml index 6db6dec8..d1849022 100644 --- a/tests/data/t_trie.ml +++ b/tests/data/t_trie.ml @@ -118,9 +118,9 @@ let rec sorted ~rev = function | [] | [ _ ] -> true | x :: (y :: _ as tl) -> (if rev then - x >= y - else - x <= y) + x >= y + else + x <= y) && sorted ~rev tl let gen_str = Q.small_printable_string;; diff --git a/tests/pvec/t_pvec.ml b/tests/pvec/t_pvec.ml index e58130aa..b4643d6c 100644 --- a/tests/pvec/t_pvec.ml +++ b/tests/pvec/t_pvec.ml @@ -242,12 +242,12 @@ module Op = struct 1, return (Check_rev_iter, size); ]; (if size > 0 then - [ - 1, return (Pop, size - 1); - (1, 0 -- (size - 1) >|= fun x -> Check_get x, size); - ] - else - []); + [ + 1, return (Pop, size - 1); + (1, 0 -- (size - 1) >|= fun x -> Check_get x, size); + ] + else + []); [ ( 1, small_list gen_x >|= fun l ->