Skip to content

Commit

Permalink
Cleanup Lwt_seq.to_seq implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko committed Jan 25, 2021
1 parent cb39979 commit 13e6b67
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/core/lwt_seq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,13 @@ let rec of_seq seq =

let rec to_seq seq =
Lwt.catch
(fun () ->
seq () >|= fun x ->
`Result x )
(fun () -> seq () >>= Lwt.return_ok)
(fun exn ->
Lwt.return (`Exn exn)
Lwt.return_error exn
) >>= function
| `Result Nil -> Lwt.return Seq.empty
| `Result (Cons (x, next)) ->
| Ok Nil -> Lwt.return Seq.empty
| Ok (Cons (x, next)) ->
let+ next = to_seq next in
fun () -> Seq.Cons (x, next)
| `Exn exn ->
| Error exn ->
Lwt.return (fun () -> raise exn)

0 comments on commit 13e6b67

Please sign in to comment.