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

Minor Cleanup/Improvements #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ryantaylor
Copy link

@ryantaylor ryantaylor commented Oct 19, 2019

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

  1. ok has been renamed to do_try. This has been done in the spirit of Rust's try macro, and makes more sense in my opinion. I believe ok should wrap a value in an :ok result in order to make chaining more user-friendly.
  2. I've also added an err function to provide a user-friendly way to wrap a value in an :error result.
  3. When using 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.
  4. ExSpec has been updated to eliminate compiler warnings.

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.

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.

None yet

1 participant