Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses various issues I've come across while using this library. A few are personal preference and will be labeled as such; others I believe are fundamental to the correct functioning of the library. If you'd like, I can separate the two and submit two PRs instead of this single one.
Changes
ok
has been renamed todo_try
. This has been done in the spirit of Rust'stry
macro, and makes more sense in my opinion. I believeok
should wrap a value in an:ok
result in order to make chaining more user-friendly.err
function to provide a user-friendly way to wrap a value in an:error
result.try_catch
, a method that does not raise should return a value wrapped in an:ok
result. This conforms to the expectations laid out in https://zohaib.me/railway-programming-pattern-in-elixir/ and makes sense logically, and also makes code much easier to write. Tests have been updated to reflect this change as well.Of these changes, 3) and 4) are logical changes that I believe should be made no matter what; 1) and 2) are stylistic changes that I prefer but which I understand may not make sense to be included in a wide release. As mentioned, I can split the changes if that is preferred.