|
3 | 3 | import com.jnape.palatable.lambda.functions.Fn2; |
4 | 4 | import com.jnape.palatable.lambda.functor.Applicative; |
5 | 5 | import com.jnape.palatable.lambda.functor.Functor; |
| 6 | +import com.jnape.palatable.lambda.functor.Profunctor; |
6 | 7 |
|
7 | 8 | import java.util.function.BiFunction; |
8 | 9 | import java.util.function.Function; |
|
133 | 134 | * @param <B> the type of the "smaller" update value |
134 | 135 | */ |
135 | 136 | @FunctionalInterface |
136 | | -public interface Lens<S, T, A, B> extends Applicative<T, Lens<S, ?, A, B>> { |
| 137 | +public interface Lens<S, T, A, B> extends Applicative<T, Lens<S, ?, A, B>>, Profunctor<S, T, Lens<?, ?, A, B>> { |
137 | 138 |
|
138 | 139 | <F extends Functor, FT extends Functor<T, F>, FB extends Functor<B, F>> FT apply( |
139 | 140 | Function<? super A, ? extends FB> fn, S s); |
@@ -179,6 +180,11 @@ default <U> Lens<S, T, A, B> discardR(Applicative<U, Lens<S, ?, A, B>> appB) { |
179 | 180 | return Applicative.super.discardR(appB).coerce(); |
180 | 181 | } |
181 | 182 |
|
| 183 | + @Override |
| 184 | + default <R, U> Lens<R, U, A, B> diMap(Function<R, S> lFn, Function<T, U> rFn) { |
| 185 | + return mapS(lFn).mapT(rFn); |
| 186 | + } |
| 187 | + |
182 | 188 | /** |
183 | 189 | * Contravariantly map <code>S</code> to <code>R</code>, yielding a new lens. |
184 | 190 | * |
|
0 commit comments