Skip to content

Commit 0d3a1c5

Browse files
committed
removing parenthesis of single argument lamda expression
1 parent 0fba016 commit 0d3a1c5

1 file changed

Lines changed: 39 additions & 41 deletions

File tree

core/src/main/java/fj/F1Functions.java

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class F1Functions {
2929
* @return The composed function such that this function is applied last.
3030
*/
3131
static public <A, B, C> F<C, B> o(final F<A, B> f, final F<C, A> g) {
32-
return (c) -> f.f(g.f(c));
32+
return c -> f.f(g.f(c));
3333
}
3434

3535
/**
@@ -38,7 +38,7 @@ static public <A, B, C> F<C, B> o(final F<A, B> f, final F<C, A> g) {
3838
* @return A function that composes this function with another.
3939
*/
4040
static public <A, B,C> F<F<C, A>, F<C, B>> o(final F<A, B> f) {
41-
return (g) -> o(f, g);
41+
return g -> o(f, g);
4242
}
4343

4444
/**
@@ -58,7 +58,7 @@ static public <A, B, C> F<A, C> andThen(final F<A, B> f, final F<B, C> g) {
5858
* @return A function that invokes this function and then a given function on the result.
5959
*/
6060
static public <A, B, C> F<F<B, C>, F<A, C>> andThen(final F<A, B> f) {
61-
return (g) -> andThen(f, g);
61+
return g -> andThen(f, g);
6262
}
6363

6464
/**
@@ -68,7 +68,7 @@ static public <A, B, C> F<F<B, C>, F<A, C>> andThen(final F<A, B> f) {
6868
* @return A function that invokes this function on its argument and then the given function on the result.
6969
*/
7070
static public <A, B, C> F<A, C> bind(final F<A, B> f, final F<B, F<A, C>> g) {
71-
return (a) -> g.f(f.f(a)).f(a);
71+
return a -> g.f(f.f(a)).f(a);
7272
}
7373

7474
/**
@@ -77,7 +77,7 @@ static public <A, B, C> F<A, C> bind(final F<A, B> f, final F<B, F<A, C>> g) {
7777
* @return A function that binds another function across this function.
7878
*/
7979
static public <A, B, C> F<F<B, F<A, C>>, F<A, C>> bind(final F<A, B> f) {
80-
return (g) -> bind(f, g);
80+
return g -> bind(f, g);
8181
}
8282

8383
/**
@@ -89,7 +89,7 @@ static public <A, B, C> F<F<B, F<A, C>>, F<A, C>> bind(final F<A, B> f) {
8989
* applied to the result of applying this function to the argument.
9090
*/
9191
static public <A, B, C> F<A, C> apply(final F<A, B> f, final F<A, F<B, C>> g) {
92-
return (a) -> g.f(a).f(f.f(a));
92+
return a -> g.f(a).f(f.f(a));
9393
}
9494

9595
/**
@@ -98,7 +98,7 @@ static public <A, B, C> F<A, C> apply(final F<A, B> f, final F<A, F<B, C>> g) {
9898
* @return A function that applies a given function within the environment of this function.
9999
*/
100100
static public <A, B, C> F<F<A, F<B, C>>, F<A, C>> apply(final F<A, B> f) {
101-
return (g) -> apply(f, g);
101+
return g -> apply(f, g);
102102
}
103103

104104
/**
@@ -108,9 +108,7 @@ static public <A, B, C> F<F<A, F<B, C>>, F<A, C>> apply(final F<A, B> f) {
108108
* @return A new function that invokes this function on its arguments before invoking the given function.
109109
*/
110110
static public <A, B, C> F<A, F<A, C>> on(final F<A, B> f, final F<B, F<B, C>> g) {
111-
return (a1) ->
112-
(a2) ->
113-
g.f(f.f(a1)).f(f.f(a2));
111+
return a1 -> a2 -> g.f(f.f(a1)).f(f.f(a2));
114112
}
115113

116114

@@ -121,7 +119,7 @@ static public <A, B, C> F<A, F<A, C>> on(final F<A, B> f, final F<B, F<B, C>> g)
121119
* @return A function that applies this function over the arguments of another function.
122120
*/
123121
static public <A, B, C> F<F<B, F<B, C>>, F<A, F<A, C>>> on(final F<A, B> f) {
124-
return (g) -> on(f, g);
122+
return g -> on(f, g);
125123
}
126124

127125
/**
@@ -130,7 +128,7 @@ static public <A, B, C> F<F<B, F<B, C>>, F<A, F<A, C>>> on(final F<A, B> f) {
130128
* @return This function promoted to return its result in a product-1.
131129
*/
132130
static public <A, B> F<A, P1<B>> lazy(final F<A, B> f) {
133-
return (a) -> new P1<B>(){
131+
return a -> new P1<B>(){
134132
public B _1() {
135133
return f.f(a);
136134
}
@@ -153,7 +151,7 @@ static public <A, B> P1<B> f(final F<A, B> f, final A a) {
153151
* @return This function promoted to map over a product-1.
154152
*/
155153
static public <A, B> F<P1<A>, P1<B>> mapP1(final F<A, B> f) {
156-
return (p) -> p.map(f);
154+
return p -> p.map(f);
157155
}
158156

159157
/**
@@ -162,7 +160,7 @@ static public <A, B> F<P1<A>, P1<B>> mapP1(final F<A, B> f) {
162160
* @return This function promoted to return its result in an Option.
163161
*/
164162
static public <A, B> F<A, Option<B>> optionK(final F<A, B> f) {
165-
return (a) -> some(f.f(a));
163+
return a -> some(f.f(a));
166164
}
167165

168166
/**
@@ -171,7 +169,7 @@ static public <A, B> F<A, Option<B>> optionK(final F<A, B> f) {
171169
* @return This function promoted to map over an optional value.
172170
*/
173171
static public <A, B> F<Option<A>, Option<B>> mapOption(final F<A, B> f) {
174-
return (o) -> o.map(f);
172+
return o -> o.map(f);
175173
}
176174

177175
/**
@@ -180,7 +178,7 @@ static public <A, B> F<Option<A>, Option<B>> mapOption(final F<A, B> f) {
180178
* @return This function promoted to return its result in a List.
181179
*/
182180
static public <A, B> F<A, List<B>> listK(final F<A, B> f) {
183-
return (a) -> List.single(f.f(a));
181+
return a -> List.single(f.f(a));
184182
}
185183

186184
/**
@@ -189,7 +187,7 @@ static public <A, B> F<A, List<B>> listK(final F<A, B> f) {
189187
* @return This function promoted to map over a List.
190188
*/
191189
static public <A, B> F<List<A>, List<B>> mapList(final F<A, B> f) {
192-
return (x) -> x.map(f);
190+
return x -> x.map(f);
193191
}
194192

195193
/**
@@ -198,7 +196,7 @@ static public <A, B> F<List<A>, List<B>> mapList(final F<A, B> f) {
198196
* @return This function promoted to return its result in a Stream.
199197
*/
200198
static public <A, B> F<A, Stream<B>> streamK(final F<A, B> f) {
201-
return (a) -> Stream.single(f.f(a));
199+
return a -> Stream.single(f.f(a));
202200
}
203201

204202
/**
@@ -207,7 +205,7 @@ static public <A, B> F<A, Stream<B>> streamK(final F<A, B> f) {
207205
* @return This function promoted to map over a Stream.
208206
*/
209207
static public <A, B> F<Stream<A>, Stream<B>> mapStream(final F<A, B> f) {
210-
return (x) -> x.map(f);
208+
return x -> x.map(f);
211209
}
212210

213211
/**
@@ -216,7 +214,7 @@ static public <A, B> F<Stream<A>, Stream<B>> mapStream(final F<A, B> f) {
216214
* @return This function promoted to return its result in a Array.
217215
*/
218216
static public <A, B> F<A, Array<B>> arrayK(final F<A, B> f) {
219-
return (a) -> Array.single(f.f(a));
217+
return a -> Array.single(f.f(a));
220218

221219
}
222220

@@ -226,7 +224,7 @@ static public <A, B> F<A, Array<B>> arrayK(final F<A, B> f) {
226224
* @return This function promoted to map over a Array.
227225
*/
228226
static public <A, B> F<Array<A>, Array<B>> mapArray(final F<A, B> f) {
229-
return (x) -> x.map(f);
227+
return x -> x.map(f);
230228
}
231229

232230
/**
@@ -235,7 +233,7 @@ static public <A, B> F<Array<A>, Array<B>> mapArray(final F<A, B> f) {
235233
* @return A function that comaps over a given actor.
236234
*/
237235
static public <A, B> F<Actor<B>, Actor<A>> comapActor(final F<A, B> f) {
238-
return (a) -> a.comap(f);
236+
return a -> a.comap(f);
239237
}
240238

241239
/**
@@ -254,7 +252,7 @@ static public <A, B> F<A, Promise<B>> promiseK(final F<A, B> f, final Strategy<U
254252
* @return This function promoted to map over Promises.
255253
*/
256254
static public <A, B> F<Promise<A>, Promise<B>> mapPromise(final F<A, B> f) {
257-
return (p) -> p.fmap(f);
255+
return p -> p.fmap(f);
258256
}
259257

260258
/**
@@ -305,7 +303,7 @@ static public <A, B, X> F<Either<X, A>, Either<X, B>> mapRight(final F<A, B> f)
305303
* @return a function that returns the left side of a given Either, or this function applied to the right side.
306304
*/
307305
static public <A, B> F<Either<B, A>, B> onLeft(final F<A, B> f) {
308-
return (e) -> e.left().on(f);
306+
return e -> e.left().on(f);
309307
}
310308

311309
/**
@@ -314,7 +312,7 @@ static public <A, B> F<Either<B, A>, B> onLeft(final F<A, B> f) {
314312
* @return a function that returns the right side of a given Either, or this function applied to the left side.
315313
*/
316314
static public <A, B> F<Either<A, B>, B> onRight(final F<A, B> f) {
317-
return (e) -> e.right().on(f);
315+
return e -> e.right().on(f);
318316
}
319317

320318
/**
@@ -353,7 +351,7 @@ static public <A, B> F<A, NonEmptyList<B>> nelK(final F<A, B> f) {
353351
* @return This function promoted to map over a NonEmptyList.
354352
*/
355353
static public <A, B> F<NonEmptyList<A>, NonEmptyList<B>> mapNel(final F<A, B> f) {
356-
return (list) -> list.map(f);
354+
return list -> list.map(f);
357355
}
358356

359357
/**
@@ -364,7 +362,7 @@ static public <A, B> F<NonEmptyList<A>, NonEmptyList<B>> mapNel(final F<A, B> f)
364362
*/
365363
static public <A, B> F<A, Set<B>> setK(final F<A, B> f, final Ord<B> o
366364
) {
367-
return (a) -> Set.single(o, f.f(a));
365+
return a -> Set.single(o, f.f(a));
368366
}
369367

370368
/**
@@ -374,7 +372,7 @@ static public <A, B> F<A, Set<B>> setK(final F<A, B> f, final Ord<B> o
374372
* @return This function promoted to map over a Set.
375373
*/
376374
static public <A, B> F<Set<A>, Set<B>> mapSet(final F<A, B> f, final Ord<B> o) {
377-
return (s) -> s.map(o, f);
375+
return s -> s.map(o, f);
378376
}
379377

380378
/**
@@ -383,7 +381,7 @@ static public <A, B> F<Set<A>, Set<B>> mapSet(final F<A, B> f, final Ord<B> o) {
383381
* @return This function promoted to return its value in a Tree.
384382
*/
385383
static public <A, B> F<A, Tree<B>> treeK(final F<A, B> f) {
386-
return (a) -> Tree.leaf(f.f(a));
384+
return a -> Tree.leaf(f.f(a));
387385
}
388386

389387
/**
@@ -431,7 +429,7 @@ static public <A, B> F<TreeZipper<A>, TreeZipper<B>> mapTreeZipper(final F<A, B>
431429
* @return This function promoted to return its result on the failure side of a Validation.
432430
*/
433431
static public <A, B, C> F<A, Validation<B, C>> failK(final F<A, B> f) {
434-
return (a) -> Validation.fail(f.f(a));
432+
return a -> Validation.fail(f.f(a));
435433

436434
}
437435

@@ -442,7 +440,7 @@ static public <A, B, C> F<A, Validation<B, C>> failK(final F<A, B> f) {
442440
* @return This function promoted to return its result on the success side of an Validation.
443441
*/
444442
static public <A, B, C> F<A, Validation<C, B>> successK(final F<A, B> f) {
445-
return (a) -> Validation.success(f.f(a));
443+
return a -> Validation.success(f.f(a));
446444
}
447445

448446
/**
@@ -451,7 +449,7 @@ static public <A, B, C> F<A, Validation<C, B>> successK(final F<A, B> f) {
451449
* @return This function promoted to map over the failure side of a Validation.
452450
*/
453451
static public <A, B, X> F<Validation<A, X>, Validation<B, X>> mapFail(final F<A, B> f) {
454-
return (v) -> v.f().map(f);
452+
return v -> v.f().map(f);
455453
}
456454

457455
/**
@@ -460,7 +458,7 @@ static public <A, B, X> F<Validation<A, X>, Validation<B, X>> mapFail(final F<A,
460458
* @return This function promoted to map over the success side of a Validation.
461459
*/
462460
static public <A, B, X> F<Validation<X, A>, Validation<X, B>> mapSuccess(final F<A, B> f) {
463-
return (v) -> v.map(f);
461+
return v -> v.map(f);
464462
}
465463

466464
/**
@@ -471,7 +469,7 @@ static public <A, B, X> F<Validation<X, A>, Validation<X, B>> mapSuccess(final F
471469
* or this function applied to the success side.
472470
*/
473471
static public <A, B> F<Validation<B, A>, B> onFail(final F<A, B> f) {
474-
return (v) -> v.f().on(f);
472+
return v -> v.f().on(f);
475473
}
476474

477475
/**
@@ -482,7 +480,7 @@ static public <A, B> F<Validation<B, A>, B> onFail(final F<A, B> f) {
482480
* or this function applied to the failure side.
483481
*/
484482
static public <A, B> F<Validation<A, B>, B> onSuccess(final F<A, B> f) {
485-
return (v) -> v.on(f);
483+
return v -> v.on(f);
486484
}
487485

488486
/**
@@ -491,7 +489,7 @@ static public <A, B> F<Validation<A, B>, B> onSuccess(final F<A, B> f) {
491489
* @return This function promoted to return its value in a Zipper.
492490
*/
493491
static public <A, B> F<A, Zipper<B>> zipperK(final F<A, B> f) {
494-
return andThen(streamK(f), (s) -> fromStream(s).some());
492+
return andThen(streamK(f), s -> fromStream(s).some());
495493
}
496494

497495
/**
@@ -500,7 +498,7 @@ static public <A, B> F<A, Zipper<B>> zipperK(final F<A, B> f) {
500498
* @return This function promoted to map over a Zipper.
501499
*/
502500
static public <A, B> F<Zipper<A>, Zipper<B>> mapZipper(final F<A, B> f) {
503-
return (z) -> z.map(f);
501+
return z -> z.map(f);
504502
}
505503

506504
/**
@@ -509,7 +507,7 @@ static public <A, B> F<Zipper<A>, Zipper<B>> mapZipper(final F<A, B> f) {
509507
* @return This function promoted to map over an Equal as a contravariant functor.
510508
*/
511509
static public <A, B> F<Equal<B>, Equal<A>> comapEqual(final F<A, B> f) {
512-
return (e) -> e.comap(f);
510+
return e -> e.comap(f);
513511
}
514512

515513
/**
@@ -518,7 +516,7 @@ static public <A, B> F<Equal<B>, Equal<A>> comapEqual(final F<A, B> f) {
518516
* @return This function promoted to map over a Hash as a contravariant functor.
519517
*/
520518
static public <A, B> F<Hash<B>, Hash<A>> comapHash(final F<A, B> f) {
521-
return (h) -> h.comap(f);
519+
return h -> h.comap(f);
522520
}
523521

524522
/**
@@ -527,7 +525,7 @@ static public <A, B> F<Hash<B>, Hash<A>> comapHash(final F<A, B> f) {
527525
* @return This function promoted to map over a Show as a contravariant functor.
528526
*/
529527
static public <A, B> F<Show<B>, Show<A>> comapShow(final F<A, B> f) {
530-
return (s) -> s.comap(f);
528+
return s -> s.comap(f);
531529
}
532530

533531
/**
@@ -554,7 +552,7 @@ static public <A, B, C> F<P2<C, A>, P2<C, B>> mapSnd(final F<A, B> f) {
554552
* @return This function promoted to map over both elements of a pair.
555553
*/
556554
static public <A, B> F<P2<A, A>, P2<B, B>> mapBoth(final F<A, B> f) {
557-
return (p2) -> P2.map(f, p2);
555+
return p2 -> P2.map(f, p2);
558556
}
559557

560558
/**

0 commit comments

Comments
 (0)