import { pipe } from 'fp-ts/lib/pipeable' ; import { TaskEither } from 'fp-ts/lib/TaskEither' ; import { fold } from 'fp-ts/lib/Either' ; export const toPromise = async < E , A > ( taskEither ) : Promise < A > => pipe ( await taskEither ( ) , fold ( ( e ) => Promise . reject ( e ) , ( a ) => Promise . resolve ( a ) ) ) ; export const toError = ( e ) : Error => ( e instanceof Error ? e : new Error ( String ( e ) ) ) ;