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

add .map_all_split/2 and unwrap utils #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sitch
Copy link

@sitch sitch commented Oct 11, 2019

I've found cases where it's useful to combine OK.map_all/2 along with Enum.split_with/2 in order to explain failure cases for various evaluations. Things like mapping a cast/1 function where you might need to detail to the user what was wrong with some items.

I also added .unwrap/1, .unwrap_ok/1 and .unwrap_failure/1 as general conveniences.

@giddie
Copy link

giddie commented Apr 21, 2021

I definitely think this library needs unwrap, but I think it would be better to make it less convenient to drop the success/failure information. I would prefer:

  • unwrap/2: opposite of "wrap" - returns the value from a successful result tuple. If the result is a failure ({:error, ...}), then it returns the second parameter. I'm not in favour of nils generally, but probably most people would expect that the second parameter should default to nil.

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