let for_concurrent:
'a list -> f:('a -> ('c, 'b) t) -> ('c list * 'b list, 'd) t
= fun l ~f ->
let oks = ref [] in
let errors = ref [] in
Lwt.(
Lwt_list.map_p (fun elt ->
f elt >>= function
| `Ok o -> oks := o :: !oks; return ()
| `Error e -> errors := e :: !errors; return ()) l
>>= fun _ ->
return (`Ok ())
)
>>= fun () ->
return (List.rev !oks, List.rev !errors)