我有简单的三个函数返回arrow-kt
数据类型
fun validate(input): Validated<Error, Input> = ...
fun fetch(input): Option<Error, InputEntity> = ...
fun performAction(inputEntity): Either<Error, Output> = ...
并且想要链接这样的东西(可以使用任何可用的功能而不是map
)
validate(input)
.map{fetch(it)}
.map{performAction(it)}
我能想出的唯一解决Validated
方案是Option
用. 有没有更好的功能方式让它在不更新现有功能的情况下工作?Either
flatMap