diff --git a/src/core/lwt_seq.ml b/src/core/lwt_seq.ml index 1f8807bfc..f28973b4a 100644 --- a/src/core/lwt_seq.ml +++ b/src/core/lwt_seq.ml @@ -282,20 +282,24 @@ let to_list seq = x :: l let rec of_seq seq = - try - match seq () with - | Seq.Nil -> empty - | Seq.Cons (x, next) -> - cons x (of_seq next) - with exn -> - fun () -> raise exn + match seq () with + | Seq.Nil -> empty + | Seq.Cons (x, next) -> + cons x (of_seq next) + | exception exn -> Lwt.fail exn let rec of_seq_lwt (seq: 'a Lwt.t Seq.t): 'a t Lwt.t = match seq () with | Seq.Nil -> Lwt.return empty | Seq.Cons (x, next) -> - Lwt.catch (fun () -> - let* x = x in - let+ next = of_seq_lwt next in - cons x next) - (fun exc -> Lwt.return (fun () -> raise exc)) + let* x = x in + let+ next = of_seq_lwt next in + cons x next +let of_seq_lwt (seq: 'a Lwt.t Seq.t): 'a t Lwt.t = + match seq () with + | Seq.Nil -> Lwt.return empty + | Seq.Cons (x, next) -> + let* x = x in + let+ next = of_seq_lwt next in + cons x next + | exception exc -> Lwt.fail exc