From 972a6f27203ee4608e8faeb2a00556347d441a75 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 28 Mar 2018 19:46:57 -0500 Subject: [PATCH] style: reindent --- src/core/CCFormat.mli | 2 +- src/core/CCString.ml | 2 +- src/core/CCUtf8_string.ml | 6 ++-- src/data/CCBijection.ml | 36 +++++++++++----------- src/data/CCBijection.mli | 6 ++-- src/data/CCFun_vec.ml | 34 ++++++++++----------- src/data/CCFun_vec.mli | 64 +++++++++++++++++++-------------------- src/iter/CCLazy_list.ml | 4 +-- 8 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/core/CCFormat.mli b/src/core/CCFormat.mli index bdf2f394..f7650483 100644 --- a/src/core/CCFormat.mli +++ b/src/core/CCFormat.mli @@ -258,7 +258,7 @@ val sprintf_no_color : ('a, t, unit, string) format4 -> 'a val sprintf_dyn_color : colors:bool -> ('a, t, unit, string) format4 -> 'a (** Like {!sprintf} but enable/disable colors depending on [colors]. - + Example: {[ (* with colors *) diff --git a/src/core/CCString.ml b/src/core/CCString.ml index f5004529..518ffd06 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -84,7 +84,7 @@ let rev s = (*$Q Q.printable_string (fun s -> \ rev s = (to_list s |> List.rev |> of_list)) - *) +*) (*$= diff --git a/src/core/CCUtf8_string.ml b/src/core/CCUtf8_string.ml index 372271e2..60ccf1b5 100644 --- a/src/core/CCUtf8_string.ml +++ b/src/core/CCUtf8_string.ml @@ -237,7 +237,7 @@ let of_string s = if is_valid s then Some s else None let printer s = String.escaped (to_string s) let pp_uchar (c:Uchar.t) = Printf.sprintf "0x%x" (Uchar.to_int c) -let uutf_is_valid s = + let uutf_is_valid s = try Uutf.String.fold_utf_8 (fun () _ -> function @@ -248,7 +248,7 @@ let uutf_is_valid s = with Exit -> false -let uutf_to_seq s f = + let uutf_to_seq s f = Uutf.String.fold_utf_8 (fun () _ -> function | `Malformed _ -> f (Uchar.of_int 0xfffd) @@ -331,4 +331,4 @@ let uutf_to_seq s f = else Q.Test.fail_reportf "uutf: '%s', containers: '%s', is_valid %B, uutf_is_valid %B" (pp l_uutf) (pp l_co) (is_valid s) (uutf_is_valid s) ) - *) +*) diff --git a/src/data/CCBijection.ml b/src/data/CCBijection.ml index cfb63537..3b2b1e3b 100644 --- a/src/data/CCBijection.ml +++ b/src/data/CCBijection.ml @@ -46,14 +46,14 @@ module Make(L : OrderedType)(R : OrderedType) = struct module MapR = Map.Make(R) type t = { - left : right MapL.t; - right : left MapR.t; - } + left : right MapL.t; + right : left MapR.t; + } let empty = { - left = MapL.empty; - right = MapR.empty; - } + left = MapL.empty; + right = MapR.empty; + } let cardinal m = MapL.cardinal m.left @@ -66,17 +66,17 @@ module Make(L : OrderedType)(R : OrderedType) = struct let compare a b = MapL.compare R.compare a.left b.left let add a b m = { - left = - (try let found = MapR.find b m.right in - if L.compare found a <> 0 then MapL.remove found m.left else m.left - with Not_found -> m.left) - |> MapL.add a b; - right = - (try let found = MapL.find a m.left in - if R.compare found b <> 0 then MapR.remove found m.right else m.right - with Not_found -> m.right) - |> MapR.add b a; - } + left = + (try let found = MapR.find b m.right in + if L.compare found a <> 0 then MapL.remove found m.left else m.left + with Not_found -> m.left) + |> MapL.add a b; + right = + (try let found = MapL.find a m.left in + if R.compare found b <> 0 then MapR.remove found m.right else m.right + with Not_found -> m.right) + |> MapR.add b a; + } let find_left key m = MapL.find key m.left let find_right key m = MapR.find key m.right @@ -84,7 +84,7 @@ module Make(L : OrderedType)(R : OrderedType) = struct let mem left right m = try R.compare right (find_left left m) = 0 with Not_found -> false let mem_left key m = MapL.mem key m.left let mem_right key m = MapR.mem key m.right - + let remove a b m = if mem a b m then { diff --git a/src/data/CCBijection.mli b/src/data/CCBijection.mli index 9ee7388a..996633c4 100644 --- a/src/data/CCBijection.mli +++ b/src/data/CCBijection.mli @@ -28,8 +28,8 @@ module type S = sig val add : left -> right -> t -> t (** Add [left] and [right] correspondence to bijection such that - [left] and [right] are unique in their respective sets and only - correspond to each other. *) + [left] and [right] are unique in their respective sets and only + correspond to each other. *) val cardinal : t -> int (** Number of bindings. O(n) time *) @@ -51,7 +51,7 @@ module type S = sig val remove : left -> right -> t -> t (** Removes the [left], [right] binding if it exists. Returns the - same bijection otherwise. *) + same bijection otherwise. *) val remove_left : left -> t -> t (** Remove the binding with [left] key if it exists. Returns the diff --git a/src/data/CCFun_vec.ml b/src/data/CCFun_vec.ml index e49a08bb..29af2859 100644 --- a/src/data/CCFun_vec.ml +++ b/src/data/CCFun_vec.ml @@ -19,17 +19,17 @@ type 'a printer = Format.formatter -> 'a -> unit type 'a ktree = unit -> [`Nil | `Node of 'a * 'a ktree list] (* TODO -(** {2 Transient IDs} *) -module Transient = struct - type state = { mutable frozen: bool } - type t = Nil | St of state - let empty = Nil - let equal a b = Pervasives.(==) a b - let create () = St {frozen=false} - let active = function Nil -> false | St st -> not st.frozen - let frozen = function Nil -> true | St st -> st.frozen - let freeze = function Nil -> () | St st -> st.frozen <- true - let with_ f = + (** {2 Transient IDs} *) + module Transient = struct + type state = { mutable frozen: bool } + type t = Nil | St of state + let empty = Nil + let equal a b = Pervasives.(==) a b + let create () = St {frozen=false} + let active = function Nil -> false | St st -> not st.frozen + let frozen = function Nil -> true | St st -> st.frozen + let freeze = function Nil -> () | St st -> st.frozen <- true + let with_ f = let r = create() in try let x = f r in @@ -38,9 +38,9 @@ module Transient = struct with e -> freeze r; raise e - exception Frozen -end - *) + exception Frozen + end +*) (* function array *) module A = struct @@ -133,7 +133,7 @@ type 'a t = { (forall j>=i, sub[j].size<32^{n+1}-1)] (prefix of subs has size of complete binary tree; suffix has smaller size (actually decreasing)) - *) +*) let empty = {size=0; leaves=A.empty; subs=A.empty} @@ -290,7 +290,7 @@ let rec map f m : _ t = let f = Q.Fn.apply f in (List.map f l) = (of_list l |> map f |> to_list) ) - *) +*) let append a b = if is_empty b then a @@ -300,7 +300,7 @@ let append a b = Q.(pair (small_list int)(small_list int)) (fun (l1,l2) -> (l1 @ l2) = (append (of_list l1)(of_list l2) |> to_list) ) - *) +*) let add_list v l = List.fold_left (fun v x -> push x v) v l diff --git a/src/data/CCFun_vec.mli b/src/data/CCFun_vec.mli index a536c101..b6389000 100644 --- a/src/data/CCFun_vec.mli +++ b/src/data/CCFun_vec.mli @@ -16,37 +16,37 @@ type 'a printer = Format.formatter -> 'a -> unit type 'a ktree = unit -> [`Nil | `Node of 'a * 'a ktree list] (* TODO: restore this -(** {2 Transient Identifiers} *) -module Transient : sig - type t - (** Identifiers for transient modifications. A transient modification + (** {2 Transient Identifiers} *) + module Transient : sig + type t + (** Identifiers for transient modifications. A transient modification is uniquely identified by a [Transient.t]. Once [Transient.freeze r] is called, [r] cannot be used to modify the structure again. *) - val create : unit -> t - (** Create a new, active ID. *) + val create : unit -> t + (** Create a new, active ID. *) - val equal : t -> t -> bool - (** Equality between IDs. *) + val equal : t -> t -> bool + (** Equality between IDs. *) - val frozen : t -> bool - (** [frozen i] returns [true] if [freeze i] was called before. In this case, + val frozen : t -> bool + (** [frozen i] returns [true] if [freeze i] was called before. In this case, the ID cannot be used for modifications again. *) - val active : t -> bool - (** [active i] is [not (frozen i)]. *) + val active : t -> bool + (** [active i] is [not (frozen i)]. *) - val freeze : t -> unit - (** [freeze i] makes [i] unusable for new modifications. The values + val freeze : t -> unit + (** [freeze i] makes [i] unusable for new modifications. The values created with [i] will now be immutable. *) - val with_ : (t -> 'a) -> 'a - (** [with_ f] creates a transient ID [i], calls [f i], + val with_ : (t -> 'a) -> 'a + (** [with_ f] creates a transient ID [i], calls [f i], freezes the ID [i] and returns the result of [f i]. *) - exception Frozen - (** Raised when a frozen ID is used. *) -end + exception Frozen + (** Raised when a frozen ID is used. *) + end *) (** {2 Signature} *) @@ -92,19 +92,19 @@ val choose : 'a t -> 'a option (* TODO -val push_mut : id:Transient.t -> 'a -> 'a t -> 'a t -(** [add_mut ~id k v m] behaves like [add k v m], except it will mutate + val push_mut : id:Transient.t -> 'a -> 'a t -> 'a t + (** [add_mut ~id k v m] behaves like [add k v m], except it will mutate in place whenever possible. Changes done with an [id] might affect all versions of the structure obtained with the same [id] (but not other versions). @raise Transient.Frozen if [id] is frozen. *) -val pop_mut : id:Transient.t -> 'a t -> 'a * 'a t -(** Same as {!remove}, but modifies in place whenever possible. + val pop_mut : id:Transient.t -> 'a t -> 'a * 'a t + (** Same as {!remove}, but modifies in place whenever possible. @raise Transient.Frozen if [id] is frozen. *) -val append_mut : id:Transient.t -> into:'a t -> 'a t -> 'a t - *) + val append_mut : id:Transient.t -> into:'a t -> 'a t -> 'a t +*) (** {6 Conversions} *) @@ -128,15 +128,15 @@ val to_gen : 'a t -> 'a gen (* TODO -val add_list_mut : id:Transient.t -> 'a t -> 'a list -> 'a t -(** @raise Frozen if the ID is frozen. *) + val add_list_mut : id:Transient.t -> 'a t -> 'a list -> 'a t + (** @raise Frozen if the ID is frozen. *) -val add_seq_mut : id:Transient.t -> 'a t -> 'a sequence -> 'a t -(** @raise Frozen if the ID is frozen. *) + val add_seq_mut : id:Transient.t -> 'a t -> 'a sequence -> 'a t + (** @raise Frozen if the ID is frozen. *) -val add_gen_mut : id:Transient.t -> 'a t -> 'a gen -> 'a t -(** @raise Frozen if the ID is frozen. *) - *) + val add_gen_mut : id:Transient.t -> 'a t -> 'a gen -> 'a t + (** @raise Frozen if the ID is frozen. *) +*) (** {6 IO} *) diff --git a/src/iter/CCLazy_list.ml b/src/iter/CCLazy_list.ml index 40a416d9..16c4e10f 100644 --- a/src/iter/CCLazy_list.ml +++ b/src/iter/CCLazy_list.ml @@ -84,10 +84,10 @@ let rec flat_map ~f l = let default ~default l = lazy ( - match l with + match l with | lazy Nil -> Lazy.force default | lazy l -> l - ) + ) (*$= [1] (default (return 1) empty |> to_list)