Skip to content

Commit 7211189

Browse files
committed
Replaced anonymous F3s with lambdas
1 parent b438b1b commit 7211189

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

core/src/main/java/fj/data/hlist/HList.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ private HFoldr(final F3<G, V, L, R> foldRight) {
212212
* @return a fold instance for the empty list.
213213
*/
214214
public static <G, V> HFoldr<G, V, HNil, V> hFoldr() {
215-
return new HFoldr<G, V, HNil, V>(new F3<G, V, HNil, V>() {
216-
public V f(final G f, final V v, final HNil hNil) {
217-
return v;
218-
}
219-
});
215+
return new HFoldr<G, V, HNil, V>((f, v, hNil) -> v);
220216
}
221217

222218
/**
@@ -238,11 +234,7 @@ public V f(final G f, final V v, final HNil hNil) {
238234
H extends HFoldr<G, V, L, R>,
239235
PP extends Apply<G, P2<E, R>, RR>>
240236
HFoldr<G, V, HCons<E, L>, RR> hFoldr(final PP p, final H h) {
241-
return new HFoldr<G, V, HCons<E, L>, RR>(new F3<G, V, HCons<E, L>, RR>() {
242-
public RR f(final G f, final V v, final HCons<E, L> c) {
243-
return p.apply(f, P.p(c.head(), h.foldRight(f, v, c.tail())));
244-
}
245-
});
237+
return new HFoldr<G, V, HCons<E, L>, RR>((f, v, c) -> p.apply(f, P.p(c.head(), h.foldRight(f, v, c.tail()))));
246238
}
247239

248240
/**

demo/src/main/java/fj/demo/test/EqualsHashCode.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ public static void main(final String[] args) {
6161
final Arbitrary<Byte> arbByteR = arbitrary(arbByte.gen.map(b -> (byte)(b % 3)));
6262

6363
// Restrictive arbitrary for String, produces from twelve (2 * 3 * 2) possible values.
64-
final Arbitrary<String> arbStringR = arbitrary(arbCharacter.gen.bind(arbCharacter.gen, arbCharacter.gen, curry(new F3<Character, Character, Character, String>() {
65-
public String f(final Character c1, final Character c2, final Character c3) {
66-
return new String(new char[]{(char)(c1 % 2 + 'a'), (char)(c2 % 3 + 'a'), (char)(c3 % 2 + 'a')});
67-
}
68-
})));
64+
final Arbitrary<String> arbStringR = arbitrary(arbCharacter.gen.bind(arbCharacter.gen, arbCharacter.gen, curry((c1, c2, c3) -> new String(new char[]{(char)(c1 % 2 + 'a'), (char)(c2 % 3 + 'a'), (char)(c3 % 2 + 'a')}))));
6965

7066
// Arbitrary for MyClass that uses the restrictive arbitraries above.
7167
// We are using the monad pattern (bind) to make this a trivial exercise.

0 commit comments

Comments
 (0)