请参阅以下代码片段:
const
fun1 = () => Either.of(1),
fun2 = () => Either.of(2),
fun3 = () => Either.of(3),
fun4 = curry((x, y, z) => Either.of(x + y + z)),
fun5 = x => Either.of(x + 1),
fun6 = () => pipeK(
() => sequence(Either.of, [fun1(), fun2(), fun3()]),
apply(fun4),
fun5
)(),
result = fun6() // returns 7
fun4
需要 3 个参数,只有当它们都是正确的参数时,我才想给出它们。也就是说,sequence
将应用每个单子值,因此我将它们作为一个包含原始、、、返回值的单一权限。fun1
fun2
fun3
这是推荐的方法吗?