25
25
*
26
26
* @version %build.number%
27
27
*/
28
- public abstract class F2 <A , B , C > {
28
+ public interface F2 <A , B , C > {
29
29
/**
30
30
* Transform <code>A</code> and <code>B</code> to <code>C</code>.
31
31
*
32
32
* @param a The <code>A</code> to transform.
33
33
* @param b The <code>B</code> to transform.
34
34
* @return The result of the transformation.
35
35
*/
36
- public abstract C f (A a , B b );
36
+ public C f (A a , B b );
37
37
38
38
39
39
/**
@@ -42,7 +42,7 @@ public abstract class F2<A, B, C> {
42
42
* @param a The <code>A</code> to which to apply this function.
43
43
* @return The function partially applied to the given argument.
44
44
*/
45
- public final F <B , C > f (final A a ) {
45
+ default public F <B , C > f (final A a ) {
46
46
return new F <B , C >() {
47
47
public C f (final B b ) {
48
48
return F2 .this .f (a , b );
@@ -55,7 +55,7 @@ public C f(final B b) {
55
55
*
56
56
* @return a wrapped function of arity-1 that returns another wrapped function.
57
57
*/
58
- public final F <A , F <B , C >> curry () {
58
+ default public F <A , F <B , C >> curry () {
59
59
return new F <A , F <B , C >>() {
60
60
public F <B , C > f (final A a ) {
61
61
return new F <B , C >() {
@@ -72,7 +72,7 @@ public C f(final B b) {
72
72
*
73
73
* @return A new function with the arguments of this function flipped.
74
74
*/
75
- public final F2 <B , A , C > flip () {
75
+ default public F2 <B , A , C > flip () {
76
76
return new F2 <B , A , C >() {
77
77
public C f (final B b , final A a ) {
78
78
return F2 .this .f (a , b );
@@ -85,7 +85,7 @@ public C f(final B b, final A a) {
85
85
*
86
86
* @return A new function that calls this function with the elements of a given tuple.
87
87
*/
88
- public final F <P2 <A , B >, C > tuple () {
88
+ default public F <P2 <A , B >, C > tuple () {
89
89
return new F <P2 <A , B >, C >() {
90
90
public C f (final P2 <A , B > p ) {
91
91
return F2 .this .f (p ._1 (), p ._2 ());
@@ -98,7 +98,7 @@ public C f(final P2<A, B> p) {
98
98
*
99
99
* @return This function promoted to transform Arrays.
100
100
*/
101
- public final F2 <Array <A >, Array <B >, Array <C >> arrayM () {
101
+ default public F2 <Array <A >, Array <B >, Array <C >> arrayM () {
102
102
return new F2 <Array <A >, Array <B >, Array <C >>() {
103
103
public Array <C > f (final Array <A > a , final Array <B > b ) {
104
104
return a .bind (b , F2 .this .curry ());
@@ -111,7 +111,7 @@ public Array<C> f(final Array<A> a, final Array<B> b) {
111
111
*
112
112
* @return This function promoted to transform Promises.
113
113
*/
114
- public final F2 <Promise <A >, Promise <B >, Promise <C >> promiseM () {
114
+ default public F2 <Promise <A >, Promise <B >, Promise <C >> promiseM () {
115
115
return new F2 <Promise <A >, Promise <B >, Promise <C >>() {
116
116
public Promise <C > f (final Promise <A > a , final Promise <B > b ) {
117
117
return a .bind (b , F2 .this .curry ());
@@ -124,7 +124,7 @@ public Promise<C> f(final Promise<A> a, final Promise<B> b) {
124
124
*
125
125
* @return This function promoted to transform Iterables.
126
126
*/
127
- public final F2 <Iterable <A >, Iterable <B >, IterableW <C >> iterableM () {
127
+ default public F2 <Iterable <A >, Iterable <B >, IterableW <C >> iterableM () {
128
128
return new F2 <Iterable <A >, Iterable <B >, IterableW <C >>() {
129
129
public IterableW <C > f (final Iterable <A > a , final Iterable <B > b ) {
130
130
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) {
137
137
*
138
138
* @return This function promoted to transform Lists.
139
139
*/
140
- public final F2 <List <A >, List <B >, List <C >> listM () {
140
+ default public F2 <List <A >, List <B >, List <C >> listM () {
141
141
return new F2 <List <A >, List <B >, List <C >>() {
142
142
public List <C > f (final List <A > a , final List <B > b ) {
143
143
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) {
150
150
*
151
151
* @return This function promoted to transform non-empty lists.
152
152
*/
153
- public final F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >> nelM () {
153
+ default public F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >> nelM () {
154
154
return new F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >>() {
155
155
public NonEmptyList <C > f (final NonEmptyList <A > as , final NonEmptyList <B > bs ) {
156
156
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) {
163
163
*
164
164
* @return This function promoted to transform Options.
165
165
*/
166
- public final F2 <Option <A >, Option <B >, Option <C >> optionM () {
166
+ default public F2 <Option <A >, Option <B >, Option <C >> optionM () {
167
167
return new F2 <Option <A >, Option <B >, Option <C >>() {
168
168
public Option <C > f (final Option <A > a , final Option <B > b ) {
169
169
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) {
177
177
* @param o An ordering for the result of the promoted function.
178
178
* @return This function promoted to transform Sets.
179
179
*/
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 ) {
181
181
return new F2 <Set <A >, Set <B >, Set <C >>() {
182
182
public Set <C > f (final Set <A > as , final Set <B > bs ) {
183
183
Set <C > cs = Set .empty (o );
@@ -194,7 +194,7 @@ public Set<C> f(final Set<A> as, final Set<B> bs) {
194
194
*
195
195
* @return This function promoted to transform Streams.
196
196
*/
197
- public final F2 <Stream <A >, Stream <B >, Stream <C >> streamM () {
197
+ default public F2 <Stream <A >, Stream <B >, Stream <C >> streamM () {
198
198
return new F2 <Stream <A >, Stream <B >, Stream <C >>() {
199
199
public Stream <C > f (final Stream <A > as , final Stream <B > bs ) {
200
200
return as .bind (bs , F2 .this );
@@ -207,7 +207,7 @@ public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
207
207
*
208
208
* @return This function promoted to transform Trees.
209
209
*/
210
- public final F2 <Tree <A >, Tree <B >, Tree <C >> treeM () {
210
+ default public F2 <Tree <A >, Tree <B >, Tree <C >> treeM () {
211
211
return new F2 <Tree <A >, Tree <B >, Tree <C >>() {
212
212
public Tree <C > f (final Tree <A > as , final Tree <B > bs ) {
213
213
final F2 <Tree <A >, Tree <B >, Tree <C >> self = this ;
@@ -225,7 +225,7 @@ public Stream<Tree<C>> _1() {
225
225
*
226
226
* @return A function that zips two arrays with this function.
227
227
*/
228
- public final F2 <Array <A >, Array <B >, Array <C >> zipArrayM () {
228
+ default public F2 <Array <A >, Array <B >, Array <C >> zipArrayM () {
229
229
return new F2 <Array <A >, Array <B >, Array <C >>() {
230
230
public Array <C > f (final Array <A > as , final Array <B > bs ) {
231
231
return as .zipWith (bs , F2 .this );
@@ -238,7 +238,7 @@ public Array<C> f(final Array<A> as, final Array<B> bs) {
238
238
*
239
239
* @return A function that zips two iterables with this function.
240
240
*/
241
- public final F2 <Iterable <A >, Iterable <B >, Iterable <C >> zipIterableM () {
241
+ default public F2 <Iterable <A >, Iterable <B >, Iterable <C >> zipIterableM () {
242
242
return new F2 <Iterable <A >, Iterable <B >, Iterable <C >>() {
243
243
public Iterable <C > f (final Iterable <A > as , final Iterable <B > bs ) {
244
244
return wrap (as ).zipWith (bs , F2 .this );
@@ -251,7 +251,7 @@ public Iterable<C> f(final Iterable<A> as, final Iterable<B> bs) {
251
251
*
252
252
* @return A function that zips two lists with this function.
253
253
*/
254
- public final F2 <List <A >, List <B >, List <C >> zipListM () {
254
+ default public F2 <List <A >, List <B >, List <C >> zipListM () {
255
255
return new F2 <List <A >, List <B >, List <C >>() {
256
256
public List <C > f (final List <A > as , final List <B > bs ) {
257
257
return as .zipWith (bs , F2 .this );
@@ -265,7 +265,7 @@ public List<C> f(final List<A> as, final List<B> bs) {
265
265
*
266
266
* @return A function that zips two streams with this function.
267
267
*/
268
- public final F2 <Stream <A >, Stream <B >, Stream <C >> zipStreamM () {
268
+ default public F2 <Stream <A >, Stream <B >, Stream <C >> zipStreamM () {
269
269
return new F2 <Stream <A >, Stream <B >, Stream <C >>() {
270
270
public Stream <C > f (final Stream <A > as , final Stream <B > bs ) {
271
271
return as .zipWith (bs , F2 .this );
@@ -278,7 +278,7 @@ public Stream<C> f(final Stream<A> as, final Stream<B> bs) {
278
278
*
279
279
* @return A function that zips two non-empty lists with this function.
280
280
*/
281
- public final F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >> zipNelM () {
281
+ default public F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >> zipNelM () {
282
282
return new F2 <NonEmptyList <A >, NonEmptyList <B >, NonEmptyList <C >>() {
283
283
public NonEmptyList <C > f (final NonEmptyList <A > as , final NonEmptyList <B > bs ) {
284
284
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) {
292
292
* @param o An ordering for the resulting set.
293
293
* @return A function that zips two sets with this function.
294
294
*/
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 ) {
296
296
return new F2 <Set <A >, Set <B >, Set <C >>() {
297
297
public Set <C > f (final Set <A > as , final Set <B > bs ) {
298
298
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) {
306
306
*
307
307
* @return A function that zips two trees with this function.
308
308
*/
309
- public final F2 <Tree <A >, Tree <B >, Tree <C >> zipTreeM () {
309
+ default public F2 <Tree <A >, Tree <B >, Tree <C >> zipTreeM () {
310
310
return new F2 <Tree <A >, Tree <B >, Tree <C >>() {
311
311
public Tree <C > f (final Tree <A > ta , final Tree <B > tb ) {
312
312
final F2 <Tree <A >, Tree <B >, Tree <C >> self = this ;
@@ -325,7 +325,7 @@ public Stream<Tree<C>> _1() {
325
325
*
326
326
* @return A function that zips two zippers with this function.
327
327
*/
328
- public final F2 <Zipper <A >, Zipper <B >, Zipper <C >> zipZipperM () {
328
+ default public F2 <Zipper <A >, Zipper <B >, Zipper <C >> zipZipperM () {
329
329
return new F2 <Zipper <A >, Zipper <B >, Zipper <C >>() {
330
330
@ SuppressWarnings ({"unchecked" })
331
331
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) {
341
341
*
342
342
* @return A function that zips two TreeZippers with this function.
343
343
*/
344
- public final F2 <TreeZipper <A >, TreeZipper <B >, TreeZipper <C >> zipTreeZipperM () {
344
+ default public F2 <TreeZipper <A >, TreeZipper <B >, TreeZipper <C >> zipTreeZipperM () {
345
345
return new F2 <TreeZipper <A >, TreeZipper <B >, TreeZipper <C >>() {
346
346
@ SuppressWarnings ({"unchecked" })
347
347
public TreeZipper <C > f (final TreeZipper <A > ta , final TreeZipper <B > tb ) {
0 commit comments