Skip to content

Commit b5ffcf4

Browse files
committed
Converted F1 -> F8 from abstract classes to interfaces
1 parent 1535044 commit b5ffcf4

File tree

10 files changed

+107
-102
lines changed

10 files changed

+107
-102
lines changed

.idea/misc.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
defaultTasks 'build'

core/src/main/java/fj/F.java

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

core/src/main/java/fj/F2.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*
2626
* @version %build.number%
2727
*/
28-
public abstract class F2<A, B, C> {
28+
public interface F2<A, B, C> {
2929
/**
3030
* Transform <code>A</code> and <code>B</code> to <code>C</code>.
3131
*
3232
* @param a The <code>A</code> to transform.
3333
* @param b The <code>B</code> to transform.
3434
* @return The result of the transformation.
3535
*/
36-
public abstract C f(A a, B b);
36+
public C f(A a, B b);
3737

3838

3939
/**
@@ -42,7 +42,7 @@ public abstract class F2<A, B, C> {
4242
* @param a The <code>A</code> to which to apply this function.
4343
* @return The function partially applied to the given argument.
4444
*/
45-
public final F<B, C> f(final A a) {
45+
default public F<B, C> f(final A a) {
4646
return new F<B, C>() {
4747
public C f(final B b) {
4848
return F2.this.f(a, b);
@@ -55,7 +55,7 @@ public C f(final B b) {
5555
*
5656
* @return a wrapped function of arity-1 that returns another wrapped function.
5757
*/
58-
public final F<A, F<B, C>> curry() {
58+
default public F<A, F<B, C>> curry() {
5959
return new F<A, F<B, C>>() {
6060
public F<B, C> f(final A a) {
6161
return new F<B, C>() {
@@ -72,7 +72,7 @@ public C f(final B b) {
7272
*
7373
* @return A new function with the arguments of this function flipped.
7474
*/
75-
public final F2<B, A, C> flip() {
75+
default public F2<B, A, C> flip() {
7676
return new F2<B, A, C>() {
7777
public C f(final B b, final A a) {
7878
return F2.this.f(a, b);
@@ -85,7 +85,7 @@ public C f(final B b, final A a) {
8585
*
8686
* @return A new function that calls this function with the elements of a given tuple.
8787
*/
88-
public final F<P2<A, B>, C> tuple() {
88+
default public F<P2<A, B>, C> tuple() {
8989
return new F<P2<A, B>, C>() {
9090
public C f(final P2<A, B> p) {
9191
return F2.this.f(p._1(), p._2());
@@ -98,7 +98,7 @@ public C f(final P2<A, B> p) {
9898
*
9999
* @return This function promoted to transform Arrays.
100100
*/
101-
public final F2<Array<A>, Array<B>, Array<C>> arrayM() {
101+
default public F2<Array<A>, Array<B>, Array<C>> arrayM() {
102102
return new F2<Array<A>, Array<B>, Array<C>>() {
103103
public Array<C> f(final Array<A> a, final Array<B> b) {
104104
return a.bind(b, F2.this.curry());
@@ -111,7 +111,7 @@ public Array<C> f(final Array<A> a, final Array<B> b) {
111111
*
112112
* @return This function promoted to transform Promises.
113113
*/
114-
public final F2<Promise<A>, Promise<B>, Promise<C>> promiseM() {
114+
default public F2<Promise<A>, Promise<B>, Promise<C>> promiseM() {
115115
return new F2<Promise<A>, Promise<B>, Promise<C>>() {
116116
public Promise<C> f(final Promise<A> a, final Promise<B> b) {
117117
return a.bind(b, F2.this.curry());
@@ -124,7 +124,7 @@ public Promise<C> f(final Promise<A> a, final Promise<B> b) {
124124
*
125125
* @return This function promoted to transform Iterables.
126126
*/
127-
public final F2<Iterable<A>, Iterable<B>, IterableW<C>> iterableM() {
127+
default public F2<Iterable<A>, Iterable<B>, IterableW<C>> iterableM() {
128128
return new F2<Iterable<A>, Iterable<B>, IterableW<C>>() {
129129
public IterableW<C> f(final Iterable<A> a, final Iterable<B> b) {
130130
return IterableW.liftM2(F2.this.curry()).f(a).f(b);
@@ -137,7 +137,7 @@ public IterableW<C> f(final Iterable<A> a, final Iterable<B> b) {
137137
*
138138
* @return This function promoted to transform Lists.
139139
*/
140-
public final F2<List<A>, List<B>, List<C>> listM() {
140+
default public F2<List<A>, List<B>, List<C>> listM() {
141141
return new F2<List<A>, List<B>, List<C>>() {
142142
public List<C> f(final List<A> a, final List<B> b) {
143143
return List.liftM2(F2.this.curry()).f(a).f(b);
@@ -150,7 +150,7 @@ public List<C> f(final List<A> a, final List<B> b) {
150150
*
151151
* @return This function promoted to transform non-empty lists.
152152
*/
153-
public final F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>> nelM() {
153+
default public F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>> nelM() {
154154
return new F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>>() {
155155
public NonEmptyList<C> f(final NonEmptyList<A> as, final NonEmptyList<B> bs) {
156156
return NonEmptyList.fromList(as.toList().bind(bs.toList(), F2.this)).some();
@@ -163,7 +163,7 @@ public NonEmptyList<C> f(final NonEmptyList<A> as, final NonEmptyList<B> bs) {
163163
*
164164
* @return This function promoted to transform Options.
165165
*/
166-
public final F2<Option<A>, Option<B>, Option<C>> optionM() {
166+
default public F2<Option<A>, Option<B>, Option<C>> optionM() {
167167
return new F2<Option<A>, Option<B>, Option<C>>() {
168168
public Option<C> f(final Option<A> a, final Option<B> b) {
169169
return Option.liftM2(F2.this.curry()).f(a).f(b);
@@ -177,7 +177,7 @@ public Option<C> f(final Option<A> a, final Option<B> b) {
177177
* @param o An ordering for the result of the promoted function.
178178
* @return This function promoted to transform Sets.
179179
*/
180-
public final F2<Set<A>, Set<B>, Set<C>> setM(final Ord<C> o) {
180+
default public F2<Set<A>, Set<B>, Set<C>> setM(final Ord<C> o) {
181181
return new F2<Set<A>, Set<B>, Set<C>>() {
182182
public Set<C> f(final Set<A> as, final Set<B> bs) {
183183
Set<C> cs = Set.empty(o);
@@ -194,7 +194,7 @@ public Set<C> f(final Set<A> as, final Set<B> bs) {
194194
*
195195
* @return This function promoted to transform Streams.
196196
*/
197-
public final F2<Stream<A>, Stream<B>, Stream<C>> streamM() {
197+
default public F2<Stream<A>, Stream<B>, Stream<C>> streamM() {
198198
return new F2<Stream<A>, Stream<B>, Stream<C>>() {
199199
public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
200200
return as.bind(bs, F2.this);
@@ -207,7 +207,7 @@ public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
207207
*
208208
* @return This function promoted to transform Trees.
209209
*/
210-
public final F2<Tree<A>, Tree<B>, Tree<C>> treeM() {
210+
default public F2<Tree<A>, Tree<B>, Tree<C>> treeM() {
211211
return new F2<Tree<A>, Tree<B>, Tree<C>>() {
212212
public Tree<C> f(final Tree<A> as, final Tree<B> bs) {
213213
final F2<Tree<A>, Tree<B>, Tree<C>> self = this;
@@ -225,7 +225,7 @@ public Stream<Tree<C>> _1() {
225225
*
226226
* @return A function that zips two arrays with this function.
227227
*/
228-
public final F2<Array<A>, Array<B>, Array<C>> zipArrayM() {
228+
default public F2<Array<A>, Array<B>, Array<C>> zipArrayM() {
229229
return new F2<Array<A>, Array<B>, Array<C>>() {
230230
public Array<C> f(final Array<A> as, final Array<B> bs) {
231231
return as.zipWith(bs, F2.this);
@@ -238,7 +238,7 @@ public Array<C> f(final Array<A> as, final Array<B> bs) {
238238
*
239239
* @return A function that zips two iterables with this function.
240240
*/
241-
public final F2<Iterable<A>, Iterable<B>, Iterable<C>> zipIterableM() {
241+
default public F2<Iterable<A>, Iterable<B>, Iterable<C>> zipIterableM() {
242242
return new F2<Iterable<A>, Iterable<B>, Iterable<C>>() {
243243
public Iterable<C> f(final Iterable<A> as, final Iterable<B> bs) {
244244
return wrap(as).zipWith(bs, F2.this);
@@ -251,7 +251,7 @@ public Iterable<C> f(final Iterable<A> as, final Iterable<B> bs) {
251251
*
252252
* @return A function that zips two lists with this function.
253253
*/
254-
public final F2<List<A>, List<B>, List<C>> zipListM() {
254+
default public F2<List<A>, List<B>, List<C>> zipListM() {
255255
return new F2<List<A>, List<B>, List<C>>() {
256256
public List<C> f(final List<A> as, final List<B> bs) {
257257
return as.zipWith(bs, F2.this);
@@ -265,7 +265,7 @@ public List<C> f(final List<A> as, final List<B> bs) {
265265
*
266266
* @return A function that zips two streams with this function.
267267
*/
268-
public final F2<Stream<A>, Stream<B>, Stream<C>> zipStreamM() {
268+
default public F2<Stream<A>, Stream<B>, Stream<C>> zipStreamM() {
269269
return new F2<Stream<A>, Stream<B>, Stream<C>>() {
270270
public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
271271
return as.zipWith(bs, F2.this);
@@ -278,7 +278,7 @@ public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
278278
*
279279
* @return A function that zips two non-empty lists with this function.
280280
*/
281-
public final F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>> zipNelM() {
281+
default public F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>> zipNelM() {
282282
return new F2<NonEmptyList<A>, NonEmptyList<B>, NonEmptyList<C>>() {
283283
public NonEmptyList<C> f(final NonEmptyList<A> as, final NonEmptyList<B> bs) {
284284
return NonEmptyList.fromList(as.toList().zipWith(bs.toList(), F2.this)).some();
@@ -292,7 +292,7 @@ public NonEmptyList<C> f(final NonEmptyList<A> as, final NonEmptyList<B> bs) {
292292
* @param o An ordering for the resulting set.
293293
* @return A function that zips two sets with this function.
294294
*/
295-
public final F2<Set<A>, Set<B>, Set<C>> zipSetM(final Ord<C> o) {
295+
default public F2<Set<A>, Set<B>, Set<C>> zipSetM(final Ord<C> o) {
296296
return new F2<Set<A>, Set<B>, Set<C>>() {
297297
public Set<C> f(final Set<A> as, final Set<B> bs) {
298298
return iterableSet(o, as.toStream().zipWith(bs.toStream(), F2.this));
@@ -306,7 +306,7 @@ public Set<C> f(final Set<A> as, final Set<B> bs) {
306306
*
307307
* @return A function that zips two trees with this function.
308308
*/
309-
public final F2<Tree<A>, Tree<B>, Tree<C>> zipTreeM() {
309+
default public F2<Tree<A>, Tree<B>, Tree<C>> zipTreeM() {
310310
return new F2<Tree<A>, Tree<B>, Tree<C>>() {
311311
public Tree<C> f(final Tree<A> ta, final Tree<B> tb) {
312312
final F2<Tree<A>, Tree<B>, Tree<C>> self = this;
@@ -325,7 +325,7 @@ public Stream<Tree<C>> _1() {
325325
*
326326
* @return A function that zips two zippers with this function.
327327
*/
328-
public final F2<Zipper<A>, Zipper<B>, Zipper<C>> zipZipperM() {
328+
default public F2<Zipper<A>, Zipper<B>, Zipper<C>> zipZipperM() {
329329
return new F2<Zipper<A>, Zipper<B>, Zipper<C>>() {
330330
@SuppressWarnings({"unchecked"})
331331
public Zipper<C> f(final Zipper<A> ta, final Zipper<B> tb) {
@@ -341,7 +341,7 @@ public Zipper<C> f(final Zipper<A> ta, final Zipper<B> tb) {
341341
*
342342
* @return A function that zips two TreeZippers with this function.
343343
*/
344-
public final F2<TreeZipper<A>, TreeZipper<B>, TreeZipper<C>> zipTreeZipperM() {
344+
default public F2<TreeZipper<A>, TreeZipper<B>, TreeZipper<C>> zipTreeZipperM() {
345345
return new F2<TreeZipper<A>, TreeZipper<B>, TreeZipper<C>>() {
346346
@SuppressWarnings({"unchecked"})
347347
public TreeZipper<C> f(final TreeZipper<A> ta, final TreeZipper<B> tb) {

core/src/main/java/fj/F3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @version %build.number%
88
*/
9-
public abstract class F3<A, B, C, D> {
9+
public interface F3<A, B, C, D> {
1010
/**
1111
* Transform <code>A</code>, <code>B</code> and <code>C</code> to <code>D</code>.
1212
*
@@ -15,5 +15,5 @@ public abstract class F3<A, B, C, D> {
1515
* @param c The <code>C</code> to transform.
1616
* @return The result of the transformation.
1717
*/
18-
public abstract D f(A a, B b, C c);
18+
public D f(A a, B b, C c);
1919
}

core/src/main/java/fj/F4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @version %build.number%
88
*/
9-
public abstract class F4<A, B, C, D, E> {
9+
public interface F4<A, B, C, D, E> {
1010
/**
1111
* Transform <code>A</code>, <code>B</code>, <code>C</code> and <code>D</code> to <code>E</code>.
1212
*
@@ -16,5 +16,5 @@ public abstract class F4<A, B, C, D, E> {
1616
* @param d The <code>D</code> to transform.
1717
* @return The result of the transformation.
1818
*/
19-
public abstract E f(A a, B b, C c, D d);
19+
public E f(A a, B b, C c, D d);
2020
}

core/src/main/java/fj/F5.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @version %build.number%
99
*/
10-
public abstract class F5<A, B, C, D, E, F$> {
10+
public interface F5<A, B, C, D, E, F$> {
1111
/**
1212
* Transform <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code> and <code>E</code> to
1313
* <code>F$</code>.
@@ -19,5 +19,5 @@ public abstract class F5<A, B, C, D, E, F$> {
1919
* @param e The <code>E</code> to transform.
2020
* @return The result of the transformation.
2121
*/
22-
public abstract F$ f(A a, B b, C c, D d, E e);
22+
public F$ f(A a, B b, C c, D d, E e);
2323
}

core/src/main/java/fj/F6.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @version %build.number%
99
*/
10-
public abstract class F6<A, B, C, D, E, F$, G> {
10+
public interface F6<A, B, C, D, E, F$, G> {
1111
/**
1212
* Transform <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>, <code>E</code> and
1313
* <code>F$</code> to <code>G</code>.
@@ -20,5 +20,5 @@ public abstract class F6<A, B, C, D, E, F$, G> {
2020
* @param f The <code>F$</code> to transform.
2121
* @return The result of the transformation.
2222
*/
23-
public abstract G f(A a, B b, C c, D d, E e, F$ f);
23+
public G f(A a, B b, C c, D d, E e, F$ f);
2424
}

core/src/main/java/fj/F7.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @version %build.number%
99
*/
10-
public abstract class F7<A, B, C, D, E, F$, G, H> {
10+
public interface F7<A, B, C, D, E, F$, G, H> {
1111
/**
1212
* Transform <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>, <code>E</code>,
1313
* <code>F$</code> and <code>G</code> to <code>H</code>.
@@ -21,5 +21,5 @@ public abstract class F7<A, B, C, D, E, F$, G, H> {
2121
* @param g The <code>G</code> to transform.
2222
* @return The result of the transformation.
2323
*/
24-
public abstract H f(A a, B b, C c, D d, E e, F$ f, G g);
24+
public H f(A a, B b, C c, D d, E e, F$ f, G g);
2525
}

core/src/main/java/fj/F8.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @version %build.number%
99
*/
10-
public abstract class F8<A, B, C, D, E, F$, G, H, I> {
10+
public interface F8<A, B, C, D, E, F$, G, H, I> {
1111
/**
1212
* Transform <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>, <code>E</code>,
1313
* <code>F$</code>, <code>G</code> and <code>H</code> to <code>I</code>.
@@ -22,5 +22,5 @@ public abstract class F8<A, B, C, D, E, F$, G, H, I> {
2222
* @param h The <code>H</code> to transform.
2323
* @return The result of the transformation.
2424
*/
25-
public abstract I f(A a, B b, C c, D d, E e, F$ f, G g, H h);
25+
public I f(A a, B b, C c, D d, E e, F$ f, G g, H h);
2626
}

0 commit comments

Comments
 (0)