rescript-core icon indicating copy to clipboard operation
rescript-core copied to clipboard

Add Option.all & Result.all helpers

Open bloodyowl opened this issue 1 year ago • 1 comments

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)

bloodyowl avatar Mar 16 '24 12:03 bloodyowl

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

cknitt avatar Mar 17 '24 18:03 cknitt

closing as merged with https://github.com/rescript-lang/rescript/pull/7181

bloodyowl avatar Dec 12 '24 11:12 bloodyowl