Skip to content

Commit 31792a0

Browse files
authored
Merge pull request #666 from ocsigen/format
Upgrading ocamlformat version (both os and template)
2 parents 24b470b + fe251fa commit 31792a0

40 files changed

+624
-618
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/os_comet.eliom

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
open%client Js_of_ocaml
2222
open%client Js_of_ocaml_lwt
23+
2324
let%shared __link = () (* to make sure os_comet is linked *)
2425

2526
let%client cookies_enabled () =
@@ -49,7 +50,7 @@ let%client restart_process () =
4950

5051
let%client _ =
5152
Eliom_comet.set_handle_exn_function (fun ?exn:_ () ->
52-
restart_process (); Lwt.return_unit)
53+
restart_process (); Lwt.return_unit)
5354

5455
(* We create a channel on scope user_indep_process_scope,
5556
to monitor the application.
@@ -74,7 +75,7 @@ let create_monitor_channel () =
7475
(so that it is not garbage collected).
7576
It is garbage collected when this client process state is closed
7677
after timeout.
77-
*)
78+
*)
7879
let monitor_channel_ref =
7980
Eliom_reference.Volatile.eref ~scope:Os_session.user_indep_process_scope None
8081

@@ -83,10 +84,9 @@ let already_send_ref =
8384

8485
let%client handle_error =
8586
ref (fun exn ->
86-
Eliom_lib.debug_exn "Exception received on Os_comet's monitor channel: "
87-
exn;
88-
restart_process ();
89-
Lwt.return_unit)
87+
Eliom_lib.debug_exn "Exception received on Os_comet's monitor channel: " exn;
88+
restart_process ();
89+
Lwt.return_unit)
9090

9191
let%client set_error_handler f = handle_error := f
9292

@@ -109,15 +109,15 @@ let%server _ =
109109

110110
let%server _ =
111111
Os_session.on_start_process (fun _ ->
112-
let channel = create_monitor_channel () in
113-
Eliom_reference.Volatile.set monitor_channel_ref (Some channel);
114-
ignore
115-
[%client
116-
(Lwt.async (fun () ->
117-
Lwt_stream.iter_s handle_message
118-
(Lwt_stream.wrap_exn ~%(fst channel)))
119-
: unit)];
120-
Lwt.return_unit);
112+
let channel = create_monitor_channel () in
113+
Eliom_reference.Volatile.set monitor_channel_ref (Some channel);
114+
ignore
115+
[%client
116+
(Lwt.async (fun () ->
117+
Lwt_stream.iter_s handle_message
118+
(Lwt_stream.wrap_exn ~%(fst channel)))
119+
: unit)];
120+
Lwt.return_unit);
121121
let warn c =
122122
(* User connected or disconnected.
123123
I want to send the message on all tabs of the browser: *)
@@ -129,9 +129,9 @@ let%server _ =
129129
~state:
130130
(Eliom_state.Ext.current_volatile_data_state
131131
~scope:Os_session.user_indep_session_scope ()) (fun state ->
132-
match Eliom_reference.Volatile.Ext.get state monitor_channel_ref with
133-
| Some (_, send) as v -> if not (v == cur) then send c
134-
| None -> ()));
132+
match Eliom_reference.Volatile.Ext.get state monitor_channel_ref with
133+
| Some (_, send) as v -> if not (v == cur) then send c
134+
| None -> ()));
135135
Lwt.return_unit
136136
in
137137
let warn_connection_change _ = warn Connection_changed in

src/os_connect_phone.eliom

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ let%server confirm_code_signup_no_connect ~first_name ~last_name ~code ~password
112112
| _ -> Lwt.return_none
113113

114114
let%rpc confirm_code_signup ~(first_name : string) ~(last_name : string)
115-
~(code : string) ~(password : string) ()
116-
: bool Lwt.t
115+
~(code : string) ~(password : string) () : bool Lwt.t
117116
=
118117
match%lwt
119118
confirm_code_signup_no_connect ~first_name ~last_name ~code ~password ()

src/os_connect_phone.eliomi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ type sms_error_core = [`Unknown | `Send | `Limit | `Invalid_number]
2525

2626
[%%server.start]
2727

28-
val set_send_sms_handler
29-
: (number:string -> string -> (unit, sms_error_core) result Lwt.t)
28+
val set_send_sms_handler :
29+
(number:string -> string -> (unit, sms_error_core) result Lwt.t)
3030
-> unit
3131
(** [set_send_sms_handler f] registers [f] as the function to be
3232
called to send SMS messages. Used to send activation codes for
3333
connectivity by mail. *)
3434

35-
val confirm_code_signup_no_connect
36-
: first_name:string
35+
val confirm_code_signup_no_connect :
36+
first_name:string
3737
-> last_name:string
3838
-> code:string
3939
-> password:string
@@ -60,8 +60,8 @@ val confirm_code_extra : string -> bool Lwt.t
6060
(** Confirm validation code and add extra phone to account of the currently
6161
connected user*)
6262

63-
val confirm_code_signup
64-
: first_name:string
63+
val confirm_code_signup :
64+
first_name:string
6565
-> last_name:string
6666
-> code:string
6767
-> password:string
@@ -74,8 +74,8 @@ val confirm_code_recovery : string -> bool Lwt.t
7474
(** Confirm validation code and recover account. We redirect to the
7575
settings page for setting a new password. *)
7676

77-
val connect
78-
: keepmeloggedin:bool
77+
val connect :
78+
keepmeloggedin:bool
7979
-> password:string
8080
-> string
8181
-> [`Login_ok | `No_such_user | `Wrong_password | `Password_not_set] Lwt.t

src/os_current_user.eliom

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ let%server unset_user_client () =
101101

102102
let%server () =
103103
Os_session.on_request (fun myid_o ->
104-
match myid_o with
105-
| Some myid -> set_user_server myid
106-
| None -> unset_user_server (); Lwt.return_unit);
104+
match myid_o with
105+
| Some myid -> set_user_server myid
106+
| None -> unset_user_server (); Lwt.return_unit);
107107
Os_session.on_start_connected_process (fun myid ->
108-
let%lwt () = set_user_server myid in
109-
set_user_client (); Lwt.return_unit);
108+
let%lwt () = set_user_server myid in
109+
set_user_client (); Lwt.return_unit);
110110
Os_session.on_pre_close_session (fun () ->
111-
unset_user_client ();
112-
(*VVV!!! will affect only current tab!! *)
113-
unset_user_server ();
114-
(* ok this is a request reference *)
115-
Lwt.return_unit)
111+
unset_user_client ();
112+
(*VVV!!! will affect only current tab!! *)
113+
unset_user_server ();
114+
(* ok this is a request reference *)
115+
Lwt.return_unit)
116116

117117
let%rpc remove_email_from_user (email : string) : unit Lwt.t =
118118
let myid = get_current_userid () in

src/os_date.eliom

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ let user_tz_opt () =
6464
else tz
6565

6666
let user_tz () = match user_tz_opt () with None -> "UTC" | Some v -> v
67-
6867
let%client user_tz () = timezone
6968

7069
(* This function is called once by each client process to record on server
@@ -84,7 +83,7 @@ let%client disable_auto_init () = auto_init := false
8483
let%client _ =
8584
(* We wait for the client process to be fully loaded: *)
8685
Eliom_client.onload (fun () ->
87-
if !auto_init then Lwt.async (fun () -> init_time_rpc timezone))
86+
if !auto_init then Lwt.async (fun () -> init_time_rpc timezone))
8887

8988
[%%shared
9089
open CalendarLib
@@ -152,8 +151,8 @@ let%client to_utc d =
152151
let o' = (new%js Js.date_fromTimeValue (d' *. 1000.))##getTimezoneOffset in
153152
CalendarLib.Calendar.from_unixfloat
154153
(if o = o'
155-
then d' (* We guessed the DST status right *)
156-
else d +. (float o' *. 60.))
154+
then d' (* We guessed the DST status right *)
155+
else d +. (float o' *. 60.))
157156
(* Assume other DST status *)
158157

159158
let%server now ?timezone () = to_local ?timezone (CalendarLib.Calendar.now ())

src/os_date.eliomi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ val smart_hours_minutes : local_calendar -> string
118118
If the timezone is unknown, GMT is added.
119119
*)
120120

121-
val smart_interval
122-
: ?now:local_calendar
121+
val smart_interval :
122+
?now:local_calendar
123123
-> local_calendar
124124
-> local_calendar
125125
-> string
@@ -138,8 +138,8 @@ val smart_interval
138138
year is needed and ["%B %d"] if not.
139139
*)
140140

141-
val smart_date_interval
142-
: ?now:local_calendar
141+
val smart_date_interval :
142+
?now:local_calendar
143143
-> local_calendar
144144
-> local_calendar
145145
-> string

src/os_email.eliomi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ val is_valid : string -> bool
4545
(** [is_valid email] returns [true] if the e-mail address [email] is valid. Else
4646
it returns [false]. *)
4747

48-
val send
49-
: ?url:string
48+
val send :
49+
?url:string
5050
-> ?from_addr:string * string
5151
-> to_addrs:(string * string) list
5252
-> subject:string
@@ -58,13 +58,13 @@ val send
5858
Tuples used by [from_addr] and [to_addrs] is of the form [(name, email)].
5959
*)
6060

61-
val set_send
62-
: (?url:string
63-
-> from_addr:string * string
64-
-> to_addrs:(string * string) list
65-
-> subject:string
66-
-> string list
67-
-> unit Lwt.t)
61+
val set_send :
62+
(?url:string
63+
-> from_addr:string * string
64+
-> to_addrs:(string * string) list
65+
-> subject:string
66+
-> string list
67+
-> unit Lwt.t)
6868
-> unit
6969
(** Customize email sending function. See {!send} for more details about the
7070
arguments.

src/os_fcm_notif.eliom

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ module Response = struct
193193
module Results = struct
194194
(* If an error occurred, one of these sum types is returned (based on the
195195
couple (code, error_as_string), see [error_of_string_and_code].
196-
*)
196+
*)
197197
type error =
198198
| Missing_registration
199199
| Invalid_registration
@@ -214,7 +214,7 @@ module Response = struct
214214
(* Internal use. See
215215
https://developers.google.com/cloud-messaging/http-server-ref
216216
table 9
217-
*)
217+
*)
218218
let error_of_string_and_code = function
219219
| 200, "MissingRegistration" -> Missing_registration
220220
| 200, "InvalidRegistration" -> Invalid_registration
@@ -253,7 +253,7 @@ module Response = struct
253253

254254
(* If no error occurred, the JSON in the results attribute contains a
255255
mandatory field message_id and an optional field registration_id.
256-
*)
256+
*)
257257
type success = {message_id : string; registration_id : string option}
258258

259259
let message_id_of_success success = success.message_id
@@ -266,7 +266,7 @@ module Response = struct
266266
match Util.member "message_id" json with
267267
(* If the field [message_id] is present, we are in the case of a
268268
successful message
269-
*)
269+
*)
270270
| `String x ->
271271
let message_id = x in
272272
let registration_id =
@@ -279,12 +279,12 @@ module Response = struct
279279
case of an error message.
280280
The pattern _ is used because is equivalent to `Null in this
281281
case due to the predefined type of the message_id (string).
282-
*)
282+
*)
283283
| _ -> (
284284
match Util.member "error" json with
285285
(* If the field [error] is present, we are in the case of an
286286
error message.
287-
*)
287+
*)
288288
| `String err -> Error (error_of_string_and_code (code, err))
289289
(* Else we don't know what is the result. *)
290290
| _ -> raise (FCM_missing_field "No message_id and error fields found.")
@@ -307,7 +307,7 @@ module Response = struct
307307
the max integer. The first pattern is `Int x is x is smaller
308308
than the max integer and the second is `String if x can't be
309309
interpreted as an integer.
310-
*)
310+
*)
311311
let multicast_id =
312312
match Util.member "multicast_id" json with
313313
| `Int x -> string_of_int x
@@ -331,7 +331,7 @@ module Response = struct
331331
in
332332
(* As results is an options array, we don't fail if it's not present but
333333
we use an empty list.
334-
*)
334+
*)
335335
let results =
336336
match Util.member "results" json with
337337
| `List l -> List.map (Results.t_of_json code) l
@@ -342,7 +342,7 @@ module Response = struct
342342
(* Build a type t from the raw HTTP response. The HTTP response code is
343343
computed to pass it to [t_of_json] and to [results_of_json] to be used
344344
if an error occurred.
345-
*)
345+
*)
346346
let t_of_http_response (r, b) =
347347
try%lwt
348348
let status = Cohttp.(Code.code_of_status (Response.status r)) in
@@ -352,7 +352,7 @@ module Response = struct
352352
with
353353
(* Could be the case if the server key is wrong or if it's not
354354
registered only in FCM and not in FCM (since September 2016).
355-
*)
355+
*)
356356
| Yojson.Json_error _ ->
357357
Lwt.fail (FCM_no_json_response "It could come from your server key.")
358358

src/os_fcm_notif.eliomi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ module Response : sig
448448
(** [results_of_t response] returns the status of the messages processed. *)
449449
end
450450

451-
val send
452-
: string
451+
val send :
452+
string
453453
-> Notification.t
454454
-> ?data:Data.t
455455
-> Options.t

0 commit comments

Comments
 (0)