import { pipe } from 'fp-ts/lib/function' ; import * as Either from 'fp-ts/lib/Either' ; import { TaskEither } from 'fp-ts/lib/TaskEither' ; param task export const executeTask = async < E , A > ( task ) : Promise < A > => { const result = await task ( ) ; return new Promise ( ( resolve , reject ) => { pipe ( result , Either . fold ( reject , resolve ) ) ; } ) ; } ; param task param onLeft param onRight export const executeAndHandle = async < E , A , B > ( task , onLeft , onRight ) : Promise < B > => { const result = await task ( ) ; return pipe ( result , Either . fold < E , A , B > ( onLeft , onRight ) ) ; } ;