let while_sequential:
'a list -> f:('a -> ('c, 'b) t) -> ('c list, 'b) t
= fun (type b) (l: 'a list) ~(f: 'a -> ('c, b) t) ->
let module Map_sequential = struct
exception Local_exception of b
let ms l f =
wrap_deferred
(fun () ->
Lwt_list.map_s (fun o ->
Lwt.bind (f o) (function
| `Ok oo -> Lwt.return oo
| `Error ee -> Lwt.fail (Local_exception ee))) l)
~on_exn:(function
| Local_exception e -> e
| e ->
ksprintf failwith "Expecting only Local_exception, but got: %s"
(Printexc.to_string e) ())
end in
Map_sequential.ms l f