Skip to content

Instantly share code, notes, and snippets.

@jrsinclair
Created December 5, 2018 22:11
Show Gist options
  • Save jrsinclair/0c7bc161e6303c797cfdab8690e0ead5 to your computer and use it in GitHub Desktop.
Save jrsinclair/0c7bc161e6303c797cfdab8690e0ead5 to your computer and use it in GitHub Desktop.
Elegant Error Handling Code Samples
/* Rest of Left class is hidden to save space */
// Ap In Left (the sad path)
ap() {
return this;
}
/* 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