此处介绍了面向铁路的编程(ROP):
https://fsharpforfunandprofit.com/rop/
是否可以通过Fluture
我可以使用以下两种辅助方法进行ROP:
const bind = f => x => Future.attempt(() => f(x));
const bindAsync = f => x => Future.tryP(() => f(x));
Future.of("TEST")
.chain(bind(doThis))
.chain(bind(doThat))
.chain(bindAsync(doThisAsync))
.chain(bindAsync(doThatAsync))
.chain(bind(doAnotherThing))
.chain(bindAsync(doAnotherThingAsync))
.
.
.
是否有更好的方法来删除bind
,bindAsync
并自动进行绑定?