Skip to content

Commit 2b298c9

Browse files
committed
Automatic changes done with ciao-lwt
1 parent a05c785 commit 2b298c9

File tree

7 files changed

+42
-44
lines changed

7 files changed

+42
-44
lines changed

src/widgets/ot_calendar.eliom

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ let make :
561561

562562
let%server make :
563563
?init:int * int * int
564-
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
564+
-> ?highlight:(int -> int -> int list) Eliom_client_value.t
565565
-> ?click_non_highlighted:bool
566566
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
567-
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
567+
-> ?action:(int -> int -> int -> unit) Eliom_client_value.t
568568
-> ?period:
569569
CalendarLib.Date.field CalendarLib.Date.date
570570
* CalendarLib.Date.field CalendarLib.Date.date

src/widgets/ot_carousel.eliom

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open Eio.Std
2+
13
(* Ocsigen
24
* http://www.ocsigen.org
35
*
@@ -39,7 +41,7 @@ open%client Js_of_ocaml
3941
[%%client open Js_of_ocaml_lwt]
4042
[%%shared open Eliom_content.Html]
4143
[%%shared open Eliom_content.Html.F]
42-
[%%shared open Lwt.Syntax]
44+
[%%shared]
4345

4446
let%client clX = Ot_swipe.clX
4547
let%client clY = Ot_swipe.clY
@@ -587,9 +589,7 @@ let%client set_default_fail f =
587589
:> exn -> Html_types.div_content Eliom_content.Html.elt)
588590

589591
let%shared generate_content generator =
590-
Lwt.catch
591-
(fun () -> Eliom_shared.Value.local generator ())
592-
(fun e -> Lwt.return (default_fail e))
592+
try Eliom_shared.Value.local generator () with e -> default_fail e
593593

594594
(* on the client side we generate the contents of the initially visible page
595595
asynchronously so the tabs will be rendered right away *)
@@ -606,8 +606,8 @@ let%client generate_initial_contents ~spinner sleeper gen =
606606

607607
(* on the server side we generate all the visible contents right away *)
608608
let%server generate_initial_contents ~spinner:_ _ gen =
609-
let* contents = generate_content gen in
610-
Lwt.return (contents, ref @@ None)
609+
let contents = generate_content gen in
610+
contents, ref @@ None
611611

612612
let%shared
613613
make_lazy
@@ -628,30 +628,30 @@ let%shared
628628
=
629629
let gen_contents =
630630
(gen_contents
631-
:> (unit -> Html_types.div_content elt Lwt.t) Eliom_shared.Value.t list)
631+
:> (unit -> Html_types.div_content elt) Eliom_shared.Value.t list)
632+
in
633+
let sleeper, wakener =
634+
Promise.create
635+
(* TODO: ciao-lwt: Translation is incomplete, [Promise.await] must be called on the promise when it's part of control-flow. *)
636+
()
632637
in
633-
let sleeper, wakener = Lwt.wait () in
634-
let mk_contents : int -> 'gen -> ('a elt * ('a elt * 'gen) option ref) Lwt.t =
638+
let mk_contents : int -> 'gen -> 'a elt * ('a elt * 'gen) option ref =
635639
fun i gen ->
636640
if i = position
637641
then generate_initial_contents ~spinner sleeper gen
638642
else
639-
Lwt.return
640-
@@
641643
let s = spinner () in
642644
s, ref @@ Some (s, gen)
643645
in
644-
let* contents, spinners_and_generators =
645-
Lwt.map List.split
646-
@@ Lwt_list.map_s (fun x -> x)
647-
@@ List.mapi mk_contents gen_contents
646+
let contents, spinners_and_generators =
647+
List.split (List.map (fun x -> x) (List.mapi mk_contents gen_contents))
648648
in
649649
let carousel =
650650
make ?a ?vertical ~position ?transition_duration ?inertia ?swipeable
651651
?allow_overswipe ?update ?disabled ?full_height ?make_transform
652652
?make_page_attribute contents
653653
in
654-
Lwt.wakeup wakener carousel.elt;
654+
Promise.resolve wakener carousel.elt;
655655
(* generate initial content (client-side) *)
656656
(* replace spinners with content when switched to for the first time *)
657657
let _ =
@@ -677,7 +677,7 @@ let%shared
677677
| None -> Lwt.return ())
678678
: unit)]
679679
in
680-
Lwt.return carousel
680+
carousel
681681

682682
let%shared bullet_class i pos size =
683683
Eliom_shared.React.S.l2

src/widgets/ot_drawer.eliom

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open Eio.Std
2+
13
[%%shared
24
(* Ocsigen
35
* http://www.ocsigen.org
@@ -113,11 +115,11 @@ let%shared
113115
D.div ~a:(a_class ("ot-drawer-bckgrnd" :: bckgrnd_init_class) :: a) [d]
114116
in
115117
let bind_touch :
116-
((unit -> unit) Lwt.t * (unit -> unit) Lwt.u) Eliom_client_value.t
118+
((unit -> unit) Promise.t * (unit -> unit) Lwt.u) Eliom_client_value.t
117119
=
118120
[%client Lwt.wait ()]
119121
in
120-
let touch_thread = [%client (ref Lwt.return_unit : unit Lwt.t ref)] in
122+
let touch_thread = [%client (ref Lwt.return_unit : unit Promise.t ref)] in
121123
let reset_scroll_pos =
122124
[%client
123125
(fun () ->
@@ -179,7 +181,7 @@ let%shared
179181
html_ManipClass_remove "ot-drawer-open";
180182
html_ManipClass_remove "ot-drawer-closing");
181183
Lwt.return_unit
182-
: unit Lwt.t)]
184+
: unit Promise.t)]
183185
in
184186
let _ =
185187
[%client

src/widgets/ot_picture_uploader.eliom

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,7 @@ let%client bind_input input preview ?container ?reset () =
446446
type cropping = (float * float * float * float) React.S.t
447447

448448
type 'a upload =
449-
?progress:(int -> int -> unit)
450-
-> ?cropping:cropping
451-
-> File.file Js.t
452-
-> 'a Lwt.t]
449+
?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a]
453450

454451
let%client ocaml_service_upload ~service ~arg ?progress ?cropping file =
455452
Eliom_client.call_ocaml_service ~service () ?upload_progress:progress
@@ -499,7 +496,7 @@ let%server mk_service name arg_deriver =
499496

500497
let%shared
501498
mk_form
502-
?(after_submit = fun () -> Lwt.return_unit)
499+
?(after_submit = fun () -> ())
503500
?crop
504501
?input:(input_a, input_content = [], [])
505502
?submit:(submit_a, submit_content = [], [])
@@ -532,4 +529,4 @@ let%shared
532529
~upload:~%upload ~after_submit:~%after_submit ()
533530
: unit)]
534531
in
535-
Lwt.return form
532+
form

src/widgets/ot_pulltorefresh.eliom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ let make
175175
?(refresh_timeout = 20.)
176176
?(header = [%shared default_header])
177177
~content
178-
(afterPull : (unit -> bool Lwt.t) Eliom_client_value.t)
178+
(afterPull : (unit -> bool) Eliom_client_value.t)
179179
=
180180
if app_only && not (Eliom_client.is_client_app ())
181181
then div ~a [content]

src/widgets/ot_spinner.eliom

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
open%client Js_of_ocaml
2323

2424
[%%shared open Eliom_content.Html]
25-
[%%shared open Lwt.Syntax]
25+
[%%shared]
2626
[%%shared open Eliom_content.Html.F]
2727
[%%client open Eliom_shared]
2828

@@ -58,20 +58,19 @@ let%server with_spinner ?(a = []) ?spinner:_ ?fail thread =
5858
let a = (a :> Html_types.div_attrib attrib list) in
5959
let fail =
6060
((match fail with
61-
| Some fail -> (fail :> exn -> Html_types.div_content elt list Lwt.t)
62-
| None -> fun e -> Lwt.return (default_fail e))
63-
:> exn -> Html_types.div_content elt list Lwt.t)
61+
| Some fail -> (fail :> exn -> Html_types.div_content elt list)
62+
| None -> fun e -> default_fail e)
63+
:> exn -> Html_types.div_content elt list)
6464
in
65-
let* v =
66-
Lwt.catch
67-
(fun () ->
68-
let* v = thread in
69-
Lwt.return (v :> Html_types.div_content_fun F.elt list))
70-
(fun e ->
71-
let* v = fail e in
72-
Lwt.return (v :> Html_types.div_content_fun F.elt list))
65+
let v =
66+
try
67+
let v = thread in
68+
(v :> Html_types.div_content_fun F.elt list)
69+
with e ->
70+
let v = fail e in
71+
(v :> Html_types.div_content_fun F.elt list)
7372
in
74-
Lwt.return (D.div ~a:(a_class ["ot-spinner"] :: a) v)
73+
D.div ~a:(a_class ["ot-spinner"] :: a) v
7574

7675
[%%client
7776
let num_active_spinners, set_num_active_spinners = React.S.create 0

src/widgets/ot_time_picker.eliom

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ let display_hours_minutes_seq ?h24 f =
381381
Eliom_shared.React.S.l2 [%shared display_hours_minutes_seq ?h24:~%h24 ~%f]
382382

383383
let show_minutes_aux
384-
?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option)
384+
?(action : (int * int -> unit) Eliom_client_value.t option)
385385
e_m
386386
hm
387387
f_e_m
@@ -407,7 +407,7 @@ let get_angle_signal ?round =
407407
| _, _ -> e]
408408

409409
let make_hours_minutes_seq_24h
410-
?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option)
410+
?(action : (int * int -> unit) Eliom_client_value.t option)
411411
?(init = 0, 0)
412412
?(update : (int * int) React.E.t Eliom_client_value.t option)
413413
?round_5

0 commit comments

Comments
 (0)