Created
December 5, 2018 22:11
-
-
Save jrsinclair/0c7bc161e6303c797cfdab8690e0ead5 to your computer and use it in GitHub Desktop.
Elegant Error Handling Code Samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Rest of Left class is hidden to save space */ | |
// Ap In Left (the sad path) | |
ap() { | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Rest of the Right class is hidden to save space */ | |
// In Right (the happy path) | |
ap(otherEither) { | |
const functionToRun = otherEither._value; | |
return this.map(functionToRun); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment