我是 fp-ts 的新手,所以请帮我解决我的问题:我需要使用异步函数在不同级别上多次记录相同的错误。这是我的示例代码:
const myProgram = pipe(
tryCatch(() => someAsyncFunc(), toError),
mapLeft(async (err1) => {
await loggerAsyncFunc();
return err1;
}),
)
const main = pipe(
myProgram,
mapLeft((err2) => {
// err2 is a pending promise :(
})
)();
我习惯mapLeft
这样做,但它不起作用。我需要做什么才能获得err2
错误(err1)的价值而不是待定的承诺?