breaking: fut: join does not take ?on anymore

This commit is contained in:
Simon Cruanes 2023-11-07 20:38:27 -05:00
parent 9cb7781a2e
commit 9709f88d5f
2 changed files with 11 additions and 3 deletions

View file

@ -123,7 +123,6 @@ let map ?on ~f fut : _ t =
Error (e, bt))
| Error e_bt -> Error e_bt
in
match peek fut with
| Some r -> of_result (map_res r)
| None ->
@ -137,7 +136,17 @@ let map ?on ~f fut : _ t =
match on with
| None -> map_and_fulfill ()
| Some on -> Runner.run_async on map_and_fulfill);
fut2
let join (fut : 'a t t) : 'a t =
match peek fut with
| Some (Ok f) -> f
| Some (Error (e, bt)) -> fail e bt
| None ->
let fut2, promise = make () in
on_result fut (function
| Ok sub_fut -> on_result sub_fut (fulfill promise)
| Error _ as e -> fulfill promise e);
fut2
let bind ?on ~f fut : _ t =
@ -175,7 +184,6 @@ let bind ?on ~f fut : _ t =
fut2
let bind_reify_error ?on ~f fut : _ t = bind ?on ~f (reify_error fut)
let join ?on fut = bind ?on fut ~f:(fun x -> x)
let update_ (st : 'a A.t) f : 'a =
let rec loop () =

View file

@ -120,7 +120,7 @@ val bind_reify_error : ?on:Runner.t -> f:('a or_error -> 'b t) -> 'a t -> 'b t
@param on if provided, [f] runs on the given runner
@since 0.4 *)
val join : ?on:Runner.t -> 'a t t -> 'a t
val join : 'a t t -> 'a t
(** [join fut] is [fut >>= Fun.id]. It joins the inner layer of the future.
@since 0.2 *)