rescript-core
rescript-core copied to clipboard
Add Option.all & Result.all helpers
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)
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.)
closing as merged with https://github.com/rescript-lang/rescript/pull/7181