-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array.IO.sequence vs Promise.all/Promise.any #297
Comments
It runs them in parallel at present. I'd have to check, but I believe it preserves order, and emits the first error occurred (based on the order of the array, not of resolution), not all errors. |
Yeah, I think @AlexaDeWit is right - if I recall it runs the async work in parallel (because the default I don't think we have an |
I just talked to @BlueHotDog a bit in discord and wanted to bring a few things into this thread:
The key here using |
thanks @johnhaley81 ! was just about to write that :) Since i'm using rescript, the code i ended up with is: module IOWithVoidError =
IO.WithError({
type t = Void.t;
});
let collect = array => {
array
|> List.fromArray
|> List.map(IO.summonError)
|> IOWithVoidError.all
|> IO.map(res => res |> Relude.Array.fromList)
|> IO.mapError(ignore);
}; It would be cool to have allArray or something to avoid the array->list->array conversion |
While we're talking about Making it stack-safe would be a really nice-to-have. It might also make sense to just create a new "async effect type" off to the side of Desired new features:
|
If you're happy with what I'm suggesting in #298 I'd be happy to do both simultaniously? |
Hey, trying to understand how Array.IO.sequence is compared to Promise.all/Promise.any.
Are the IOs running on parallel?
Is it like Promise.all that if one fails all fails? (looks like, since it doesnt look like it collects the errors)
Maybe worth having an Promise.any solution too?
The text was updated successfully, but these errors were encountered: