-
Notifications
You must be signed in to change notification settings - Fork 184
More general join and choose operators #325
Copy link
Copy link
Closed
Labels
Description
The <&> operator has the following type:
val ( <&> ) : unit t -> unit t -> unit tIt'd be useful to have a variant that works for any promise type, returning both results, with the following type:
val ( <&> ) : 'a t -> 'b t -> ('a * 'b) tthat behaved something like this:
let (<&>) l r =
let lv = ref None and rv = ref None in
( (l >>= fun v -> lv := Some v; return_unit)
<&> (r >>= fun v -> rv := Some v; return_unit)) >|= fun () ->
match !lv, !rv with
| Some lv, Some rv -> (lv, rv)
| _ -> assert falseSimilarly, the <?> operator has the following type:
val ( <?> ) : 'a t -> 'a t -> 'a tIt'd be useful to have a variant that doesn't constrain the result types to be the same, and that preserves the information about which promise delivered the result, with the following type:
val ( <?> ) : 'a t -> 'b t -> ('a, 'b) either tthat behaved something like this:
let (<?>) l r =
map (fun l -> Left l) l
<?> map (fun r -> Right r) rReactions are currently unavailable