public static Future <Try <To> > flatMapT <From, To>( this Future <Try <From> > future, Fn <From, Future <To> > mapper ) { return(future.flatMap(t => t.fold( from => mapper(from).map(F.scs), err => Future.successful(F.err <To>(err)) ))); }
public static Future <Either <Err, To> > flatMapE <From, To, Err>( this Future <Either <Err, From> > future, Fn <From, Future <Either <Err, To> > > mapper ) { return(future.flatMap(e => e.fold( err => Future.successful(Either <Err, To> .Left(err)), mapper ))); }
public static Future <Option <B> > flatMapO <A, B>( this Future <Option <A> > future, Fn <A, Future <Option <B> > > mapper ) { return(future.flatMap(opt => opt.fold( () => Future.successful(F.none <B>()), mapper ))); }
public void SuccessfulToSuccessful() { successful.flatMap(successfulMapper).shouldBeOfSuccessfulType(2); }
public static Future <A> flatten <A>(this Future <Future <A> > future) => future.flatMap(_ => _);
public static Future <A> extract <A>(this Future <Option <A> > optFuture) => optFuture.flatMap(opt => opt.fold(Future <A> .unfulfilled, Future.successful));
public static Future <C> SelectMany <A, B, C>(this Future <A> fa, Fn <A, Future <B> > f, Fn <A, B, C> g) => fa.flatMap(f, g);
public static Future <B> SelectMany <A, B>(this Future <A> fa, Fn <A, Future <B> > f) => fa.flatMap(f);