Suppose that you have the following code:
import R from "ramda";
import S from "sanctuary";
import { Left, Right } from "sanctuary-either";
const add = R.curry((p1, p2) => p1 + p2);
const addOne = add(1);
const func1 = () => Right(2);
const func2 = () => Right(7);
Combining addOne
with func1
or func2
is relatively easy:
const res = R.compose(
S.map(addOne),
func1
)();
but how can one call add
using func1
and func2
as arguments?
p.s. I know that ramda offers an add
function. Consider the example as an abstraction of a real world problem.
You are probably looking for the
lift2
function:Alternatively, you can use
ap
: