Skip to content

Commit 5e90aed

Browse files
authored
Merge pull request #694 from ocsigen/to-eio
ocamlformat
2 parents cfa6f9a + 29566d9 commit 5e90aed

17 files changed

+4022
-3353
lines changed

.ocamlformat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
version=0.26.1
1+
version=0.28.1
2+
parse-docstrings = false
23
break-cases = fit
34
break-collection-expressions = fit-or-vertical
45
break-fun-decl = wrap

src/os_comet.eliom

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ let%client restart_process () =
4141
Eliom_client.exit_to ~absolute:false
4242
~service:(Eliom_service.static_dir ())
4343
["index.html"] ()
44-
else if (* If cookies do not work,
44+
else if
45+
(* If cookies do not work,
4546
the failed comet is probably due to missing cookies.
4647
In that case we do not restart. This happens for example
4748
if cookies are deactivated of if the app is running in an iframe
4849
and the browser forbids third party cookies. *)
49-
cookies_enabled ()
50+
cookies_enabled ()
5051
then Eliom_client.exit_to ~service:Eliom_service.reload_action () ()
5152

5253
let%client _ =

src/os_connect_phone.eliom

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*)
2020

2121
open%server Lwt.Syntax
22+
2223
type%shared sms_error_core = [`Unknown | `Send | `Limit | `Invalid_number]
2324
type%shared sms_error = [`Ownership | sms_error_core]
2425

@@ -100,8 +101,8 @@ let%server confirm_code myid code =
100101
let%rpc confirm_code_extra myid (code : string) : bool Lwt.t =
101102
confirm_code myid code
102103

103-
let%server confirm_code_signup_no_connect ~first_name ~last_name ~code ~password
104-
()
104+
let%server
105+
confirm_code_signup_no_connect ~first_name ~last_name ~code ~password ()
105106
=
106107
Lwt.bind (Eliom_reference.get activation_code_ref) (function
107108
| Some (number, code', _) when code = code' ->
@@ -114,8 +115,13 @@ let%server confirm_code_signup_no_connect ~first_name ~last_name ~code ~password
114115
Lwt.return_some userid
115116
| _ -> Lwt.return_none)
116117

117-
let%rpc confirm_code_signup ~(first_name : string) ~(last_name : string)
118-
~(code : string) ~(password : string) () : bool Lwt.t
118+
let%rpc
119+
confirm_code_signup
120+
~(first_name : string)
121+
~(last_name : string)
122+
~(code : string)
123+
~(password : string)
124+
() : bool Lwt.t
119125
=
120126
Lwt.bind
121127
(confirm_code_signup_no_connect ~first_name ~last_name ~code ~password ())
@@ -136,16 +142,16 @@ let%rpc confirm_code_recovery (code : string) : bool Lwt.t =
136142
| _ -> Lwt.return_false)
137143

138144
let%rpc connect ~(keepmeloggedin : bool) ~(password : string) (number : string)
139-
: [`Login_ok | `Wrong_password | `No_such_user | `Password_not_set] Lwt.t
145+
: [`Login_ok | `Wrong_password | `No_such_user | `Password_not_set] Lwt.t
140146
=
141147
Lwt.catch
142148
(fun () ->
143149
let* userid = Os_db.User.verify_password_phone ~password ~number in
144150
let* () = Os_session.connect ~expire:(not keepmeloggedin) userid in
145151
Lwt.return `Login_ok)
146152
(function
147-
| Os_db.Empty_password | Os_db.Wrong_password ->
148-
Lwt.return `Wrong_password
149-
| Os_db.No_such_user -> Lwt.return `No_such_user
150-
| Os_db.Password_not_set -> Lwt.return `Password_not_set
151-
| exc -> Lwt.reraise exc)
153+
| Os_db.Empty_password | Os_db.Wrong_password ->
154+
Lwt.return `Wrong_password
155+
| Os_db.No_such_user -> Lwt.return `No_such_user
156+
| Os_db.Password_not_set -> Lwt.return `Password_not_set
157+
| exc -> Lwt.reraise exc)

src/os_core_db.ml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,35 @@ let connect () =
6767
Lwt.catch
6868
(fun () -> init h)
6969
(fun exn ->
70-
let* () = dispose h in
71-
Lwt.fail exn)
70+
let* () = dispose h in
71+
Lwt.fail exn)
7272
in
7373
Lwt.return h
7474
| None -> Lwt.return h
7575

7676
let validate db =
7777
Lwt.catch
7878
(fun () ->
79-
let* () = Lwt_PGOCaml.ping db in
80-
Lwt.return_true)
79+
let* () = Lwt_PGOCaml.ping db in
80+
Lwt.return_true)
8181
(fun _ -> Lwt.return_false)
8282

8383
let pool : (string, bool) Hashtbl.t Lwt_PGOCaml.t Resource_pool.t ref =
8484
ref @@ Resource_pool.create 16 ~validate ~dispose connect
8585

8686
let set_pool_size n = pool := Resource_pool.create n ~validate ~dispose connect
8787

88-
let init ?host ?port ?user ?password ?database ?unix_domain_socket_dir
89-
?pool_size ?init () =
88+
let init
89+
?host
90+
?port
91+
?user
92+
?password
93+
?database
94+
?unix_domain_socket_dir
95+
?pool_size
96+
?init
97+
()
98+
=
9099
host_r := host;
91100
port_r := port;
92101
user_r := user;
@@ -98,11 +107,10 @@ let init ?host ?port ?user ?password ?database ?unix_domain_socket_dir
98107

99108
let connection_pool () = !pool
100109

101-
type wrapper = {
102-
f : 'a. PGOCaml.pa_pg_data PGOCaml.t -> (unit -> 'a Lwt.t) -> 'a Lwt.t;
103-
}
110+
type wrapper =
111+
{f : 'a. PGOCaml.pa_pg_data PGOCaml.t -> (unit -> 'a Lwt.t) -> 'a Lwt.t}
104112

105-
let connection_wrapper = ref { f = (fun _ f -> f ()) }
113+
let connection_wrapper = ref {f = (fun _ f -> f ())}
106114
let set_connection_wrapper f = connection_wrapper := f
107115

108116
let use_pool f =
@@ -128,10 +136,10 @@ let use_pool f =
128136
let transaction_block db f =
129137
Lwt.catch
130138
(fun () ->
131-
Lwt_PGOCaml.begin_work db >>= fun _ ->
132-
let* r = f () in
133-
let* () = Lwt_PGOCaml.commit db in
134-
Lwt.return r)
139+
Lwt_PGOCaml.begin_work db >>= fun _ ->
140+
let* r = f () in
141+
let* () = Lwt_PGOCaml.commit db in
142+
Lwt.return r)
135143
(function
136144
| (Lwt_PGOCaml.Error _ | Lwt.Canceled | Unix.Unix_error _ | End_of_file)
137145
as e ->

src/os_date.eliom

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ let%client timezone =
3131
(* Use Intl API if available. Revert to using the time zone offset
3232
otherwise. *)
3333
match
34-
if Js.Opt.test Js.Unsafe.global ##. Intl
35-
&& Js.Opt.test Js.Unsafe.global ##. Intl ##. DateTimeFormat
34+
if
35+
Js.Opt.test Js.Unsafe.global##.Intl
36+
&& Js.Opt.test Js.Unsafe.global##.Intl##.DateTimeFormat
3637
then
37-
let f = Js.Unsafe.global ##. Intl ## DateTimeFormat in
38+
let f = Js.Unsafe.global##.Intl##DateTimeFormat in
3839
if Js.Opt.test f##.resolvedOptions
3940
then
4041
let o = f##resolvedOptions in

0 commit comments

Comments
 (0)