Skip to content

Commit 4295058

Browse files
authored
Merge pull request #254 from Julow/unused-lwt-utils
Remove unused Lwt utils
2 parents e98212b + d4837ec commit 4295058

File tree

5 files changed

+7
-65
lines changed

5 files changed

+7
-65
lines changed

src/baselib/ocsigen_cache.ml

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@author Raphaël Proust (adding timers)
2323
*)
2424

25-
let ( >>= ) = Lwt.bind
25+
open Lwt.Infix
2626

2727
module Dlist : sig
2828
type 'a t
@@ -66,12 +66,6 @@ module Dlist : sig
6666
(** fold over the elements from the cache starting from the oldest
6767
to the newest *)
6868

69-
val lwt_fold : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.t
70-
(** lwt version of fold *)
71-
72-
val lwt_fold_back : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.t
73-
(** lwt version of fold_back *)
74-
7569
val move : 'a node -> 'a t -> 'a option
7670
(** Move a node from one dlist to another one, without finalizing.
7771
If one value is removed from the destination list (because its
@@ -322,34 +316,6 @@ end = struct
322316
(match node.mylist with None -> () | Some l -> remove' node l);
323317
match add_node node l with None -> None | Some v -> remove v; Some v.value
324318

325-
(* fold over the elements from the newest to the oldest *)
326-
let lwt_fold f accu {newest; _} =
327-
match newest with
328-
| None -> Lwt.return accu
329-
| Some newest ->
330-
let rec fold accu node =
331-
f accu node.value >>= fun accu ->
332-
match node.prev with
333-
| None -> Lwt.return accu
334-
| Some new_node when new_node == newest -> Lwt.return accu
335-
| Some new_node -> fold accu new_node
336-
in
337-
fold accu newest
338-
339-
(* fold over the elements from the oldest to the newest *)
340-
let lwt_fold_back f accu {oldest; _} =
341-
match oldest with
342-
| None -> Lwt.return accu
343-
| Some oldest ->
344-
let rec fold accu node =
345-
f accu node.value >>= fun accu ->
346-
match node.succ with
347-
| None -> Lwt.return accu
348-
| Some new_node when new_node == oldest -> Lwt.return accu
349-
| Some new_node -> fold accu new_node
350-
in
351-
fold accu oldest
352-
353319
(* fold over the elements from the newest to the oldest *)
354320
let fold f accu {newest; _} =
355321
match newest with

src/baselib/ocsigen_cache.mli

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ module Dlist : sig
125125
(** fold over the elements from the cache starting from the oldest
126126
to the newest *)
127127

128-
val lwt_fold : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.t
129-
(** lwt version of fold *)
130-
131-
val lwt_fold_back : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.t
132-
(** lwt version of fold_back *)
133-
134128
val move : 'a node -> 'a t -> 'a option
135129
(** Move a node from one dlist to another one, without finalizing.
136130
If one value is removed from the destination list (because its

src/baselib/ocsigen_lib_base.ml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ exception Ocsigen_Request_too_long
2323

2424
external id : 'a -> 'a = "%identity"
2525

26-
let ( >>= ) = Lwt.bind
27-
let ( >|= ) = Lwt.( >|= )
26+
include Lwt.Infix
27+
2828
let ( !! ) = Lazy.force
2929
let ( |> ) x f = f x
3030
let ( @@ ) f x = f x
@@ -62,17 +62,6 @@ module Option = struct
6262
let return x = Some x
6363
let bind opt k = match opt with Some x -> k x | None -> None
6464
let to_list = function None -> [] | Some v -> [v]
65-
66-
module Lwt = struct
67-
let map f = function
68-
| Some x -> f x >>= fun v -> Lwt.return (Some v)
69-
| None -> Lwt.return None
70-
71-
let get f = function Some x -> Lwt.return x | None -> f ()
72-
let get' a = function Some x -> Lwt.return x | None -> a
73-
let iter f = function Some x -> f x | None -> Lwt.return ()
74-
let bind opt k = match opt with Some x -> k x | None -> Lwt.return None
75-
end
7665
end
7766

7867
module List = struct

src/baselib/ocsigen_lib_base.mli

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ exception Input_is_too_large
2626
exception Ocsigen_Bad_Request
2727
exception Ocsigen_Request_too_long
2828

29-
val ( >>= ) : 'a Lwt.t -> ('a -> 'b Lwt.t) -> 'b Lwt.t
30-
val ( >|= ) : 'a Lwt.t -> ('a -> 'b) -> 'b Lwt.t
29+
include module type of Lwt.Infix
30+
3131
val ( !! ) : 'a Lazy.t -> 'a
3232
val ( |> ) : 'a -> ('a -> 'b) -> 'b
3333
val ( @@ ) : ('a -> 'b) -> 'a -> 'b
@@ -63,14 +63,6 @@ module Option : sig
6363
val return : 'a -> 'a t
6464
val bind : 'a t -> ('a -> 'b t) -> 'b t
6565
val to_list : 'a t -> 'a list
66-
67-
module Lwt : sig
68-
val map : ('a -> 'b Lwt.t) -> 'a t -> 'b t Lwt.t
69-
val get : (unit -> 'a Lwt.t) -> 'a t -> 'a Lwt.t
70-
val get' : 'a Lwt.t -> 'a t -> 'a Lwt.t
71-
val iter : ('a -> unit Lwt.t) -> 'a t -> unit Lwt.t
72-
val bind : 'a t -> ('a -> 'b t Lwt.t) -> 'b t Lwt.t
73-
end
7466
end
7567

7668
(** Improvement of module List *)

src/server/ocsigen_messages.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
(** Writing messages in the logs *)
2020

21-
let ( >>= ) = Lwt.bind
21+
open Lwt.Infix
22+
2223
let access_file = "access.log"
2324
let warning_file = "warnings.log"
2425
let error_file = "errors.log"

0 commit comments

Comments
 (0)