假设您有以下代码:
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);
addOne与func1or结合func2比较容易:
const res = R.compose(
S.map(addOne),
func1
)();
但是如何add使用func1andfunc2作为参数调用呢?
ps 我知道 ramda 提供了一个add功能。将该示例视为对现实世界问题的抽象。
慕莱坞森
相关分类