From 0b0dd83423c29cab63a62b18c17ea60dc7df4ed3 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 13 May 2024 20:57:53 -0400 Subject: [PATCH] reformat all the things --- .ocamlformat | 2 +- Makefile | 7 ++++++ benchs/dune | 25 ++++++++++++++++----- benchs/run_bench_hash.ml | 4 +++- benchs/run_benchs.ml | 15 ++++++++++--- examples/ccparse_irclogs_real.cond.ml | 6 ++++- examples/ccparse_sexp.ml | 4 +++- fuzz/dune | 7 +++--- src/bencode/containers_bencode.ml | 6 ++++- src/bencode/containers_bencode.mli | 6 ++++- src/cbor/containers_cbor.ml | 3 ++- src/cbor/containers_cbor.mli | 3 ++- src/codegen/containers_codegen.ml | 11 +++++++-- src/core/CCByte_buffer.ml | 6 ++++- src/core/CCByte_buffer.mli | 5 ++++- src/core/CCCanonical_sexp.ml | 7 +++--- src/core/CCCanonical_sexp.mli | 5 ++++- src/core/CCChar.mli | 2 +- src/core/CCEither.ml | 4 +++- src/core/CCEither.mli | 4 +++- src/core/CCEqual.ml | 2 -- src/core/CCFloat.ml | 2 -- src/core/CCFloat.mli | 2 -- src/core/CCFormat.ml | 13 +++++++++-- src/core/CCFormat.mli | 13 +++++++++-- src/core/CCHeap.ml | 5 ++++- src/core/CCIO.ml | 4 +++- src/core/CCInt32.ml | 1 - src/core/CCInt32.mli | 2 +- src/core/CCInt64.ml | 4 +--- src/core/CCInt64.mli | 2 +- src/core/CCNativeint.ml | 1 - src/core/CCNativeint.mli | 2 +- src/core/CCOrd.ml | 2 -- src/core/CCParse.ml | 5 ++++- src/core/CCParse.mli | 6 +++-- src/core/CCResult.ml | 9 ++++++-- src/core/CCResult.mli | 9 ++++++-- src/core/CCSeq.ml | 8 +++++-- src/core/CCSexp.ml | 12 ++++++---- src/core/CCSexp.mli | 5 ++++- src/core/CCSexp_intf.ml | 5 ++++- src/core/CCString.ml | 22 +++++++++++++----- src/core/CCString.mli | 7 ++++-- src/core/CCStringLabels.mli | 7 ++++-- src/core/CCUtf8_string.ml | 8 ++++--- src/core/CCVector.ml | 5 ++++- src/core/cpp/cpp.ml | 6 ++++- src/core/cpp/dune | 3 ++- src/core/tests/test_hash.ml | 5 ++++- src/data/CCBV.ml | 5 ++++- src/data/CCBijection.ml | 5 ++++- src/data/CCCache.ml | 8 +++++-- src/data/CCDeque.ml | 5 ++++- src/data/CCFun_vec.ml | 10 +++++++-- src/data/CCGraph.ml | 26 +++++++++++++++++----- src/data/CCGraph.mli | 17 ++++++++++---- src/data/CCHashTrie.ml | 9 ++++---- src/data/CCImmutArray.ml | 1 - src/data/CCIntMap.ml | 1 - src/data/CCKTree.ml | 8 +++++-- src/data/CCKTree.mli | 3 ++- src/data/CCLazy_list.ml | 5 ++++- src/data/CCLazy_list.mli | 5 ++++- src/data/CCMixset.ml | 6 ++++- src/data/CCMultiMap.ml | 5 ++++- src/data/CCMutHeap.ml | 2 -- src/data/CCPersistentArray.ml | 5 ++++- src/data/CCPersistentHashtbl.ml | 8 +++++-- src/data/CCRAL.ml | 4 +++- src/data/CCSimple_queue.ml | 5 ++++- src/data/CCTrie.ml | 4 +++- src/data/CCWBTree.ml | 5 ++++- src/data/dune | 12 ++++++++-- src/dune | 24 ++++++++++++++++---- src/pp/containers_pp.ml | 32 ++++++++++++++++++++++----- src/pp/containers_pp.mli | 18 +++++++++++++-- src/pp/dune | 11 +++++---- src/pvec/containers_pvec.ml | 5 ++++- src/pvec/dune | 13 +++++------ src/scc/dune | 9 ++++---- src/testlib/containers_testlib.ml | 15 +++++++++++-- tests/cbor/t_appendix_a.ml | 18 ++++++++++++--- tests/core/dune | 18 +++++++++++---- tests/core/t_parse.ml | 4 +++- tests/data/dune | 3 ++- tests/data/t_bv.ml | 8 ++++--- tests/data/t_mutheap.ml | 6 ++++- tests/data/t_ringbuffer.ml | 5 ++++- tests/data/t_wbt.ml | 5 ++++- tests/pvec/dune | 4 ++-- 91 files changed, 498 insertions(+), 173 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index f820496c..c611b8d9 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -5,7 +5,7 @@ if-then-else=k-r parens-ite=true parens-tuple=multi-line-only sequence-style=terminator -type-decl=compact +type-decl=sparse break-cases=toplevel cases-exp-indent=2 field-space=tight-decl diff --git a/Makefile b/Makefile index 2731d39d..3c14d756 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,13 @@ doc: examples: dune build examples/id_sexp.exe +format: + @dune build $(DUNE_OPTS) @fmt --auto-promote + +format-check: + @dune build $(DUNE_OPTS) @fmt --display=quiet + + VERSION=$(shell awk '/^version:/ {print $$2}' containers.opam) update_next_tag: diff --git a/benchs/dune b/benchs/dune index ee9ac780..8319f4c1 100644 --- a/benchs/dune +++ b/benchs/dune @@ -1,9 +1,24 @@ (executables (names run_benchs run_bench_hash run_objsize) - (libraries containers containers_pvec - containers-data benchmark gen iter - qcheck oseq batteries base sek) + (libraries + containers + containers_pvec + containers-data + benchmark + gen + iter + qcheck + oseq + batteries + base + sek) (flags :standard -warn-error -3-5 -safe-string -color always) (optional) - (ocamlopt_flags :standard -O3 -color always -unbox-closures - -unbox-closures-factor 20)) + (ocamlopt_flags + :standard + -O3 + -color + always + -unbox-closures + -unbox-closures-factor + 20)) diff --git a/benchs/run_bench_hash.ml b/benchs/run_bench_hash.ml index c205a058..2e8577d4 100644 --- a/benchs/run_bench_hash.ml +++ b/benchs/run_bench_hash.ml @@ -1,6 +1,8 @@ (** Test hash functions *) -type tree = Empty | Node of int * tree list +type tree = + | Empty + | Node of int * tree list let mk_node i l = Node (i, l) diff --git a/benchs/run_benchs.ml b/benchs/run_benchs.ml index 4c617e9b..6e23f9e2 100644 --- a/benchs/run_benchs.ml +++ b/benchs/run_benchs.ml @@ -794,7 +794,9 @@ module Tbl = struct val compare : t -> t -> int end - type _ key_type = Int : int key_type | Str : string key_type + type _ key_type = + | Int : int key_type + | Str : string key_type let arg_make : type a. a key_type -> (module KEY with type t = a) * string = function @@ -918,7 +920,10 @@ module Tbl = struct module M = CCHashTrie.Make (K) - type 'a t = { id: CCHashTrie.Transient.t; mutable map: 'a M.t } + type 'a t = { + id: CCHashTrie.Transient.t; + mutable map: 'a M.t; + } let create _ = { id = CCHashTrie.Transient.create (); map = M.empty } let find m k = M.get_exn k m.map @@ -1237,7 +1242,11 @@ module Deque = struct end module Base : DEQUE = struct - type 'a elt = { content: 'a; mutable prev: 'a elt; mutable next: 'a elt } + type 'a elt = { + content: 'a; + mutable prev: 'a elt; + mutable next: 'a elt; + } (** A cell holding a single element *) and 'a t = 'a elt option ref diff --git a/examples/ccparse_irclogs_real.cond.ml b/examples/ccparse_irclogs_real.cond.ml index 8b2bbd05..b36351f1 100644 --- a/examples/ccparse_irclogs_real.cond.ml +++ b/examples/ccparse_irclogs_real.cond.ml @@ -14,7 +14,11 @@ let pp_datetime out d = CCFormat.( fprintf out "{y=%d;M=%d;d=%d;h=%d;m=%d;s=%d}" year month day hour min sec) -type msg = { timestamp: datetime; user: string; msg: string } +type msg = { + timestamp: datetime; + user: string; + msg: string; +} let pp_msg out m = CCFormat.fprintf out "{@[time=%a;@ user=%S;@ msg=%S@]}" pp_datetime diff --git a/examples/ccparse_sexp.ml b/examples/ccparse_sexp.ml index 634ced3c..f33fabe3 100644 --- a/examples/ccparse_sexp.ml +++ b/examples/ccparse_sexp.ml @@ -1,6 +1,8 @@ open CCParse -type sexp = Atom of string | List of sexp list +type sexp = + | Atom of string + | List of sexp list let rec pp_sexpr out (s : sexp) : unit = match s with diff --git a/fuzz/dune b/fuzz/dune index 29c0f998..8cc8a87c 100644 --- a/fuzz/dune +++ b/fuzz/dune @@ -1,8 +1,9 @@ (executables (flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g)) - (names ccsexp_parse_string_does_not_crash - ccutf8_string_uchar_to_bytes_is_same_as_simple_version - ccsexp_csexp_reparse) + (names + ccsexp_parse_string_does_not_crash + ccutf8_string_uchar_to_bytes_is_same_as_simple_version + ccsexp_csexp_reparse) (optional) (libraries crowbar containers)) diff --git a/src/bencode/containers_bencode.ml b/src/bencode/containers_bencode.ml index 7811c9fe..c9c63ca7 100644 --- a/src/bencode/containers_bencode.ml +++ b/src/bencode/containers_bencode.ml @@ -1,6 +1,10 @@ module Str_map = Map.Make (String) -type t = Int of int64 | String of string | List of t list | Map of t Str_map.t +type t = + | Int of int64 + | String of string + | List of t list + | Map of t Str_map.t let rec equal t1 t2 = match t1, t2 with diff --git a/src/bencode/containers_bencode.mli b/src/bencode/containers_bencode.mli index f2e5b68b..f6c8592d 100644 --- a/src/bencode/containers_bencode.mli +++ b/src/bencode/containers_bencode.mli @@ -6,7 +6,11 @@ module Str_map : module type of Map.Make (String) -type t = Int of int64 | String of string | List of t list | Map of t Str_map.t +type t = + | Int of int64 + | String of string + | List of t list + | Map of t Str_map.t val equal : t -> t -> bool val hash : t -> int diff --git a/src/cbor/containers_cbor.ml b/src/cbor/containers_cbor.ml index 65da19c0..24b0b5e5 100644 --- a/src/cbor/containers_cbor.ml +++ b/src/cbor/containers_cbor.ml @@ -11,7 +11,8 @@ type t = | `Text of string | `Array of t list | `Map of (t * t) list - | `Tag of int * t ] + | `Tag of int * t + ] let rec pp_diagnostic out (self : t) = match self with diff --git a/src/cbor/containers_cbor.mli b/src/cbor/containers_cbor.mli index 4ca08772..873cdcb6 100644 --- a/src/cbor/containers_cbor.mli +++ b/src/cbor/containers_cbor.mli @@ -19,7 +19,8 @@ type t = | `Text of string | `Array of t list | `Map of (t * t) list - | `Tag of int * t ] + | `Tag of int * t + ] val pp_diagnostic : t CCFormat.printer val to_string_diagnostic : t -> string diff --git a/src/codegen/containers_codegen.ml b/src/codegen/containers_codegen.ml index d1135747..aa568170 100644 --- a/src/codegen/containers_codegen.ml +++ b/src/codegen/containers_codegen.ml @@ -31,8 +31,15 @@ module Code = struct end module Bitfield = struct - type field = { f_name: string; f_offset: int; f_def: field_def } - and field_def = F_bit | F_int of { width: int } + type field = { + f_name: string; + f_offset: int; + f_def: field_def; + } + + and field_def = + | F_bit + | F_int of { width: int } type t = { name: string; diff --git a/src/core/CCByte_buffer.ml b/src/core/CCByte_buffer.ml index aa173cd2..c15dbf61 100644 --- a/src/core/CCByte_buffer.ml +++ b/src/core/CCByte_buffer.ml @@ -1,5 +1,9 @@ type 'a iter = ('a -> unit) -> unit -type t = { mutable bytes: bytes; mutable len: int } + +type t = { + mutable bytes: bytes; + mutable len: int; +} let create ?(cap = 0) () : t = let bytes = diff --git a/src/core/CCByte_buffer.mli b/src/core/CCByte_buffer.mli index df817810..77325013 100644 --- a/src/core/CCByte_buffer.mli +++ b/src/core/CCByte_buffer.mli @@ -4,7 +4,10 @@ @since 3.7 *) -type t = { mutable bytes: bytes; mutable len: int } +type t = { + mutable bytes: bytes; + mutable len: int; +} (** The byte buffer. The definition is public since NEXT_RELEASE *) diff --git a/src/core/CCCanonical_sexp.ml b/src/core/CCCanonical_sexp.ml index 41e5c511..bb260902 100644 --- a/src/core/CCCanonical_sexp.ml +++ b/src/core/CCCanonical_sexp.ml @@ -2,8 +2,6 @@ (** {1 Simple S-expression parsing/printing} *) - - type 'a or_error = ('a, string) result type 'a gen = unit -> 'a option @@ -255,7 +253,10 @@ module Make (Sexp : SEXP) = struct _with_in filename (parse_chan_list_ ~file:filename) end -type t = [ `Atom of string | `List of t list ] +type t = + [ `Atom of string + | `List of t list + ] let rec equal a b = match a, b with diff --git a/src/core/CCCanonical_sexp.mli b/src/core/CCCanonical_sexp.mli index a0d8fadb..ad66228f 100644 --- a/src/core/CCCanonical_sexp.mli +++ b/src/core/CCCanonical_sexp.mli @@ -19,7 +19,10 @@ module Make (Sexp : SEXP) : S with type t = Sexp.t (** {2 Basics} *) -type t = [ `Atom of string | `List of t list ] +type t = + [ `Atom of string + | `List of t list + ] (** A simple, structural representation of S-expressions. Compatible with {!CCSexp}. *) diff --git a/src/core/CCChar.mli b/src/core/CCChar.mli index 80d32653..d18eb48e 100644 --- a/src/core/CCChar.mli +++ b/src/core/CCChar.mli @@ -4,10 +4,10 @@ @since 0.14 *) +(** @inline *) include module type of struct include Char end -(** @inline *) val compare : t -> t -> int (** The comparison function for characters, with the same specification as diff --git a/src/core/CCEither.ml b/src/core/CCEither.ml index 58210f42..30a64f6f 100644 --- a/src/core/CCEither.ml +++ b/src/core/CCEither.ml @@ -7,7 +7,9 @@ type 'a printer = Format.formatter -> 'a -> unit (** {2 Basics} *) -type ('a, 'b) t = ('a, 'b) Either.t = Left of 'a | Right of 'b +type ('a, 'b) t = ('a, 'b) Either.t = + | Left of 'a + | Right of 'b let left l = Left l let right r = Right r diff --git a/src/core/CCEither.mli b/src/core/CCEither.mli index 82cce3c2..ce6f4e18 100644 --- a/src/core/CCEither.mli +++ b/src/core/CCEither.mli @@ -15,7 +15,9 @@ type 'a printer = Format.formatter -> 'a -> unit (** {2 Basics} *) -type ('a, 'b) t = ('a, 'b) Either.t = Left of 'a | Right of 'b +type ('a, 'b) t = ('a, 'b) Either.t = + | Left of 'a + | Right of 'b val left : 'a -> ('a, 'b) t (** [left l] is [Left l] *) diff --git a/src/core/CCEqual.ml b/src/core/CCEqual.ml index 62d05c44..aaf3e267 100644 --- a/src/core/CCEqual.ml +++ b/src/core/CCEqual.ml @@ -2,8 +2,6 @@ (** {1 Equality Combinators} *) - - type 'a t = 'a -> 'a -> bool let poly = Stdlib.( = ) diff --git a/src/core/CCFloat.ml b/src/core/CCFloat.ml index f0a003de..7b62f832 100644 --- a/src/core/CCFloat.ml +++ b/src/core/CCFloat.ml @@ -1,7 +1,5 @@ (* This file is free software, part of containers. See file "license" for more details. *) - - type t = float type fpclass = Stdlib.fpclass = diff --git a/src/core/CCFloat.mli b/src/core/CCFloat.mli index 7a4b68f8..52709194 100644 --- a/src/core/CCFloat.mli +++ b/src/core/CCFloat.mli @@ -3,8 +3,6 @@ (** Basic operations on floating-point numbers @since 0.6.1 *) - - type t = float type fpclass = Stdlib.fpclass = diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index bb382423..ef1c9ca1 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -204,7 +204,15 @@ let to_file filename format = module ANSI_codes = struct type color = - [ `Black | `Red | `Yellow | `Green | `Blue | `Magenta | `Cyan | `White ] + [ `Black + | `Red + | `Yellow + | `Green + | `Blue + | `Magenta + | `Cyan + | `White + ] let int_of_color_ = function | `Black -> 0 @@ -220,7 +228,8 @@ module ANSI_codes = struct [ `FG of color (* foreground *) | `BG of color (* background *) | `Bold - | `Reset ] + | `Reset + ] let code_of_style : style -> int = function | `FG c -> 30 + int_of_color_ c diff --git a/src/core/CCFormat.mli b/src/core/CCFormat.mli index bf894951..4426f662 100644 --- a/src/core/CCFormat.mli +++ b/src/core/CCFormat.mli @@ -296,14 +296,23 @@ val with_color_ksf : @since 3.5 *) module ANSI_codes : sig type color = - [ `Black | `Red | `Yellow | `Green | `Blue | `Magenta | `Cyan | `White ] + [ `Black + | `Red + | `Yellow + | `Green + | `Blue + | `Magenta + | `Cyan + | `White + ] (** An ANSI color *) type style = [ `FG of color (** foreground *) | `BG of color (** background *) | `Bold - | `Reset ] + | `Reset + ] (** A style. Styles can be composed in a list. *) val clear_line : string diff --git a/src/core/CCHeap.ml b/src/core/CCHeap.ml index ebd784ea..dbd04824 100644 --- a/src/core/CCHeap.ml +++ b/src/core/CCHeap.ml @@ -165,7 +165,10 @@ end module Make (E : PARTIAL_ORD) : S with type elt = E.t = struct type elt = E.t - type t = E | N of int * elt * t * t + + type t = + | E + | N of int * elt * t * t let empty = E diff --git a/src/core/CCIO.ml b/src/core/CCIO.ml index 69a00446..1afbbece 100644 --- a/src/core/CCIO.ml +++ b/src/core/CCIO.ml @@ -153,7 +153,9 @@ let read_lines_l ic = with End_of_file -> List.rev !l (* thanks to nicoo for this trick *) -type _ ret_type = Ret_string : string ret_type | Ret_bytes : Bytes.t ret_type +type _ ret_type = + | Ret_string : string ret_type + | Ret_bytes : Bytes.t ret_type let read_all_ : type a. op:a ret_type -> size:int -> in_channel -> a = fun ~op ~size ic -> diff --git a/src/core/CCInt32.ml b/src/core/CCInt32.ml index 5a194685..42cbdf5c 100644 --- a/src/core/CCInt32.ml +++ b/src/core/CCInt32.ml @@ -1,6 +1,5 @@ (* This file is free software, part of containers. See file "license" for more details. *) - include Int32 let min : t -> t -> t = Stdlib.min diff --git a/src/core/CCInt32.mli b/src/core/CCInt32.mli index 732ab3e5..218168d7 100644 --- a/src/core/CCInt32.mli +++ b/src/core/CCInt32.mli @@ -13,10 +13,10 @@ @since 2.1 *) +(** @inline *) include module type of struct include Int32 end -(** @inline *) val min : t -> t -> t (** [min x y] returns the minimum of the two integers [x] and [y]. diff --git a/src/core/CCInt64.ml b/src/core/CCInt64.ml index 818dd277..80b22e67 100644 --- a/src/core/CCInt64.ml +++ b/src/core/CCInt64.ml @@ -1,6 +1,5 @@ (* This file is free software, part of containers. See file "license" for more details. *) - include Int64 let min : t -> t -> t = Stdlib.min @@ -21,8 +20,7 @@ let hash_to_int64 (n : t) = done; logand !h max_int -let[@inline] hash (n : t) : int = - to_int (hash_to_int64 n) land Stdlib.max_int +let[@inline] hash (n : t) : int = to_int (hash_to_int64 n) land Stdlib.max_int (* see {!CCInt.popcount} for more details *) let[@inline] popcount (b : t) : int = diff --git a/src/core/CCInt64.mli b/src/core/CCInt64.mli index bbe89d4c..3466d289 100644 --- a/src/core/CCInt64.mli +++ b/src/core/CCInt64.mli @@ -13,10 +13,10 @@ @since 0.13 *) +(** @inline *) include module type of struct include Int64 end -(** @inline *) val min : t -> t -> t (** [min x y] returns the minimum of the two integers [x] and [y]. diff --git a/src/core/CCNativeint.ml b/src/core/CCNativeint.ml index fd284905..065e74fa 100644 --- a/src/core/CCNativeint.ml +++ b/src/core/CCNativeint.ml @@ -1,6 +1,5 @@ (* This file is free software, part of containers. See file "license" for more details. *) - include Nativeint let min : t -> t -> t = Stdlib.min diff --git a/src/core/CCNativeint.mli b/src/core/CCNativeint.mli index 0f9bbebc..011e128f 100644 --- a/src/core/CCNativeint.mli +++ b/src/core/CCNativeint.mli @@ -14,10 +14,10 @@ @since 2.1 *) +(** @inline *) include module type of struct include Nativeint end -(** @inline *) val min : t -> t -> t (** [min x y] returns the minimum of the two integers [x] and [y]. diff --git a/src/core/CCOrd.ml b/src/core/CCOrd.ml index 8c8eff06..2726d3dc 100644 --- a/src/core/CCOrd.ml +++ b/src/core/CCOrd.ml @@ -2,8 +2,6 @@ (** {1 Comparisons} *) - - type 'a t = 'a -> 'a -> int (** Comparison (total ordering) between two elements, that returns an int *) diff --git a/src/core/CCParse.ml b/src/core/CCParse.ml index 6c865bb9..a794404b 100644 --- a/src/core/CCParse.ml +++ b/src/core/CCParse.ml @@ -85,7 +85,10 @@ module Position = struct end module Error = struct - type t = { msg: unit -> string; pos: position } + type t = { + msg: unit -> string; + pos: position; + } let position self = self.pos let line_and_column self = Position.line_and_column self.pos diff --git a/src/core/CCParse.mli b/src/core/CCParse.mli index 39087562..e9c5538d 100644 --- a/src/core/CCParse.mli +++ b/src/core/CCParse.mli @@ -259,7 +259,8 @@ val chars_fold : [ `Continue of 'acc | `Consume_and_stop of 'acc | `Stop of 'acc - | `Fail of string ]) -> + | `Fail of string + ]) -> 'acc -> ('acc * slice) t (** [chars_fold f acc0] folds over characters of the input. @@ -289,7 +290,8 @@ val chars_fold_transduce : | `Yield of 'acc * char | `Consume_and_stop | `Stop - | `Fail of string ]) -> + | `Fail of string + ]) -> 'acc -> ('acc * string) t (** Same as {!chars_fold} but with the following differences: diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index 27aae43c..9acb529b 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -13,7 +13,9 @@ type nonrec (+'good, +'bad) result = ('good, 'bad) result = | Ok of 'good | Error of 'bad -type (+'good, +'bad) t = ('good, 'bad) result = Ok of 'good | Error of 'bad +type (+'good, +'bad) t = ('good, 'bad) result = + | Ok of 'good + | Error of 'bad let return x = Ok x let fail s = Error s @@ -333,7 +335,10 @@ let to_iter e k = | Ok x -> k x | Error _ -> () -type ('a, 'b) error = [ `Ok of 'a | `Error of 'b ] +type ('a, 'b) error = + [ `Ok of 'a + | `Error of 'b + ] let of_err = function | `Ok x -> Ok x diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 74247a8e..50b7fb68 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -20,7 +20,9 @@ type nonrec (+'good, +'bad) result = ('good, 'bad) result = | Ok of 'good | Error of 'bad -type (+'good, +'bad) t = ('good, 'bad) result = Ok of 'good | Error of 'bad +type (+'good, +'bad) t = ('good, 'bad) result = + | Ok of 'good + | Error of 'bad val return : 'a -> ('a, 'err) t (** Successfully return a value. *) @@ -263,7 +265,10 @@ val to_seq : ('a, _) t -> 'a Seq.t (** Renamed from [to_std_seq] since 3.0. @since 3.0 *) -type ('a, 'b) error = [ `Ok of 'a | `Error of 'b ] +type ('a, 'b) error = + [ `Ok of 'a + | `Error of 'b + ] val of_err : ('a, 'b) error -> ('a, 'b) t (** @since 0.17 *) diff --git a/src/core/CCSeq.ml b/src/core/CCSeq.ml index 68c479d2..c3b8dd34 100644 --- a/src/core/CCSeq.ml +++ b/src/core/CCSeq.ml @@ -481,7 +481,9 @@ let to_gen l = l := l'; Some x -type 'a of_gen_state = Of_gen_thunk of 'a gen | Of_gen_saved of 'a node +type 'a of_gen_state = + | Of_gen_thunk of 'a gen + | Of_gen_saved of 'a node let of_gen g = let rec consume r () = @@ -508,7 +510,9 @@ let sort_uniq ~cmp l = let l = to_list l in uniq (fun x y -> cmp x y = 0) (of_list (List.sort cmp l)) -type 'a memoize = MemoThunk | MemoSave of 'a node +type 'a memoize = + | MemoThunk + | MemoSave of 'a node let rec memoize f = let r = ref MemoThunk in diff --git a/src/core/CCSexp.ml b/src/core/CCSexp.ml index 7dcdf651..35fe6ae7 100644 --- a/src/core/CCSexp.ml +++ b/src/core/CCSexp.ml @@ -2,8 +2,6 @@ (** {1 Simple S-expression parsing/printing} *) - - type 'a or_error = ('a, string) result type 'a gen = unit -> 'a option @@ -151,7 +149,10 @@ module Make (Sexp : SEXP) = struct (** A parser of ['a] can return [Yield x] when it parsed a value, or [Fail e] when a parse error was encountered, or [End] if the input was empty *) - type 'a parse_result = Yield of 'a | Fail of string | End + type 'a parse_result = + | Yield of 'a + | Fail of string + | End module Decoder = struct module L = CCSexp_lex @@ -311,7 +312,10 @@ module Make (Sexp : SEXP) = struct _with_in filename (parse_chan_list_ ~file:filename) end -type t = [ `Atom of string | `List of t list ] +type t = + [ `Atom of string + | `List of t list + ] let rec equal a b = match a, b with diff --git a/src/core/CCSexp.mli b/src/core/CCSexp.mli index ed48a299..095efe5b 100644 --- a/src/core/CCSexp.mli +++ b/src/core/CCSexp.mli @@ -31,7 +31,10 @@ module Make (Sexp : SEXP) : S with type t = Sexp.t and type loc = Sexp.loc (** {2 Basics} *) -type t = [ `Atom of string | `List of t list ] +type t = + [ `Atom of string + | `List of t list + ] (** A simple, structural representation of S-expressions. *) include S with type t := t diff --git a/src/core/CCSexp_intf.ml b/src/core/CCSexp_intf.ml index 7b8b9793..b4a399b1 100644 --- a/src/core/CCSexp_intf.ml +++ b/src/core/CCSexp_intf.ml @@ -129,7 +129,10 @@ module type S = sig (** A parser of ['a] can return [Yield x] when it parsed a value, or [Fail e] when a parse error was encountered, or [End] if the input was empty. *) - type 'a parse_result = Yield of 'a | Fail of string | End + type 'a parse_result = + | Yield of 'a + | Fail of string + | End module Decoder : sig type t diff --git a/src/core/CCString.ml b/src/core/CCString.ml index 933c70b1..260d9d69 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -44,7 +44,10 @@ type _ direction = (* we follow https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm *) module Find = struct - type 'a kmp_pattern = { failure: int array; str: string } + type 'a kmp_pattern = { + failure: int array; + str: string; + } (* invariant: [length failure = length str]. We use a phantom type to avoid mixing the directions. *) @@ -169,7 +172,9 @@ module Find = struct else -1 - type 'a pattern = P_char of char | P_KMP of 'a kmp_pattern + type 'a pattern = + | P_char of char + | P_KMP of 'a kmp_pattern let pattern_length = function | P_char _ -> 1 @@ -279,12 +284,17 @@ let replace ?(which = `All) ~sub ~by s = Buffer.contents b module Split = struct - type drop_if_empty = { first: bool; last: bool } + type drop_if_empty = { + first: bool; + last: bool; + } let no_drop = { first = false; last = false } let default_drop = no_drop - type split_state = SplitStop | SplitAt of int (* previous *) + type split_state = + | SplitStop + | SplitAt of int (* previous *) let rec _split ~by s state = match state with @@ -414,7 +424,9 @@ let compare_versions a b = in cmp_rec (Split.gen_cpy ~by:"." a) (Split.gen_cpy ~by:"." b) -type nat_chunk = NC_char of char | NC_int of int +type nat_chunk = + | NC_char of char + | NC_int of int let compare_natural a b = (* stream of chunks *) diff --git a/src/core/CCString.mli b/src/core/CCString.mli index 2fe96b91..0e5e7ba0 100644 --- a/src/core/CCString.mli +++ b/src/core/CCString.mli @@ -8,10 +8,10 @@ type 'a iter = ('a -> unit) -> unit type 'a gen = unit -> 'a option +(** @inline *) include module type of struct include String end -(** @inline *) val length : t -> int (** [length s] returns the length (number of characters) of the given string [s]. *) @@ -369,7 +369,10 @@ end (** {2 Splitting} *) module Split : sig - type drop_if_empty = { first: bool; last: bool } + type drop_if_empty = { + first: bool; + last: bool; + } (** Specification of what to do with empty blocks, as in [split ~by:"-" "-a-b-"]. - [{first=false; last=false}] will return [""; "a"; "b"; ""] diff --git a/src/core/CCStringLabels.mli b/src/core/CCStringLabels.mli index b87042ca..318e8237 100644 --- a/src/core/CCStringLabels.mli +++ b/src/core/CCStringLabels.mli @@ -8,10 +8,10 @@ type 'a iter = ('a -> unit) -> unit type 'a gen = unit -> 'a option +(** @inline *) include module type of struct include StringLabels end -(** @inline *) val length : t -> int (** [length s] returns the length (number of characters) of the given string [s]. *) @@ -406,7 +406,10 @@ end (** {2 Splitting} *) module Split : sig - type drop_if_empty = { first: bool; last: bool } + type drop_if_empty = { + first: bool; + last: bool; + } (** Specification of what to do with empty blocks, as in [split ~by:"-" "-a-b-"]. - [{first=false; last=false}] will return [""; "a"; "b"; ""] diff --git a/src/core/CCUtf8_string.ml b/src/core/CCUtf8_string.ml index ed148c37..80482d57 100644 --- a/src/core/CCUtf8_string.ml +++ b/src/core/CCUtf8_string.ml @@ -4,8 +4,6 @@ We only deal with UTF8 strings as they naturally map to OCaml bytestrings *) - - type uchar = Uchar.t type 'a gen = unit -> 'a option type 'a iter = ('a -> unit) -> unit @@ -30,7 +28,11 @@ let to_string x = x (** State for decoding *) module Dec = struct - type t = { s: string; len: int; (* max offset *) mutable i: int (* offset *) } + type t = { + s: string; + len: int; + (* max offset *) mutable i: int; (* offset *) + } let make ?(idx = 0) (s : string) : t = { s; i = idx; len = String.length s } end diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index f1d9d240..6a560df0 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -10,7 +10,10 @@ type 'a equal = 'a -> 'a -> bool type 'a ord = 'a -> 'a -> int type 'a printer = Format.formatter -> 'a -> unit -type ('a, 'mut) t = { mutable size: int; mutable vec: 'a array } +type ('a, 'mut) t = { + mutable size: int; + mutable vec: 'a array; +} (** A vector of 'a. *) type 'a vector = ('a, rw) t diff --git a/src/core/cpp/cpp.ml b/src/core/cpp/cpp.ml index 3ca612db..128ad712 100644 --- a/src/core/cpp/cpp.ml +++ b/src/core/cpp/cpp.ml @@ -1,6 +1,10 @@ module C = Configurator.V1 -type op = Le | Ge | Gt | Lt +type op = + | Le + | Ge + | Gt + | Lt type line = | If of op * int * int diff --git a/src/core/cpp/dune b/src/core/cpp/dune index fcb009f1..087a42df 100644 --- a/src/core/cpp/dune +++ b/src/core/cpp/dune @@ -3,5 +3,6 @@ (executable (name cpp) (flags :standard -warn-error -a+8) - (modes (best exe)) + (modes + (best exe)) (libraries dune.configurator)) diff --git a/src/core/tests/test_hash.ml b/src/core/tests/test_hash.ml index 21e24185..86ed830e 100644 --- a/src/core/tests/test_hash.ml +++ b/src/core/tests/test_hash.ml @@ -3,7 +3,10 @@ module H = CCHash module Hist = struct - type t = { tbl: (int, int) Hashtbl.t; mutable n_samples: int } + type t = { + tbl: (int, int) Hashtbl.t; + mutable n_samples: int; + } let create () : t = { tbl = Hashtbl.create 32; n_samples = 0 } diff --git a/src/data/CCBV.ml b/src/data/CCBV.ml index 5ef4f04e..8eeed88c 100644 --- a/src/data/CCBV.ml +++ b/src/data/CCBV.ml @@ -55,7 +55,10 @@ let[@inline] __popcount8 (b : int) : int = - [Bytes.length v.b >= div_ v.size] (enough storage) - all bits above [size] are 0 in [v.b] *) -type t = { mutable b: bytes; mutable size: int } +type t = { + mutable b: bytes; + mutable size: int; +} let length t = t.size let empty () = { b = Bytes.empty; size = 0 } diff --git a/src/data/CCBijection.ml b/src/data/CCBijection.ml index a8e8f52b..f72c3496 100644 --- a/src/data/CCBijection.ml +++ b/src/data/CCBijection.ml @@ -46,7 +46,10 @@ module Make (L : OrderedType) (R : OrderedType) = struct module MapL = Map.Make (L) module MapR = Map.Make (R) - type t = { left: right MapL.t; right: left MapR.t } + type t = { + left: right MapL.t; + right: left MapR.t; + } let empty = { left = MapL.empty; right = MapR.empty } let cardinal m = MapL.cardinal m.left diff --git a/src/data/CCCache.ml b/src/data/CCCache.ml index ef7ff912..e035b42d 100644 --- a/src/data/CCCache.ml +++ b/src/data/CCCache.ml @@ -67,7 +67,9 @@ let dummy = } module Linear = struct - type ('a, 'b) bucket = Empty | Pair of 'a * 'b + type ('a, 'b) bucket = + | Empty + | Pair of 'a * 'b type ('a, 'b) t = { eq: 'a equal; @@ -121,7 +123,9 @@ let linear ~eq size = } module Replacing = struct - type ('a, 'b) bucket = Empty | Pair of 'a * 'b + type ('a, 'b) bucket = + | Empty + | Pair of 'a * 'b type ('a, 'b) t = { eq: 'a equal; diff --git a/src/data/CCDeque.ml b/src/data/CCDeque.ml index 8ffd14d4..fbe7f29e 100644 --- a/src/data/CCDeque.ml +++ b/src/data/CCDeque.ml @@ -22,7 +22,10 @@ type 'a node = be anything but [Three] (all the intermediate ones are [Three]) *) -type 'a t = { mutable cur: 'a node; mutable size: int } +type 'a t = { + mutable cur: 'a node; + mutable size: int; +} (** The deque, a double linked list of cells *) exception Empty diff --git a/src/data/CCFun_vec.ml b/src/data/CCFun_vec.ml index bd2ddf13..62813074 100644 --- a/src/data/CCFun_vec.ml +++ b/src/data/CCFun_vec.ml @@ -91,7 +91,11 @@ end (** {2 Functors} *) -type 'a t = { size: int; leaves: 'a A.t; subs: 'a t A.t } +type 'a t = { + size: int; + leaves: 'a A.t; + subs: 'a t A.t; +} (* invariant: - [A.length leaves < A.max_length ==> A.is_empty subs] - either: @@ -108,7 +112,9 @@ let is_empty { size; _ } = size = 0 let length { size; _ } = size let return x = { leaves = A.return x; subs = A.empty; size = 1 } -type idx_l = I_one of int | I_cons of int * idx_l +type idx_l = + | I_one of int + | I_cons of int * idx_l (* split an index into a low and high parts *) let low_idx_ i = i land A.mask diff --git a/src/data/CCGraph.ml b/src/data/CCGraph.ml index caf4abf8..5bd22b06 100644 --- a/src/data/CCGraph.ml +++ b/src/data/CCGraph.ml @@ -121,7 +121,9 @@ let mk_stack () = (** Implementation from http://en.wikipedia.org/wiki/Skew_heap *) module Heap = struct - type 'a t = E | N of 'a * 'a t * 'a t + type 'a t = + | E + | N of 'a * 'a t * 'a t let is_empty = function | E -> true @@ -212,14 +214,19 @@ module Traverse = struct generic_tag ~tags ~bag:(mk_stack ()) ~graph iter module Event = struct - type edge_kind = [ `Forward | `Back | `Cross ] + type edge_kind = + [ `Forward + | `Back + | `Cross + ] type ('v, 'e) t = [ `Enter of 'v * int * ('v, 'e) path (* unique index in traversal, path from start *) | `Exit of 'v - | `Edge of 'v * 'e * 'v * edge_kind ] + | `Edge of 'v * 'e * 'v * edge_kind + ] (** A traversal is a iteruence of such events *) let get_vertex = function @@ -333,7 +340,10 @@ let topo_sort ~eq ?rev ~tbl ~graph iter = (** {2 Lazy Spanning Tree} *) module Lazy_tree = struct - type ('v, 'e) t = { vertex: 'v; children: ('e * ('v, 'e) t) list Lazy.t } + type ('v, 'e) t = { + vertex: 'v; + children: ('e * ('v, 'e) t) list Lazy.t; + } let make_ vertex children = { vertex; children } @@ -462,7 +472,8 @@ module Dot = struct | `Weight of int | `Style of string | `Label of string - | `Other of string * string ] + | `Other of string * string + ] (** Dot attribute *) let pp_list pp_x out l = @@ -474,7 +485,10 @@ module Dot = struct l; Format.pp_print_string out "]" - type vertex_state = { mutable explored: bool; id: int } + type vertex_state = { + mutable explored: bool; + id: int; + } (** Print an enum of Full.traverse_event *) let pp_all ~tbl ~eq ?(attrs_v = fun _ -> []) ?(attrs_e = fun _ -> []) diff --git a/src/data/CCGraph.mli b/src/data/CCGraph.mli index f780e2da..74bb7f1a 100644 --- a/src/data/CCGraph.mli +++ b/src/data/CCGraph.mli @@ -143,14 +143,19 @@ module Traverse : sig (** {2 More detailed interface} *) module Event : sig - type edge_kind = [ `Forward | `Back | `Cross ] + type edge_kind = + [ `Forward + | `Back + | `Cross + ] type ('v, 'e) t = [ `Enter of 'v * int * ('v, 'e) path (* unique index in traversal, path from start *) | `Exit of 'v - | `Edge of 'v * 'e * 'v * edge_kind ] + | `Edge of 'v * 'e * 'v * edge_kind + ] (** A traversal is a sequence of such events *) val get_vertex : ('v, 'e) t -> ('v * [ `Enter | `Exit ]) option @@ -222,7 +227,10 @@ val topo_sort_tag : (** {2 Lazy Spanning Tree} *) module Lazy_tree : sig - type ('v, 'e) t = { vertex: 'v; children: ('e * ('v, 'e) t) list Lazy.t } + type ('v, 'e) t = { + vertex: 'v; + children: ('e * ('v, 'e) t) list Lazy.t; + } val map_v : ('a -> 'b) -> ('a, 'e) t -> ('b, 'e) t val fold_v : ('acc -> 'v -> 'acc) -> 'acc -> ('v, _) t -> 'acc @@ -277,7 +285,8 @@ module Dot : sig | `Weight of int | `Style of string | `Label of string - | `Other of string * string ] + | `Other of string * string + ] (** Dot attribute *) type vertex_state diff --git a/src/data/CCHashTrie.ml b/src/data/CCHashTrie.ml index 79ff8982..786c2f45 100644 --- a/src/data/CCHashTrie.ml +++ b/src/data/CCHashTrie.ml @@ -12,7 +12,6 @@ module Transient = struct type t = { mutable frozen: bool } let empty = { frozen = true } (* special value *) - let equal a b = Stdlib.( == ) a b let create () = { frozen = false } let active st = not st.frozen @@ -166,7 +165,11 @@ let popcount (b : I64.t) : int = (* sparse array, using a bitfield and POPCOUNT *) module A_SPARSE = struct - type 'a t = { bits: int64; arr: 'a array; id: Transient.t } + type 'a t = { + bits: int64; + arr: 'a array; + id: Transient.t; + } let length_log = 6 let length = 1 lsl length_log @@ -283,11 +286,9 @@ module Make (Key : KEY) : S with type key = Key.t = struct val make : Key.t -> t val zero : t (* special "hash" *) - val is_0 : t -> bool val equal : t -> t -> bool val rem : t -> int (* [A.length_log] last bits *) - val quotient : t -> t (* remove [A.length_log] last bits *) end = struct type t = int diff --git a/src/data/CCImmutArray.ml b/src/data/CCImmutArray.ml index 2f2253b1..f3582003 100644 --- a/src/data/CCImmutArray.ml +++ b/src/data/CCImmutArray.ml @@ -70,7 +70,6 @@ type 'a gen = unit -> 'a option let of_list = Array.of_list let to_list = Array.to_list let of_array_unsafe a = a (* careful with that axe, Eugene *) - let to_iter a k = iter k a let of_iter s = diff --git a/src/data/CCIntMap.ml b/src/data/CCIntMap.ml index b18c71db..b4b1c733 100644 --- a/src/data/CCIntMap.ml +++ b/src/data/CCIntMap.ml @@ -11,7 +11,6 @@ module Bit : sig val is_0 : bit:t -> int -> bool val is_1 : bit:t -> int -> bool val mask : mask:t -> int -> int (* zeroes the bit, puts all lower bits to 1 *) - val lt : t -> t -> bool val gt : t -> t -> bool val equal_int : int -> t -> bool diff --git a/src/data/CCKTree.ml b/src/data/CCKTree.ml index 60a84d53..5b83a1d2 100644 --- a/src/data/CCKTree.ml +++ b/src/data/CCKTree.ml @@ -109,7 +109,10 @@ let dfs ~pset t = (** Functional queues for BFS *) module FQ = struct - type 'a t = { hd: 'a list; tl: 'a list } + type 'a t = { + hd: 'a list; + tl: 'a list; + } exception Empty @@ -216,7 +219,8 @@ module Dot = struct | `Style of string | `Label of string | `Id of string - | `Other of string * string ] + | `Other of string * string + ] (** Dot attributes for nodes *) type graph = string * attribute list t list diff --git a/src/data/CCKTree.mli b/src/data/CCKTree.mli index cd620920..38ecd7d0 100644 --- a/src/data/CCKTree.mli +++ b/src/data/CCKTree.mli @@ -108,7 +108,8 @@ module Dot : sig | `Style of string | `Label of string | `Id of string (** Unique ID in the graph. Allows sharing. *) - | `Other of string * string ] + | `Other of string * string + ] (** Dot attributes for nodes *) type graph = string * attribute list t list diff --git a/src/data/CCLazy_list.ml b/src/data/CCLazy_list.ml index 0c5706d4..94597fcf 100644 --- a/src/data/CCLazy_list.ml +++ b/src/data/CCLazy_list.ml @@ -3,7 +3,10 @@ (** {1 Lazy List} *) type +'a t = 'a node lazy_t -and +'a node = Nil | Cons of 'a * 'a t + +and +'a node = + | Nil + | Cons of 'a * 'a t let empty = Lazy.from_val Nil let return x = Lazy.from_val (Cons (x, empty)) diff --git a/src/data/CCLazy_list.mli b/src/data/CCLazy_list.mli index 1788b672..76588994 100644 --- a/src/data/CCLazy_list.mli +++ b/src/data/CCLazy_list.mli @@ -5,7 +5,10 @@ @since 0.17 *) type +'a t = 'a node lazy_t -and +'a node = Nil | Cons of 'a * 'a t + +and +'a node = + | Nil + | Cons of 'a * 'a t val empty : 'a t (** Empty list. *) diff --git a/src/data/CCMixset.ml b/src/data/CCMixset.ml index 11e19686..f5887a49 100644 --- a/src/data/CCMixset.ml +++ b/src/data/CCMixset.ml @@ -9,7 +9,11 @@ module IMap = Map.Make (struct end) type t = (unit -> unit) IMap.t -and 'a key = { id: int; mutable opt: 'a option } + +and 'a key = { + id: int; + mutable opt: 'a option; +} let newkey_n_ = ref 0 diff --git a/src/data/CCMultiMap.ml b/src/data/CCMultiMap.ml index 9129b51c..99aa6fa5 100644 --- a/src/data/CCMultiMap.ml +++ b/src/data/CCMultiMap.ml @@ -280,7 +280,10 @@ module MakeBidir (L : OrderedType) (R : OrderedType) = struct module MapL = Make (L) (R) module MapR = Make (R) (L) - type t = { left: MapL.t; right: MapR.t } + type t = { + left: MapL.t; + right: MapR.t; + } let empty = { left = MapL.empty; right = MapR.empty } let is_empty m = MapL.is_empty m.left diff --git a/src/data/CCMutHeap.ml b/src/data/CCMutHeap.ml index 26150b19..3dc4f9de 100644 --- a/src/data/CCMutHeap.ml +++ b/src/data/CCMutHeap.ml @@ -14,9 +14,7 @@ module Make (Elt : RANKED) = struct let _absent_index = -1 let create () = { heap = Vec.create () } let[@inline] left i = (i lsl 1) + 1 (* i*2 + 1 *) - let[@inline] right i = (i + 1) lsl 1 (* (i+1)*2 *) - let[@inline] parent i = (i - 1) asr 1 (* (i-1) / 2 *) (* diff --git a/src/data/CCPersistentArray.ml b/src/data/CCPersistentArray.ml index 367cdab3..07e1cf4c 100644 --- a/src/data/CCPersistentArray.ml +++ b/src/data/CCPersistentArray.ml @@ -26,7 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (* Persistent arrays *) type 'a t = 'a data ref -and 'a data = Array of 'a array | Diff of int * 'a * 'a t + +and 'a data = + | Array of 'a array + | Diff of int * 'a * 'a t let make n a = ref (Array (Array.make n a)) let init n f = ref (Array (Array.init n f)) diff --git a/src/data/CCPersistentHashtbl.ml b/src/data/CCPersistentHashtbl.ml index 3d7e0c86..31f8ff4b 100644 --- a/src/data/CCPersistentHashtbl.ml +++ b/src/data/CCPersistentHashtbl.ml @@ -133,10 +133,14 @@ module Make (H : HashedType) : S with type key = H.t = struct } (* piece of a persistent array *) - and 'a p_array = Arr of 'a bucket array | Set of int * 'a bucket * 'a t + and 'a p_array = + | Arr of 'a bucket array + | Set of int * 'a bucket * 'a t (* bucket of the hashtbl *) - and 'a bucket = Nil | Cons of key * 'a * 'a bucket + and 'a bucket = + | Nil + | Cons of key * 'a * 'a bucket (* first power of two that is bigger than [than], starting from [n] *) let rec power_two_larger ~than n = diff --git a/src/data/CCRAL.ml b/src/data/CCRAL.ml index 620173b7..06a94be1 100644 --- a/src/data/CCRAL.ml +++ b/src/data/CCRAL.ml @@ -3,7 +3,9 @@ (** {1 Random-Access Lists} *) (** A complete binary tree *) -type +'a tree = Leaf of 'a | Node of 'a * 'a tree * 'a tree +type +'a tree = + | Leaf of 'a + | Node of 'a * 'a tree * 'a tree and +'a t = | Nil diff --git a/src/data/CCSimple_queue.ml b/src/data/CCSimple_queue.ml index 58a605cd..0b7ade9b 100644 --- a/src/data/CCSimple_queue.ml +++ b/src/data/CCSimple_queue.ml @@ -6,7 +6,10 @@ type 'a iter = ('a -> unit) -> unit type 'a printer = Format.formatter -> 'a -> unit type 'a gen = unit -> 'a option -type 'a t = { hd: 'a list; tl: 'a list } +type 'a t = { + hd: 'a list; + tl: 'a list; +} (** Queue containing elements of type 'a *) let empty = { hd = []; tl = [] } diff --git a/src/data/CCTrie.ml b/src/data/CCTrie.ml index 67fc8c16..b8f6a3ed 100644 --- a/src/data/CCTrie.ml +++ b/src/data/CCTrie.ml @@ -495,7 +495,9 @@ module Make (W : WORD) : S with type char_ = W.char_ and type key = W.t = struct | Yield of 'a * char_ difflist | Explore of 'a t * char_ difflist - type direction = Above | Below + type direction = + | Above + | Below let rec explore ~dir k alt = match alt with diff --git a/src/data/CCWBTree.ml b/src/data/CCWBTree.ml index 793569ce..d1fb75cb 100644 --- a/src/data/CCWBTree.ml +++ b/src/data/CCWBTree.ml @@ -135,7 +135,10 @@ end module MakeFull (K : KEY) : S with type key = K.t = struct type key = K.t type weight = int - type +'a t = E | N of key * 'a * 'a t * 'a t * weight + + type +'a t = + | E + | N of key * 'a * 'a t * 'a t * weight let empty = E diff --git a/src/data/dune b/src/data/dune index 4bed1adf..0cc561ef 100644 --- a/src/data/dune +++ b/src/data/dune @@ -2,6 +2,14 @@ (name containers_data) (public_name containers-data) (wrapped false) - (flags :standard -warn-error -3 -w -70 -color always -safe-string - -strict-sequence) + (flags + :standard + -warn-error + -3 + -w + -70 + -color + always + -safe-string + -strict-sequence) (libraries containers)) diff --git a/src/dune b/src/dune index 6b6da352..39ec53cb 100644 --- a/src/dune +++ b/src/dune @@ -1,9 +1,25 @@ (env (_ - (flags :standard -warn-error -a+8 -w -32-48-70 -w +a-4-40-42-44-70 - -color always -safe-string -strict-sequence) - (ocamlopt_flags :standard -O3 -unbox-closures -unbox-closures-factor 20 - -inline 100))) + (flags + :standard + -warn-error + -a+8 + -w + -32-48-70 + -w + +a-4-40-42-44-70 + -color + always + -safe-string + -strict-sequence) + (ocamlopt_flags + :standard + -O3 + -unbox-closures + -unbox-closures-factor + 20 + -inline + 100))) (executable (name mdx_runner) diff --git a/src/pp/containers_pp.ml b/src/pp/containers_pp.ml index 8ca900c0..6724a511 100644 --- a/src/pp/containers_pp.ml +++ b/src/pp/containers_pp.ml @@ -26,7 +26,13 @@ end module Ext = struct type view = .. - type 'a key = { id: int; inject: 'a -> view; extract: view -> 'a option } + + type 'a key = { + id: int; + inject: 'a -> view; + extract: view -> 'a option; + } + type map = view Int_map.t let empty : map = Int_map.empty @@ -79,7 +85,10 @@ and view = | Text_sub of string * int * int | Text_zero_width of string | Group of t - | Fill of { sep: t; l: t list } + | Fill of { + sep: t; + l: t list; + } | Wrap : 'a Ext.t * 'a * t -> view (* debug printer *) @@ -214,7 +223,11 @@ module Flatten = struct end module Pretty = struct - type st = { out: Out.t; width: int; ext_map: Ext.map } + type st = { + out: Out.t; + width: int; + ext_map: Ext.map; + } (** Add [i] spaces of indentation. *) let add_indent st (i : int) = @@ -460,14 +473,23 @@ end module Term_color = struct type color = - [ `Black | `Red | `Yellow | `Green | `Blue | `Magenta | `Cyan | `White ] + [ `Black + | `Red + | `Yellow + | `Green + | `Blue + | `Magenta + | `Cyan + | `White + ] type style = [ `FG of color (* foreground *) | `BG of color (* background *) | `Bold | `Reset - | `Underline ] + | `Underline + ] let int_of_color_ = function | `Black -> 0 diff --git a/src/pp/containers_pp.mli b/src/pp/containers_pp.mli index f5ff88d4..780f38a0 100644 --- a/src/pp/containers_pp.mli +++ b/src/pp/containers_pp.mli @@ -261,9 +261,23 @@ end (** Simple colors in terminals *) module Term_color : sig type color = - [ `Black | `Blue | `Cyan | `Green | `Magenta | `Red | `White | `Yellow ] + [ `Black + | `Blue + | `Cyan + | `Green + | `Magenta + | `Red + | `White + | `Yellow + ] - type style = [ `BG of color | `Bold | `FG of color | `Reset | `Underline ] + type style = + [ `BG of color + | `Bold + | `FG of color + | `Reset + | `Underline + ] val color : color -> t -> t val style_l : style list -> t -> t diff --git a/src/pp/dune b/src/pp/dune index 2220457c..4c33e839 100644 --- a/src/pp/dune +++ b/src/pp/dune @@ -1,7 +1,6 @@ - (library - (name containers_pp) - (public_name containers.pp) - (synopsis "Pretty printer for Containers") - (flags :standard) - (libraries containers)) + (name containers_pp) + (public_name containers.pp) + (synopsis "Pretty printer for Containers") + (flags :standard) + (libraries containers)) diff --git a/src/pvec/containers_pvec.ml b/src/pvec/containers_pvec.ml index 8a9b9c4b..9f30dd07 100644 --- a/src/pvec/containers_pvec.ml +++ b/src/pvec/containers_pvec.ml @@ -58,7 +58,10 @@ module A = struct ) end -type 'a tree = Empty | Node of 'a tree A.t | Leaf of 'a A.t +type 'a tree = + | Empty + | Node of 'a tree A.t + | Leaf of 'a A.t type 'a t = { t: 'a tree; (** The 32-way tree *) diff --git a/src/pvec/dune b/src/pvec/dune index 6ff76874..cca1fca6 100644 --- a/src/pvec/dune +++ b/src/pvec/dune @@ -1,8 +1,7 @@ - (library - (name containers_pvec) - (public_name containers.pvec) - (preprocess - (action - (run %{project_root}/src/core/cpp/cpp.exe %{input-file}))) - (synopsis "Persistent vector for OCaml")) + (name containers_pvec) + (public_name containers.pvec) + (preprocess + (action + (run %{project_root}/src/core/cpp/cpp.exe %{input-file}))) + (synopsis "Persistent vector for OCaml")) diff --git a/src/scc/dune b/src/scc/dune index 95af7c23..8562b65f 100644 --- a/src/scc/dune +++ b/src/scc/dune @@ -1,6 +1,5 @@ - (library - (name containers_scc) - (public_name containers.scc) - (synopsis "strongly connected components algorithm") - (libraries containers)) + (name containers_scc) + (public_name containers.scc) + (synopsis "strongly connected components algorithm") + (libraries containers)) diff --git a/src/testlib/containers_testlib.ml b/src/testlib/containers_testlib.ml index 0847c3f2..11f5a58c 100644 --- a/src/testlib/containers_testlib.ml +++ b/src/testlib/containers_testlib.ml @@ -8,7 +8,13 @@ type 'a print = 'a -> string module Test = struct type run = | T of { prop: unit -> bool } - | Eq : { eq: 'a eq option; print: 'a print option; lhs: 'a; rhs: 'a } -> run + | Eq : { + eq: 'a eq option; + print: 'a print option; + lhs: 'a; + rhs: 'a; + } + -> run | Q : { count: int option; arb: 'a Q.arbitrary; @@ -20,7 +26,12 @@ module Test = struct } -> run - type t = { name: string option; run: run; __FILE__: string; n: int } + type t = { + name: string option; + run: run; + __FILE__: string; + n: int; + } (** Location for this test *) let str_loc (self : t) : string = diff --git a/tests/cbor/t_appendix_a.ml b/tests/cbor/t_appendix_a.ml index a423b06f..98331d04 100644 --- a/tests/cbor/t_appendix_a.ml +++ b/tests/cbor/t_appendix_a.ml @@ -10,8 +10,16 @@ let pp_json = J.pretty_print ~std:true let spf = Printf.sprintf module Test = struct - type expect = Diagnostic of string | Decoded of json - type t = { hex: string; raw: string; expect: expect; roundtrip: bool } + type expect = + | Diagnostic of string + | Decoded of json + + type t = { + hex: string; + raw: string; + expect: expect; + roundtrip: bool; + } let pp_expect out = function | Diagnostic s -> Fmt.fprintf out "(diagnostic %S)" s @@ -51,7 +59,11 @@ let skip = "5f42010243030405ff", "(requires representation of indefinite length)"; ] -type count = { mutable n_ok: int; mutable n_err: int; mutable n_skip: int } +type count = { + mutable n_ok: int; + mutable n_err: int; + mutable n_skip: int; +} let run_test (c : count) (t : Test.t) : unit = try diff --git a/tests/core/dune b/tests/core/dune index 4c4ce785..d7c90a5e 100644 --- a/tests/core/dune +++ b/tests/core/dune @@ -1,11 +1,21 @@ (test (name t) (flags :standard -strict-sequence -warn-error -a+8) - (modes (best exe)) + (modes + (best exe)) (package containers) (preprocess (action (run %{project_root}/src/core/cpp/cpp.exe %{input-file}))) - (libraries containers containers.bencode containers.cbor - containers.unix containers.pp - threads containers_testlib iter gen uutf csexp)) + (libraries + containers + containers.bencode + containers.cbor + containers.unix + containers.pp + threads + containers_testlib + iter + gen + uutf + csexp)) diff --git a/tests/core/t_parse.ml b/tests/core/t_parse.ml index f8428321..27b1f96b 100644 --- a/tests/core/t_parse.ml +++ b/tests/core/t_parse.ml @@ -4,7 +4,9 @@ module P = CCParse open CCParse module T = struct - type tree = L of int | N of tree * tree + type tree = + | L of int + | N of tree * tree end open T diff --git a/tests/data/dune b/tests/data/dune index ff73126d..9c54035f 100644 --- a/tests/data/dune +++ b/tests/data/dune @@ -1,6 +1,7 @@ (test (name t) (flags :standard -strict-sequence -warn-error -a+8) - (modes (best exe)) + (modes + (best exe)) (package containers-data) (libraries containers containers-data containers_testlib iter gen)) diff --git a/tests/data/t_bv.ml b/tests/data/t_bv.ml index 1d0428c9..36bf278e 100644 --- a/tests/data/t_bv.ml +++ b/tests/data/t_bv.ml @@ -236,8 +236,7 @@ q Q.Test.fail_reportf "l1=%a, l2=%a" ppli l1 ppli l2) ;; -eq ~cmp:equal ~printer:(CCFormat.to_string pp) - (of_list [ 0 ]) +eq ~cmp:equal ~printer:(CCFormat.to_string pp) (of_list [ 0 ]) (let bv = empty () in set bv 0; bv) @@ -714,7 +713,10 @@ module Op = struct end module Ref_ = struct - type t = { mutable set: Intset.t; mutable size: int } + type t = { + mutable set: Intset.t; + mutable size: int; + } let empty () = { size = 0; set = Intset.empty } diff --git a/tests/data/t_mutheap.ml b/tests/data/t_mutheap.ml index c66bdb5b..90873825 100644 --- a/tests/data/t_mutheap.ml +++ b/tests/data/t_mutheap.ml @@ -1,7 +1,11 @@ module Test = (val Containers_testlib.make ~__FILE__ ()) open Test -type elt = { x: string; mutable rank: int; mutable idx: int } +type elt = { + x: string; + mutable rank: int; + mutable idx: int; +} module Elt = struct type t = elt diff --git a/tests/data/t_ringbuffer.ml b/tests/data/t_ringbuffer.ml index 2b9c26d6..bf9b7c68 100644 --- a/tests/data/t_ringbuffer.ml +++ b/tests/data/t_ringbuffer.ml @@ -388,7 +388,10 @@ let arb_op = Q.make ~shrink:shrink_op ~print:str_of_op gen_op let arb_ops = Q.list_of_size Q.Gen.(0 -- 20) arb_op module L_impl = struct - type t = { size: int; mutable l: char list } + type t = { + size: int; + mutable l: char list; + } let create size = { size; l = [] } diff --git a/tests/data/t_wbt.ml b/tests/data/t_wbt.ml index 64d15702..3b41e907 100644 --- a/tests/data/t_wbt.ml +++ b/tests/data/t_wbt.ml @@ -3,7 +3,10 @@ open Test open CCWBTree module M = Make (CCInt) -type op = Add of int * int | Remove of int | Remove_min +type op = + | Add of int * int + | Remove of int + | Remove_min let gen_op = CCRandom.( diff --git a/tests/pvec/dune b/tests/pvec/dune index d4d56f95..e78c93ef 100644 --- a/tests/pvec/dune +++ b/tests/pvec/dune @@ -1,7 +1,7 @@ - (test (name t) (flags :standard -strict-sequence -warn-error -a+8) - (modes (best exe)) + (modes + (best exe)) (package containers) (libraries containers containers.pvec containers_testlib iter))