Skip to content

Commit 5d961a9

Browse files
committed
Automatic changes done with ciao-lwt
1 parent a05c785 commit 5d961a9

13 files changed

+57
-60
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_calendar.eliomi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ type button_labels =
4141

4242
val make :
4343
?init:int * int * int
44-
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
44+
-> ?highlight:(int -> int -> int list) Eliom_client_value.t
4545
-> ?click_non_highlighted:bool
4646
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
47-
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
47+
-> ?action:(int -> int -> int -> unit) Eliom_client_value.t
4848
-> ?period:
4949
CalendarLib.Date.field CalendarLib.Date.date
5050
* 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_carousel.eliomi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ val make_lazy :
148148
-> Html_types.div_attrib Eliom_content.Html.D.attrib list)
149149
Eliom_shared.Value.t
150150
-> ?spinner:(unit -> Html_types.div_content Eliom_content.Html.elt)
151-
-> (unit -> [< Html_types.div_content] Eliom_content.Html.elt Lwt.t)
151+
-> (unit -> [< Html_types.div_content] Eliom_content.Html.elt)
152152
Eliom_shared.Value.t
153153
list
154-
-> [> `Div] t Lwt.t
154+
-> [> `Div] t
155155
(** same as [make] except for the last argument. Instead of supplying the
156156
contents for each page directly, supply a for each page a shared content
157157
generator function. Contents will be generated and filled lazily, i.e. when

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_picture_uploader.eliomi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ open Js_of_ocaml
3333
type cropping = (float * float * float * float) React.S.t
3434

3535
type 'a upload =
36-
?progress:(int -> int -> unit)
37-
-> ?cropping:cropping
38-
-> File.file Js.t
39-
-> 'a Lwt.t
36+
?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a
4037

4138
type ('a, 'b) service =
4239
( unit
@@ -142,7 +139,7 @@ val submit :
142139
(** Create a button with [ot-pup-sumit] clas *)
143140

144141
val mk_form :
145-
?after_submit:(unit -> unit Lwt.t)
142+
?after_submit:(unit -> unit)
146143
-> ?crop:float option
147144
-> ?input:
148145
[< Html_types.label_attrib > `Class] Eliom_content.Html.attrib list
@@ -151,7 +148,7 @@ val mk_form :
151148
[< Html_types.button_attrib > `Class] Eliom_content.Html.attrib list
152149
* [< Html_types.button_content_fun] Eliom_content.Html.elt list
153150
-> 'a upload
154-
-> [> `Form] Eliom_content.Html.elt Lwt.t
151+
-> [> `Form] Eliom_content.Html.elt
155152
(** Ready-to-use form. Customizable with
156153
[input], the input button content, [submit], the submit button content.
157154
If [crop] is present, cropping is enable, with the optional ratio it is.

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_pulltorefresh.eliomi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ val make :
2525
list)
2626
Eliom_shared.Value.t
2727
-> content:'a Eliom_content.Html.elt
28-
-> (unit -> bool Lwt.t) Eliom_client_value.t
28+
-> (unit -> bool) Eliom_client_value.t
2929
-> 'a Eliom_content.Html.elt
3030
(**
3131
Creates a pull-to-refresh container from an html element.

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

0 commit comments

Comments
 (0)