I have a pipe like this:
S.pipe([
    getRequestFile,                  // not async
    S.chain(saveTemporary),          // not async
    S.chain(copyImageToPublicPath),  // async
    S.chain(copyFileToPath),         // async
    S.chain(someLoggingFunction),    // not async
    S.chain(sendResponse),           // not async
]);
There are 2 async functions in middle of this pipe.
I want to await for copyImageToPublicPath and then await for copyFileToPath and then continue the normal flow
After some search I found that there is Future.tryP function for doing async but how can I use Fluture in middle of this pipe?
                        
It's a matter of lining up the types.
Let's make up some type definitions to use in an example:
Now, let create our program step by step…
To operate on the
binside aFuture a bvalue we use eitherS.maporS.chain.S.mapcan lead to unwanted nesting:We could use
S.chainto avoid this nesting:It may be helpful to think of
S.mapadding to some computation an operation that cannot fail, whereasS.chainadds a computation that can fail.