@@ -86,11 +86,7 @@ public static <A> Promise<A> promise(final Strategy<Unit> s, final P1<A> a) {
8686 * @return A function that, given a 1-product, yields a promise of that product's value.
8787 */
8888 public static <A > F <P1 <A >, Promise <A >> promise (final Strategy <Unit > s ) {
89- return new F <P1 <A >, Promise <A >>() {
90- public Promise <A > f (final P1 <A > a ) {
91- return promise (s , a );
92- }
93- };
89+ return a -> promise (s , a );
9490 }
9591
9692 /**
@@ -117,11 +113,7 @@ public Callable<A> _1() {
117113 * @return The given function transformed into a function that returns a promise.
118114 */
119115 public static <A , B > F <A , Promise <B >> promise (final Strategy <Unit > s , final F <A , B > f ) {
120- return new F <A , Promise <B >>() {
121- public Promise <B > f (final A a ) {
122- return promise (s , P1 .curry (f ).f (a ));
123- }
124- };
116+ return a -> promise (s , P1 .curry (f ).f (a ));
125117 }
126118
127119 /**
@@ -150,11 +142,7 @@ public <B> Promise<B> fmap(final F<A, B> f) {
150142 * @return That function lifted to a function on Promises.
151143 */
152144 public static <A , B > F <Promise <A >, Promise <B >> fmap_ (final F <A , B > f ) {
153- return new F <Promise <A >, Promise <B >>() {
154- public Promise <B > f (final Promise <A > a ) {
155- return a .fmap (f );
156- }
157- };
145+ return a -> a .fmap (f );
158146 }
159147
160148 /**
@@ -206,11 +194,7 @@ public void f(final B b) {
206194 * @return A new promise after applying the given promised function to this promise.
207195 */
208196 public <B > Promise <B > apply (final Promise <F <A , B >> pf ) {
209- return pf .bind (new F <F <A , B >, Promise <B >>() {
210- public Promise <B > f (final F <A , B > f ) {
211- return fmap (f );
212- }
213- });
197+ return pf .bind (f -> fmap (f ));
214198 }
215199
216200 /**
@@ -267,11 +251,7 @@ public static <A> Promise<List<A>> sequence(final Strategy<Unit> s, final List<P
267251 * @return A function that turns a list of promises into a single promise of a list.
268252 */
269253 public static <A > F <List <Promise <A >>, Promise <List <A >>> sequence (final Strategy <Unit > s ) {
270- return new F <List <Promise <A >>, Promise <List <A >>>() {
271- public Promise <List <A >> f (final List <Promise <A >> as ) {
272- return sequence (s , as );
273- }
274- };
254+ return as -> sequence (s , as );
275255 }
276256
277257 /**
@@ -282,15 +262,7 @@ public Promise<List<A>> f(final List<Promise<A>> as) {
282262 * @return A single promise for the given Stream.
283263 */
284264 public static <A > Promise <Stream <A >> sequence (final Strategy <Unit > s , final Stream <Promise <A >> as ) {
285- return join (foldRightS (s , curry (new F2 <Promise <A >, P1 <Promise <Stream <A >>>, Promise <Stream <A >>>() {
286- public Promise <Stream <A >> f (final Promise <A > o , final P1 <Promise <Stream <A >>> p ) {
287- return o .bind (new F <A , Promise <Stream <A >>>() {
288- public Promise <Stream <A >> f (final A a ) {
289- return p ._1 ().fmap (Stream .<A >cons_ ().f (a ));
290- }
291- });
292- }
293- }), promise (s , P .p (Stream .<A >nil ()))).f (as ));
265+ return join (foldRightS (s , curry ((Promise <A > o , P1 <Promise <Stream <A >>> p ) -> o .bind (a -> p ._1 ().fmap (Stream .<A >cons_ ().f (a )))), promise (s , P .p (Stream .<A >nil ()))).f (as ));
294266 }
295267
296268 /**
@@ -300,11 +272,7 @@ public Promise<Stream<A>> f(final A a) {
300272 * @return A function that turns a list of promises into a single promise of a Stream..
301273 */
302274 public static <A > F <List <Promise <A >>, Promise <List <A >>> sequenceS (final Strategy <Unit > s ) {
303- return new F <List <Promise <A >>, Promise <List <A >>>() {
304- public Promise <List <A >> f (final List <Promise <A >> as ) {
305- return sequence (s , as );
306- }
307- };
275+ return as -> sequence (s , as );
308276 }
309277
310278 /**
0 commit comments