Skip to content

Add Option.all & Result.all helpers#202

Closed
bloodyowl wants to merge 2 commits into
rescript-lang:mainfrom
bloodyowl:option-result-all
Closed

Add Option.all & Result.all helpers#202
bloodyowl wants to merge 2 commits into
rescript-lang:mainfrom
bloodyowl:option-result-all

Conversation

@bloodyowl

@bloodyowl bloodyowl commented Mar 16, 2024

Copy link
Copy Markdown
Contributor

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

cknitt commented Mar 17, 2024

Copy link
Copy Markdown
Member

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.)

"en-US",
"en-GB"
], undefined);
]);

Copy link
Copy Markdown
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
Copy Markdown
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