diff --git a/src/fut.ml b/src/fut.ml index 0661ffa2..727f9566 100644 --- a/src/fut.ml +++ b/src/fut.ml @@ -330,6 +330,8 @@ let join_list (l : _ t list) : _ list t = | [ x ] -> map ?on:None x ~f:(fun x -> [ x ]) | _ -> join_container_ ~len:List.length ~map:List.map ~iter:List.iter l +let[@inline] map_list ~f l : _ list t = List.map f l |> join_list + let wait_array (a : _ t array) : unit t = join_container_ a ~iter:Array.iter ~len:Array.length ~map:(fun _f _ -> ()) diff --git a/src/fut.mli b/src/fut.mli index 1eed358a..d365f265 100644 --- a/src/fut.mli +++ b/src/fut.mli @@ -144,6 +144,10 @@ val join_array : 'a t array -> 'a array t val join_list : 'a t list -> 'a list t (** Wait for all the futures in the list. Fails if any future fails. *) +val map_list : f:('a -> 'b t) -> 'a list -> 'b list t +(** [map_list ~f l] is like [join_list @@ List.map f l]. + @since NEXT_RELEASE *) + val wait_array : _ t array -> unit t (** [wait_array arr] waits for all futures in [arr] to resolve. It discards the individual results of futures in [arr]. It fails if any future fails. *)