Skip to content

Commit 09b3cf6

Browse files
committed
fixing compilation
1 parent 8ffb12d commit 09b3cf6

File tree

2 files changed

+21
-100
lines changed

2 files changed

+21
-100
lines changed

src/main/java/com/jnape/palatable/lambda/Spike.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.jnape.palatable.lambda.structural.Case.of;
2323
import static com.jnape.palatable.lambda.structural.Cases.cases;
2424
import static com.jnape.palatable.lambda.structural.Matcher.$;
25+
import static com.jnape.palatable.lambda.structural.Matcher.__;
2526
import static com.jnape.palatable.lambda.structural.Matchers.$just;
2627
import static com.jnape.palatable.lambda.structural.Matchers.$right;
2728
import static com.jnape.palatable.lambda.structural.Struct.struct;
@@ -126,7 +127,7 @@ public Maybe<Integer> getBaz() {
126127
Foo foo = new Foo();
127128

128129
String match1 = struct(() -> Either.<String, Integer>right(2), () -> "foo")
129-
.match(cases(of($right(1), $(), (x, y) -> x + y),
130+
.match(cases(of($right(1), __(), (x, y) -> x + y),
130131
of($(), $(), (x, y) -> x + y)));
131132

132133
System.out.println(match1);

src/main/java/com/jnape/palatable/lambda/structural/Case.java

Lines changed: 19 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.jnape.palatable.lambda.adt.hlist.Tuple2;
77
import com.jnape.palatable.lambda.adt.hlist.Tuple3;
88
import com.jnape.palatable.lambda.adt.hlist.Tuple4;
9-
<<<<<<< HEAD
109
import com.jnape.palatable.lambda.adt.hlist.Tuple5;
1110
import com.jnape.palatable.lambda.adt.hlist.Tuple6;
1211
import com.jnape.palatable.lambda.adt.hlist.Tuple7;
@@ -19,12 +18,6 @@
1918
import com.jnape.palatable.lambda.functions.Fn7;
2019
import com.jnape.palatable.lambda.functions.Fn8;
2120
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
2821

2922
import java.util.function.BiFunction;
3023
import java.util.function.Function;
@@ -35,62 +28,22 @@
3528
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into1.into1;
3629
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into3.into3;
3730
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into4.into4;
38-
<<<<<<< HEAD
3931
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into5.into5;
4032
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into6.into6;
4133
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into7.into7;
4234
import static com.jnape.palatable.lambda.functions.builtin.fn2.Into8.into8;
43-
=======
44-
>>>>>>> snapshot
4535

4636
public abstract class Case {
4737

4838
private Case() {
4939
}
5040

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-
7841
public static <A, R> Total<SingletonHList<A>, R> of(Function<? super A, ? extends R> fn) {
7942
return new Total<>(into1(fn));
8043
}
8144

8245
public static <A, B, R> Total<Tuple2<A, B>, R> of(BiFunction<? super A, ? super B, ? extends R> fn) {
8346
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));
9447
}
9548

9649
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>,
188141
return Case.<A, B, C, D, E, F, G, H, R>of(fn);
189142
}
190143

191-
192144
public static <A, APrime, R> Partial<SingletonHList<A>, R> of(Matcher<? super A, ? extends APrime> aMatcher,
193145
Function<? super APrime, ? extends R> body) {
194146
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,
225177
.fmap(dPrime -> body.apply(aPrime, bPrime, cPrime, dPrime)))))));
226178
}
227179

228-
229180
public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, E, EPrime, R> Partial<Tuple5<A, B, C, D, E>, R> of(
230181
Matcher<? super A, ? extends APrime> aMatcher,
231182
Matcher<? super B, ? extends BPrime> bMatcher,
@@ -241,7 +192,6 @@ public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, E, EPrime, R> Partial
241192
.fmap(ePrime -> body.apply(aPrime, bPrime, cPrime, dPrime, ePrime))))))));
242193
}
243194

244-
245195
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(
246196
Matcher<? super A, ? extends APrime> aMatcher,
247197
Matcher<? super B, ? extends BPrime> bMatcher,
@@ -291,7 +241,7 @@ public static <A, APrime, B, BPrime, C, CPrime, D, DPrime, E, EPrime, F, FPrime,
291241
.flatMap(fPrime -> gMatcher.match(g)
292242
.flatMap(gPrime -> hMatcher.match(h)
293243
.fmap(hPrime -> body.apply(aPrime, bPrime, cPrime, dPrime, ePrime, fPrime, gPrime, hPrime)))))))))));
294-
=======
244+
295245
}
296246

297247
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(
303253
return new Total<>(into4(fn));
304254
}
305255

256+
public static final class Partial<Fields extends HCons, R> extends Case implements Fn1<Fields, Maybe<R>> {
306257

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;
332259

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+
}
337263

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+
}
342268
}
343269

270+
public static final class Total<Fields extends HCons, R> extends Case implements Fn1<Fields, R> {
271+
private final Function<Fields, R> fn;
344272

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+
}
352276

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+
}
361281
}
362282

363283
}

0 commit comments

Comments
 (0)