Skip to content

Commit 3daa42e

Browse files
committed
ocamlformat 0.26.1
1 parent feff545 commit 3daa42e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+681
-684
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.19.0
1+
version=0.26.1
22
break-cases = fit
33
break-collection-expressions = fit-or-vertical
44
break-fun-decl = wrap

src/baselib/ocsigen_cache.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,11 @@ end = struct
407407
end
408408

409409
module Weak = Weak.Make (struct
410-
type t = unit -> unit
410+
type t = unit -> unit
411411

412-
let hash = Hashtbl.hash
413-
let equal = ( == )
414-
end)
412+
let hash = Hashtbl.hash
413+
let equal = ( == )
414+
end)
415415

416416
let clear_all = Weak.create 17
417417

@@ -424,18 +424,18 @@ functor
424424
->
425425
struct
426426
module H = Hashtbl.Make (struct
427-
type t = A.key
427+
type t = A.key
428428

429-
let equal a a' = a = a'
430-
let hash = Hashtbl.hash
431-
end)
429+
let equal a a' = a = a'
430+
let hash = Hashtbl.hash
431+
end)
432432

433433
type t =
434434
{ mutable pointers : A.key Dlist.t
435435
; mutable table : (A.value * A.key Dlist.node) H.t
436436
; finder : A.key -> A.value Lwt.t
437437
; clear : unit -> unit
438-
(* This function clears the cache. It is put inside the
438+
(* This function clears the cache. It is put inside the
439439
cache structure so that it is garbage-collected only when the cache
440440
is no longer referenced, as the functions themselves are put inside
441441
a weak hash table *)

src/baselib/ocsigen_cache.mli

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
*)
3636

3737
module Make : functor
38-
(A : sig
39-
type key
40-
type value
41-
end)
42-
-> sig
38+
(A : sig
39+
type key
40+
type value
41+
end)
42+
-> sig
4343
(** [new cache finder ?timer size] creates a cache object where [finder]
4444
is the function responsible for retrieving non-cached data, [timer]
4545
(if any) is the life span of cached values (in seconds) (values in the
@@ -53,25 +53,21 @@ module Make : functor
5353
Using [timer] allow one to create a cache
5454
bounded both in space and time. It is to be noted that real lifespan
5555
of values is always slightly greater than [timer]. *)
56-
class cache :
57-
(A.key -> A.value Lwt.t)
58-
-> ?timer:float
59-
-> int
60-
-> object
61-
method find : A.key -> A.value Lwt.t
62-
(** Find the cached value associated to the key, or binds this
56+
class cache : (A.key -> A.value Lwt.t) -> ?timer:float -> int -> object
57+
method find : A.key -> A.value Lwt.t
58+
(** Find the cached value associated to the key, or binds this
6359
value in the cache using the function [finder] passed as argument
6460
to [create], and returns this value *)
6561

66-
method find_in_cache : A.key -> A.value
67-
(** Find the cached value associated to the key. Raises [Not_found]
62+
method find_in_cache : A.key -> A.value
63+
(** Find the cached value associated to the key. Raises [Not_found]
6864
if the key is not present in the cache *)
6965

70-
method remove : A.key -> unit
71-
method add : A.key -> A.value -> unit
72-
method clear : unit -> unit
73-
method size : int
74-
end
66+
method remove : A.key -> unit
67+
method add : A.key -> A.value -> unit
68+
method clear : unit -> unit
69+
method size : int
70+
end
7571
end
7672

7773
val clear_all_caches : unit -> unit

src/baselib/ocsigen_lib.ml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module Ip_address = struct
3333
in
3434
let options =
3535
[ (if v6
36-
then Lwt_unix.AI_FAMILY Lwt_unix.PF_INET6
37-
else Lwt_unix.AI_FAMILY Lwt_unix.PF_INET) ]
36+
then Lwt_unix.AI_FAMILY Lwt_unix.PF_INET6
37+
else Lwt_unix.AI_FAMILY Lwt_unix.PF_INET) ]
3838
in
3939
Lwt.bind (Lwt_unix.getaddrinfo host "" options) aux
4040

@@ -181,7 +181,7 @@ module Url = struct
181181

182182
let fixup_url_string1 =
183183
Netstring_pcre.global_substitute problem_re1 (fun m s ->
184-
Printf.sprintf "%%%02x" (Char.code s.[fst (Pcre.get_substring_ofs m 0)]))
184+
Printf.sprintf "%%%02x" (Char.code s.[fst (Pcre.get_substring_ofs m 0)]))
185185

186186
(* I add this fixup to handle %uxxxx sent by browsers.
187187
Translated to %xx%xx *)
@@ -191,11 +191,11 @@ module Url = struct
191191
fixup_url_string1
192192
(Netstring_pcre.global_substitute problem_re2
193193
(fun m s ->
194-
String.concat ""
195-
[ "%"
196-
; Netstring_pcre.matched_group m 1 s
197-
; "%"
198-
; Netstring_pcre.matched_group m 2 s ])
194+
String.concat ""
195+
[ "%"
196+
; Netstring_pcre.matched_group m 1 s
197+
; "%"
198+
; Netstring_pcre.matched_group m 2 s ])
199199
s)
200200

201201
(*VVV This is in Netencoding but we have a problem with ~
@@ -296,19 +296,19 @@ module Url = struct
296296
let l = String.length s1 in
297297
Netstring_pcre.global_substitute url_decoding_re
298298
(fun r _ ->
299-
match Netstring_pcre.matched_string r s1 with
300-
| "+" -> if plus then " " else "+"
301-
| _ -> (
302-
let i = fst (Pcre.get_substring_ofs r 0) in
303-
(* Assertion: s1.[i] = '%' *)
304-
if i + 2 >= l then failwith "decode";
305-
let c1 = s1.[i + 1] in
306-
let c2 = s1.[i + 2] in
307-
try
308-
let k1 = of_hex1 c1 in
309-
let k2 = of_hex1 c2 in
310-
String.make 1 (Char.chr ((k1 lsl 4) lor k2))
311-
with Not_found -> failwith "decode"))
299+
match Netstring_pcre.matched_string r s1 with
300+
| "+" -> if plus then " " else "+"
301+
| _ -> (
302+
let i = fst (Pcre.get_substring_ofs r 0) in
303+
(* Assertion: s1.[i] = '%' *)
304+
if i + 2 >= l then failwith "decode";
305+
let c1 = s1.[i + 1] in
306+
let c2 = s1.[i + 2] in
307+
try
308+
let k1 = of_hex1 c1 in
309+
let k2 = of_hex1 c2 in
310+
String.make 1 (Char.chr ((k1 lsl 4) lor k2))
311+
with Not_found -> failwith "decode"))
312312
s1
313313

314314
let make_encoded_parameters params =

src/baselib/ocsigen_lib.mli

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
include
2525
module type of Ocsigen_lib_base
26-
with type poly = Ocsigen_lib_base.poly
27-
and type yesnomaybe = Ocsigen_lib_base.yesnomaybe
28-
and type ('a, 'b) leftright = ('a, 'b) Ocsigen_lib_base.leftright
29-
and type 'a Clist.t = 'a Ocsigen_lib_base.Clist.t
30-
and type 'a Clist.node = 'a Ocsigen_lib_base.Clist.node
26+
with type poly = Ocsigen_lib_base.poly
27+
and type yesnomaybe = Ocsigen_lib_base.yesnomaybe
28+
and type ('a, 'b) leftright = ('a, 'b) Ocsigen_lib_base.leftright
29+
and type 'a Clist.t = 'a Ocsigen_lib_base.Clist.t
30+
and type 'a Clist.node = 'a Ocsigen_lib_base.Clist.node
3131

3232
val make_cryptographic_safe_string : unit -> string
3333
(** Generate an unique and cryptographically safe random string.
@@ -60,8 +60,8 @@ module Url : sig
6060
val make_encoded_parameters : (string * string) list -> string
6161
val string_of_url_path : encode:bool -> path -> uri
6262

63-
val parse
64-
: t
63+
val parse :
64+
t
6565
-> bool option
6666
* string option
6767
* int option

src/baselib/ocsigen_lib_base.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ end
220220

221221
module Int = struct
222222
module Table = Map.Make (struct
223-
type t = int
223+
type t = int
224224

225-
let compare = compare
226-
end)
225+
let compare = compare
226+
end)
227227
end
228228

229229
(*****************************************************************************)
@@ -312,8 +312,8 @@ module Url_base = struct
312312
(if https then "https://" else "http://")
313313
^ host
314314
^ (if (port = 80 && not https) || (https && port = 443)
315-
then ""
316-
else ":" ^ string_of_int port)
315+
then ""
316+
else ":" ^ string_of_int port)
317317
^ uri
318318

319319
let remove_dotdot =

src/baselib/ocsigen_loader.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ let findfiles =
158158
let deps =
159159
List.filter
160160
(fun a ->
161-
not @@ String.Set.mem a Ocsigen_config_static.builtin_packages)
161+
not @@ String.Set.mem a Ocsigen_config_static.builtin_packages)
162162
(Findlib.package_deep_ancestors preds [package])
163163
in
164164
Lwt_log.ign_info_f ~section "Dependencies of %s: %s" package

src/baselib/ocsigen_stream.ml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ let rec get_aux st =
5959
(Lwt.try_bind
6060
(fun () -> Lazy.force st.stream)
6161
(fun e ->
62-
Lwt.return
63-
(match e with
64-
| Cont (s, rem) ->
65-
st.stream <- rem;
66-
Cont (s, get_aux st)
67-
| _ -> e))
62+
Lwt.return
63+
(match e with
64+
| Cont (s, rem) ->
65+
st.stream <- rem;
66+
Cont (s, get_aux st)
67+
| _ -> e))
6868
(fun e ->
69-
st.stream <- lazy (Lwt.fail e);
70-
Lwt.fail (Interrupted e)))
69+
st.stream <- lazy (Lwt.fail e);
70+
Lwt.fail (Interrupted e)))
7171

7272
let get st =
7373
if st.in_use then raise Already_read;
@@ -141,7 +141,7 @@ let enlarge_stream = function
141141
else
142142
let long4 = long3 - max in
143143
cont (String.sub new_s 0 max) (fun () ->
144-
Lwt.return (Cont (String.sub new_s max long4, ff))))
144+
Lwt.return (Cont (String.sub new_s max long4, ff))))
145145

146146
let rec stream_want s len =
147147
(* returns a stream with at least len bytes read if possible *)
@@ -154,7 +154,7 @@ let rec stream_want s len =
154154
Lwt.catch
155155
(fun () -> enlarge_stream s >>= fun r -> Lwt.return (`OK r))
156156
(function
157-
| Stream_too_small -> Lwt.return `Too_small | e -> Lwt.fail e)
157+
| Stream_too_small -> Lwt.return `Too_small | e -> Lwt.fail e)
158158
>>= function
159159
| `OK r -> stream_want r len
160160
| `Too_small -> Lwt.return s)
@@ -191,17 +191,16 @@ let substream delim s =
191191
try
192192
let p, _ = Ocsigen_lib.Netstring_pcre.search_forward rdelim s 0 in
193193
cont (String.sub s 0 p) (fun () ->
194-
empty
195-
(Some
196-
(fun () ->
197-
Lwt.return (Cont (String.sub s p (len - p), f)))))
194+
empty
195+
(Some
196+
(fun () -> Lwt.return (Cont (String.sub s p (len - p), f)))))
198197
with Not_found ->
199198
let pos = len + 1 - ldelim in
200199
cont (String.sub s 0 pos) (fun () ->
201-
next f >>= function
202-
| Finished _ -> Lwt.fail Stream_too_small
203-
| Cont (s', f') ->
204-
aux (Cont (String.sub s pos (len - pos) ^ s', f'))))
200+
next f >>= function
201+
| Finished _ -> Lwt.fail Stream_too_small
202+
| Cont (s', f') ->
203+
aux (Cont (String.sub s pos (len - pos) ^ s', f'))))
205204
in
206205
aux s
207206

src/baselib/polytables/polytables.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
type 'a key = int * 'a option ref
2424

2525
module T = Map.Make (struct
26-
type t = int
26+
type t = int
2727

28-
let compare = compare
29-
end)
28+
let compare = compare
29+
end)
3030

3131
type t = (unit -> unit) T.t ref
3232

src/baselib/tests/test_wrapping.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type a = {a : float; a_wrap : a Ocsigen_wrap.wrapper}
77

88
let a_wrap () =
99
Ocsigen_wrap.create_wrapper (fun t ->
10-
{a = t.a +. 1.; a_wrap = Ocsigen_wrap.empty_wrapper})
10+
{a = t.a +. 1.; a_wrap = Ocsigen_wrap.empty_wrapper})
1111

1212
let a i = {a = i; a_wrap = a_wrap ()}
1313
let va = a 3.14
@@ -64,7 +64,7 @@ let ( -- ) x y =
6464
aux y x []
6565

6666
(*
67-
type l =
67+
type l =
6868
| A
6969
| L of l * int
7070
@@ -116,8 +116,8 @@ let i = ref 0
116116

117117
let mtoto () =
118118
Ocsigen_wrap.create_wrapper (fun t ->
119-
incr i;
120-
string_of_float t.a, !i)
119+
incr i;
120+
string_of_float t.a, !i)
121121

122122
let mt () = Ocsigen_wrap.create_wrapper (fun t -> incr i; t.v2)
123123
let toto i = {a = i; mtoto = mtoto ()}
@@ -140,13 +140,13 @@ let r3 = ref 88
140140

141141
let t1mark () =
142142
Ocsigen_wrap.create_wrapper (fun t ->
143-
incr r1;
144-
{t1a = 3.14; t1mark = Ocsigen_wrap.empty_wrapper})
143+
incr r1;
144+
{t1a = 3.14; t1mark = Ocsigen_wrap.empty_wrapper})
145145

146146
let t2mark () =
147147
Ocsigen_wrap.create_wrapper (fun t ->
148-
(match t.t2f with Some f -> f r2 | None -> assert false);
149-
{t with t2f = None; t2mark = Ocsigen_wrap.empty_wrapper})
148+
(match t.t2f with Some f -> f r2 | None -> assert false);
149+
{t with t2f = None; t2mark = Ocsigen_wrap.empty_wrapper})
150150

151151
let t1 = {t1a = 1.1; t1mark = t1mark ()}
152152
let t2 = {t2t1 = t1; t2f = Some (fun r -> incr r; incr r3); t2mark = t2mark ()}

0 commit comments

Comments
 (0)