Skip to content

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