since import * as F from 'fluture' ; import * as E from 'fp-ts/lib/Either' ; import { Task } from 'fp-ts/lib/Task' ; import { IO } from 'fp-ts/lib/IO' ; import { Alt2 } from 'fp-ts/lib/Alt' ; import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' ; import { ChainRec2 } from 'fp-ts/lib/ChainRec' ; import { Monad2 } from 'fp-ts/lib/Monad' ; import { pipeable } from 'fp-ts/lib/pipeable' ; import { MonadThrow2 } from 'fp-ts/lib/MonadThrow' ; import { MonadTask2 } from 'fp-ts/lib/MonadTask' ; declare module 'fp-ts/lib/HKT' { interface URItoKind2 < E , A > { 'Fluture/Future' : Future < E , A > ; } } since export const URI = 'Fluture/Future' ; since export interface Future < E , A > extends F . FutureInstance < E , A > { } since export const left = F . reject ; since export const right = F . resolve ; since export function leftIO < E = never , A = never > ( ma ) { return F . swap ( F . attempt ( ma ) ) ; } since export const rightIO = F . attempt ; since export function leftTask < E = never , A = never > ( ma ) { return F . swap ( F . attemptP ( ma ) ) ; } since export const rightTask = F . attemptP ; since export function orElse < E , A , M > ( onLeft ) { return F . chainRej ( onLeft ) ; } since export function fold < E , A , B > ( onLeft , onRight ) { return ma => ( ) => F . promise ( F . coalesce < E , Task < B > > ( onLeft ) ( onRight ) ( ma ) ) . then ( mb => mb ( ) ) ; } since export const swap = F . swap ; since export function futurify < L , R > ( f ) ; export function futurify < A , L , R > ( f ) ; export function futurify < A , B , L , R > ( f ) ; export function futurify < A , B , C , L , R > ( f ) ; export function futurify < A , B , C , D , L , R > ( f ) ; export function futurify < A , B , C , D , E , L , R > ( f ) ; export function futurify < L , R > ( f ) { return function ( ) { const args = Array . prototype . slice . call ( arguments ) ; return F . node ( done => { const cbResolver = ( e , r ) => ( e != null ? done ( e ) : done ( null , r ) ) ; f . apply ( null , args . concat ( cbResolver ) ) ; } ) ; } ; } since export type URI = typeof URI ; since export const future = { URI , map : ( fa , f ) => F . map ( f ) ( fa ) , of : F . resolve , ap : ( fab , fa ) => F . ap ( fa ) ( fab ) , chain : ( fa , f ) => F . chain ( f ) ( fa ) , bimap : ( fea , f , g ) => F . bimap ( f ) ( g ) ( fea ) , mapLeft : ( fea , f ) => F . mapRej ( f ) ( fea ) , alt : ( fx , f ) => F . alt ( f ( ) ) ( fx ) , chainRec : < E , A , B > ( a , f ) : Future < E , B > => ( function recur ( a ) : Future < E , B > { return future . chain ( f ( a ) , E . fold ( recur , F . resolve ) ) ; } ) ( a ) , throwError : left , fromTask : F . attemptP , fromIO : F . attempt } ; since export function delay ( millis ) { return chain ( F . after ( millis ) ) ; } const { alt , ap , apFirst , apSecond , bimap , chain , chainFirst , flatten , map , mapLeft , fromEither , fromOption , fromPredicate } = pipeable ( future ) ; export { alt , ap , apFirst , apSecond , bimap , chain , chainFirst , flatten , map , mapLeft , fromEither , fromOption , fromPredicate } ;