style: reindent

This commit is contained in:
Simon Cruanes 2018-03-28 19:46:57 -05:00
parent b874ff9bf9
commit 972a6f2720
8 changed files with 77 additions and 77 deletions

View file

@ -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 *)

View file

@ -84,7 +84,7 @@ let rev s =
(*$Q
Q.printable_string (fun s -> \
rev s = (to_list s |> List.rev |> of_list))
*)
*)
(*$=

View file

@ -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)
)
*)
*)

View file

@ -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
{

View file

@ -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

View file

@ -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

View file

@ -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} *)

View file

@ -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)