sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.04k stars 94 forks source link

fromLeft and fromRight #683

Closed ryanbas21 closed 4 years ago

ryanbas21 commented 4 years ago

Forgot why I never opened this, but I can't see a reason to not push it forward. Let me know if there is anything you'd like me to add / change etc.

Summary of changes: Add functionality of fromLeft and fromRight

fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b

davidchambers commented 4 years ago

This pull request contains a subset of the changes proposed in #644. This pull request does not change the behaviour of fromEither, meaning that these changes could be included in the next minor release. This would result in two equivalent functions coexisting, which would be unusual given our avoidance of aliases. It seems like a reasonable course of action.

davidchambers commented 4 years ago

@ryanbas21, as you may or may not be aware, #644 was open at the time you made your additions. That pull request has already been reviewed and discussed, and includes documentation. It makes sense to reuse @futpib's work rather than reproduce it, so I cherry-picked one of the commits and reverted the changes to fromEither included in that commit.

@futpib, I hope you are comfortable with me modifying one of your commits.

@ryanbas21, I hope you are comfortable with me commandeering your pull request.