File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -283,22 +283,16 @@ let unfold_lwt f u () =
283283 | None -> return_nil
284284 | Some (x , u' ) -> Lwt. return (Cons (x, unfold_lwt f u'))
285285
286- let rec of_list = function
287- | [] -> empty
288- | h :: t -> cons h (of_list t)
289-
290- let rec to_list seq =
291- seq () >> = function
292- | Nil -> Lwt. return_nil
293- | Cons (x , next ) ->
294- let + l = to_list next in
295- x :: l
296- let to_list seq =
297- Lwt. apply seq () >> = function
298- | Nil -> Lwt. return_nil
299- | Cons (x , next ) ->
300- let + l = to_list next in
301- x :: l
286+ let rec of_list l () =
287+ Lwt. return (match l with [] -> Nil | h :: t -> Cons (h, of_list t))
288+
289+ let to_list (seq : 'a t ) =
290+ let rec aux f seq =
291+ Lwt. bind (seq () ) (function
292+ | Nil -> Lwt. return (f [] )
293+ | Cons (h , t ) -> aux (fun x -> f (h :: x)) t)
294+ in
295+ aux (fun x -> x) (Lwt. apply seq)
302296
303297let rec of_seq seq () =
304298 match seq () with
You can’t perform that action at this time.
0 commit comments