|
1 | 1 | package com.jnape.palatable.lambda.optics.functions; |
2 | 2 |
|
3 | 3 | import com.jnape.palatable.lambda.functions.Fn1; |
| 4 | +import com.jnape.palatable.lambda.functor.Profunctor; |
4 | 5 | import com.jnape.palatable.lambda.functor.builtin.Const; |
5 | 6 | import com.jnape.palatable.lambda.functor.builtin.Identity; |
6 | 7 | import com.jnape.palatable.lambda.functor.builtin.Tagged; |
|
18 | 19 | * @param <B> the value to read from |
19 | 20 | */ |
20 | 21 | public final class Re<S, T, A, B> implements |
21 | | - Fn1<Optic<? super Tagged<?, ?>, ? super Identity<?>, S, T, A, B>, Optic<Fn1<?, ?>, Const<T, ?>, B, B, T, T>> { |
| 22 | + Fn1<Optic<? super Tagged<?, ?>, ? super Identity<?>, S, T, A, B>, |
| 23 | + Optic<Profunctor<?, ?, ?>, Const<T, ?>, B, B, T, T>> { |
22 | 24 |
|
23 | 25 | private static final Re<?, ?, ?, ?> INSTANCE = new Re<>(); |
24 | 26 |
|
25 | 27 | private Re() { |
26 | 28 | } |
27 | 29 |
|
28 | 30 | @Override |
29 | | - public Optic<Fn1<?, ?>, Const<T, ?>, B, B, T, T> checkedApply( |
| 31 | + public Optic<Profunctor<?, ?, ?>, Const<T, ?>, B, B, T, T> checkedApply( |
30 | 32 | Optic<? super Tagged<?, ?>, ? super Identity<?>, S, T, A, B> optic) { |
31 | | - return Optic.<Fn1<?, ?>, Const<T, ?>, B, B, T, T, |
| 33 | + return Optic.<Profunctor<?, ?, ?>, Const<T, ?>, B, B, T, T, |
32 | 34 | Const<T, T>, Const<T, B>, |
33 | | - Fn1<T, Const<T, T>>, |
34 | | - Fn1<B, Const<T, B>>>optic(pafb -> b -> new Const<>(optic.<Tagged<?, ?>, Identity<?>, Identity<B>, |
35 | | - Identity<T>, Tagged<A, Identity<B>>, |
36 | | - Tagged<S, Identity<T>>>apply(new Tagged<>(new Identity<>(b))).unTagged().runIdentity())); |
| 35 | + Profunctor<T, Const<T, T>, ? extends Profunctor<?, ?, ?>>, |
| 36 | + Profunctor<B, Const<T, B>, ? extends Profunctor<?, ?, ?>>>optic( |
| 37 | + pafb -> pafb.diMap( |
| 38 | + b -> optic.<Tagged<?, ?>, Identity<?>, Identity<B>, Identity<T>, |
| 39 | + Tagged<A, Identity<B>>, Tagged<S, Identity<T>>>apply( |
| 40 | + new Tagged<>(new Identity<>(b))).unTagged().runIdentity(), |
| 41 | + fb -> new Const<>(fb.runConst()))); |
37 | 42 | } |
38 | 43 |
|
39 | 44 | @SuppressWarnings("unchecked") |
40 | 45 | public static <S, T, A, B> Re<S, T, A, B> re() { |
41 | 46 | return (Re<S, T, A, B>) INSTANCE; |
42 | 47 | } |
43 | 48 |
|
44 | | - public static <S, T, A, B> Optic<Fn1<?, ?>, Const<T, ?>, B, B, T, T> re( |
| 49 | + public static <S, T, A, B> Optic<Profunctor<?, ?, ?>, Const<T, ?>, B, B, T, T> re( |
45 | 50 | Optic<? super Tagged<?, ?>, ? super Identity<?>, S, T, A, B> optic) { |
46 | 51 | return Re.<S, T, A, B>re().apply(optic); |
47 | 52 | } |
|
0 commit comments