const divide = R.curry(function (a, b) {
return b === 0 ? Either.Left('Dicision by 0.') : Either.Right(a / b);
});
const addTwo = R.curry(function (val) {
return val + 2;
});
let divideTwo = R.compose(map(addTwo), divide(2));
let two = divideTwo(2); // Right.val{4}
let zero = divideTwo(0); // Left.val{err}
Created
March 11, 2016 21:21
-
-
Save fetchTe/356f4b5897cab404751a to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment