6
6
import com .jnape .palatable .lambda .adt .hlist .Tuple2 ;
7
7
import com .jnape .palatable .lambda .adt .hlist .Tuple3 ;
8
8
import com .jnape .palatable .lambda .adt .hlist .Tuple4 ;
9
- <<<<<<< HEAD
10
9
import com .jnape .palatable .lambda .adt .hlist .Tuple5 ;
11
10
import com .jnape .palatable .lambda .adt .hlist .Tuple6 ;
12
11
import com .jnape .palatable .lambda .adt .hlist .Tuple7 ;
19
18
import com .jnape .palatable .lambda .functions .Fn7 ;
20
19
import com .jnape .palatable .lambda .functions .Fn8 ;
21
20
import com .jnape .palatable .lambda .structural .Matcher .Any ;
22
- =======
23
- import com .jnape .palatable .lambda .functions .Fn1 ;
24
- import com .jnape .palatable .lambda .functions .Fn3 ;
25
- import com .jnape .palatable .lambda .functions .Fn4 ;
26
- import com .jnape .palatable .lambda .functions .specialized .Predicate ;
27
- >>>>>>> snapshot
28
21
29
22
import java .util .function .BiFunction ;
30
23
import java .util .function .Function ;
35
28
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into1 .into1 ;
36
29
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into3 .into3 ;
37
30
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into4 .into4 ;
38
- <<<<<<< HEAD
39
31
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into5 .into5 ;
40
32
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into6 .into6 ;
41
33
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into7 .into7 ;
42
34
import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into8 .into8 ;
43
- =======
44
- >>>>>>> snapshot
45
35
46
36
public abstract class Case {
47
37
48
38
private Case () {
49
39
}
50
40
51
- public static final class Partial <Fields extends HCons , R > extends Case implements Fn1 <Fields , Maybe <R >> {
52
-
53
- private final Function <Fields , Maybe <R >> fn ;
54
-
55
- private Partial (Function <Fields , Maybe <R >> fn ) {
56
- this .fn = fn ;
57
- }
58
-
59
- @ Override
60
- public Maybe <R > apply (Fields fields ) {
61
- return just (fields ).flatMap (fn );
62
- }
63
- }
64
-
65
- public static final class Total <Fields extends HCons , R > extends Case implements Fn1 <Fields , R > {
66
- private final Function <Fields , R > fn ;
67
-
68
- private Total (Function <Fields , R > fn ) {
69
- this .fn = fn ;
70
- }
71
-
72
- @ Override
73
- public R apply (Fields fields ) {
74
- return fn .apply (fields );
75
- }
76
- }
77
-
78
41
public static <A , R > Total <SingletonHList <A >, R > of (Function <? super A , ? extends R > fn ) {
79
42
return new Total <>(into1 (fn ));
80
43
}
81
44
82
45
public static <A , B , R > Total <Tuple2 <A , B >, R > of (BiFunction <? super A , ? super B , ? extends R > fn ) {
83
46
return new Total <>(into (fn ));
84
- <<<<<<< HEAD
85
- }
86
-
87
- public static <A , B , C , R > Total <Tuple3 <A , B , C >, R > of (Fn3 <? super A , ? super B , ? super C , ? extends R > fn ) {
88
- return new Total <>(into3 (fn ));
89
- }
90
-
91
- public static <A , B , C , D , R > Total <Tuple4 <A , B , C , D >, R > of (
92
- Fn4 <? super A , ? super B , ? super C , ? super D , ? extends R > fn ) {
93
- return new Total <>(into4 (fn ));
94
47
}
95
48
96
49
public static <A , B , C , D , E , R > Total <Tuple5 <A , B , C , D , E >, R > of (
@@ -188,7 +141,6 @@ public static <A, B, C, D, E, F, G, H, R> Total<Tuple8<A, B, C, D, E, F, G, H>,
188
141
return Case .<A , B , C , D , E , F , G , H , R >of (fn );
189
142
}
190
143
191
-
192
144
public static <A , APrime , R > Partial <SingletonHList <A >, R > of (Matcher <? super A , ? extends APrime > aMatcher ,
193
145
Function <? super APrime , ? extends R > body ) {
194
146
return new Partial <>(into1 (a -> aMatcher .match (a ).fmap (body )));
@@ -225,7 +177,6 @@ public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, R> Partial<Tuple4<A,
225
177
.fmap (dPrime -> body .apply (aPrime , bPrime , cPrime , dPrime )))))));
226
178
}
227
179
228
-
229
180
public static <A , APrime , B , BPrime , C , CPrime , D , DPrime , E , EPrime , R > Partial <Tuple5 <A , B , C , D , E >, R > of (
230
181
Matcher <? super A , ? extends APrime > aMatcher ,
231
182
Matcher <? super B , ? extends BPrime > bMatcher ,
@@ -241,7 +192,6 @@ public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, E, EPrime, R> Partial
241
192
.fmap (ePrime -> body .apply (aPrime , bPrime , cPrime , dPrime , ePrime ))))))));
242
193
}
243
194
244
-
245
195
public static <A , APrime , B , BPrime , C , CPrime , D , DPrime , E , EPrime , F , FPrime , R > Partial <Tuple6 <A , B , C , D , E , F >, R > of (
246
196
Matcher <? super A , ? extends APrime > aMatcher ,
247
197
Matcher <? super B , ? extends BPrime > bMatcher ,
@@ -291,7 +241,7 @@ public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, E, EPrime, F, FPrime,
291
241
.flatMap (fPrime -> gMatcher .match (g )
292
242
.flatMap (gPrime -> hMatcher .match (h )
293
243
.fmap (hPrime -> body .apply (aPrime , bPrime , cPrime , dPrime , ePrime , fPrime , gPrime , hPrime )))))))))));
294
- =======
244
+
295
245
}
296
246
297
247
public static <A , B , C , R > Total <Tuple3 <A , B , C >, R > of (Fn3 <? super A , ? super B , ? super C , ? extends R > fn ) {
@@ -303,61 +253,31 @@ public static <A, B, C, D, R> Total<Tuple4<A, B, C, D>, R> of(
303
253
return new Total <>(into4 (fn ));
304
254
}
305
255
256
+ public static final class Partial <Fields extends HCons , R > extends Case implements Fn1 <Fields , Maybe <R >> {
306
257
307
- public static <A , R > Total <SingletonHList <A >, R > of (CatchAll __ , Function <? super A , ? extends R > fn ) {
308
- return of (fn );
309
- }
310
-
311
- public static <A , B , R > Total <Tuple2 <A , B >, R > of (CatchAll __ ,
312
- CatchAll ___ ,
313
- BiFunction <? super A , ? super B , ? extends R > fn ) {
314
- return of (fn );
315
- }
316
-
317
- public static <A , B , C , R > Total <Tuple3 <A , B , C >, R > of (CatchAll __ ,
318
- CatchAll ___ ,
319
- CatchAll ____ ,
320
- Fn3 <? super A , ? super B , ? super C , ? extends R > fn ) {
321
- return Case .<A , B , C , R >of (fn );
322
- }
323
-
324
- public static <A , B , C , D , R > Total <Tuple4 <A , B , C , D >, R > of (CatchAll __ ,
325
- CatchAll ___ ,
326
- CatchAll ____ ,
327
- CatchAll _____ ,
328
- Fn4 <? super A , ? super B , ? super C , ? super D , ? extends R > fn ) {
329
- return Case .<A , B , C , D , R >of (fn );
330
- }
331
-
258
+ private final Function <Fields , Maybe <R >> fn ;
332
259
333
- public static <A , R > Partial <SingletonHList <A >, R > of (Predicate <A > pred ,
334
- Fn1 <A , R > fn ) {
335
- return new Partial <>(pred .contraMap (HCons ::head ), into1 (fn ));
336
- }
260
+ private Partial (Function <Fields , Maybe <R >> fn ) {
261
+ this .fn = fn ;
262
+ }
337
263
338
- public static < A , B , R > Partial < Tuple2 < A , B >, R > of ( Predicate <? super A > aPredicate ,
339
- Predicate <? super B > bPredicate ,
340
- BiFunction <? super A , ? super B , ? extends R > fn ) {
341
- return new Partial <>( t -> aPredicate . test ( t . _1 ()) && bPredicate . test ( t . _2 ()), into ( fn ));
264
+ @ Override
265
+ public Maybe < R > apply ( Fields fields ) {
266
+ return just ( fields ). flatMap ( fn );
267
+ }
342
268
}
343
269
270
+ public static final class Total <Fields extends HCons , R > extends Case implements Fn1 <Fields , R > {
271
+ private final Function <Fields , R > fn ;
344
272
345
- public static <A , B , C , R > Partial <Tuple3 <A , B , C >, R > of (Predicate <? super A > aPredicate ,
346
- Predicate <? super B > bPredicate ,
347
- Predicate <? super C > cPredicate ,
348
- Fn3 <? super A , ? super B , ? super C , ? extends R > fn ) {
349
- return new Partial <>(t -> aPredicate .test (t ._1 ()) && bPredicate .test (t ._2 ()) && cPredicate .test (t ._3 ()),
350
- into3 (fn ));
351
- }
273
+ private Total (Function <Fields , R > fn ) {
274
+ this .fn = fn ;
275
+ }
352
276
353
- public static <A , B , C , D , R > Partial <Tuple4 <A , B , C , D >, R > of (Predicate <? super A > aPredicate ,
354
- Predicate <? super B > bPredicate ,
355
- Predicate <? super C > cPredicate ,
356
- Predicate <? super D > dPredicate ,
357
- Fn4 <? super A , ? super B , ? super C , ? super D , ? extends R > fn ) {
358
- return new Partial <>(t -> aPredicate .test (t ._1 ()) && bPredicate .test (t ._2 ()) && cPredicate .test (t ._3 ()) && dPredicate .test (t ._4 ()),
359
- into4 (fn ));
360
- >>>>>>> snapshot
277
+ @ Override
278
+ public R apply (Fields fields ) {
279
+ return fn .apply (fields );
280
+ }
361
281
}
362
282
363
283
}
0 commit comments