I have the following code:
const tError = (err) => (err instanceof Error ? err : Error("unexpected error"));
const safeImport = TE.tryCatchK((s) => import(s)),tError);
export const run= (globString) => pipe(
glob.sync(globString),
TE.traverseArray(safeImport),
async x => console.log(await x()),
)
//this call outputs
[{_tag: 'Left', left: Error [ERR_MODULE_NOT_FOUND]: Cannot find module...}]
but if I do:
const tError = (err) => (err instanceof Error ? err : Error("unexpected error"));
const safeImport = TE.tryCatchK((s) => import(s)),tError);
export const run= (globString) => pipe(
glob.sync(globString),
A.map(safeImport),
A.map(async x => console.log(await x())),
)
//this call outputs
[
{_tag: 'Left', left: Error [ERR_MODULE_NOT_FOUND]: Cannot find module...},
{_tag: 'Right', right:...},{_tag: 'Right', right:...},{_tag: 'Right', right:...},{_tag: 'Right', right:...}
]
//
I would like to flip the types but keeping both the left and the rights, any idea of what I am doing wrong?