Skip to content

Add Option.all & Result.all helpers #202

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

Closed
wants to merge 2 commits into from

Conversation

bloodyowl
Copy link
Contributor

@bloodyowl bloodyowl commented Mar 16, 2024

Adds Option.all & Result.all helpers. The API is inspired by Promise.all which is pretty well known by users.

Option.all([]) // Some([])
Option.all([Some(1), Some(2), Some(3)]) // Some([1, 2, 3])
Option.all([Some(1), None]) // None

Result.all([]) // Ok([])
Result.all([Ok(1), Ok(2), Ok(3)]) // Ok([1, 2, 3])
Result.all([Ok(1), Error(1)]) // Error(1)

@cknitt
Copy link
Member

cknitt commented Mar 17, 2024

I think that if we want to add this, we should also have all2, all3, ... like we do for Promise.

(This is something that I would actually already have needed in practice for the Result module.)

@@ -24,7 +24,7 @@ var collator = new Intl.Collator(["en-US"], {
Intl.Collator.supportedLocalesOf([
"en-US",
"en-GB"
], undefined);
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some unrelated changes in the test output like here - were you using a different/newer ReScript version?

@bloodyowl
Copy link
Contributor Author

closing as merged with rescript-lang/rescript#7181

@bloodyowl bloodyowl closed this Dec 12, 2024
@bloodyowl bloodyowl deleted the option-result-all branch December 12, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants