Skip to content
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

Provide an idiomatic way to flatten List<Result> #80

Closed
asarkar opened this issue Apr 14, 2021 · 4 comments
Closed

Provide an idiomatic way to flatten List<Result> #80

asarkar opened this issue Apr 14, 2021 · 4 comments

Comments

@asarkar
Copy link

asarkar commented Apr 14, 2021

From kittinunf/fuel#805:

It'd be nice to able to do the following:

  1. Transform List<Result<Foo, FuelError>> into Result<List<Foo>, FuelError>. If any of the Results is an error, the final Result is an error too, sort of an AND.
  2. Transform List<Result<Foo, FuelError>> into Result<List<Foo>, FuelError>. If any of the Results is a success, the final Result is a success too, sort of an OR.
@kittinunf
Copy link
Owner

Just to confirm, I think we have support for 1. already with lift(). I am not sure how useful the 2. nd case is though. Let's assume that we have 5 items in the list like so;

List<Result<...>>

  1. Success
  2. Failure
  3. Success
  4. Success
  5. Success

When we "lift" this into Result<List<>>, what do we do to the 2nd (the failure one?)? Just ignore them?

@asarkar
Copy link
Author

asarkar commented Apr 16, 2021

what do we do to the 2nd (the failure one?)?

Provide an error handler fn perhaps, user can do whatever they want in there with the exception.

@kittinunf
Copy link
Owner

Then I think we might be able to expand the lift() functionality then?

@kittinunf
Copy link
Owner

Close with new version

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

No branches or pull requests

2 participants