P - The container type.Mu - The witness type for this profunctor.public interface Profunctor<P extends K2,Mu extends Profunctor _> extends Kind2 P
dimap(Function, Function), which transforms a mapping
between types to a mapping between wrapped types.
This type class requires that the container P is contravariant in its first parameter.
| Modifier and Type | Method and Description |
|---|---|
default <A,B,C,D> P<C,D> |
dimap(P<A,B> arg,
(C) -> A g,
(B) -> D h)
Takes an input container, a left mapping from output to input, and a right mapping from input to output,
and returns an output container.
|
<A,B,C,D> (P<A,B>) -> P<C,D> |
dimap((C) -> A g,
(B) -> D h)
Takes a function from the output type
C to the input type A and a function from the input
type B to the output type D, and returns a function from a container of A, B to
a container of C, D. |
default <A,B,C,D> P<C,D> |
dimap(by-name P<A,B> arg,
(C) -> A g,
(B) -> D h)
Takes an input container, a mapping from output to input, and a mapping from input to output, and returns
an output container.
|
default <A,B,C> P<C,B> |
lmap(P<A,B> input,
(C) -> A g)
Maps the first, or left hand, parameter of the given input.
|
default <A,B,D> P<A,D> |
rmap(P<A,B> input,
(B) -> D h)
Maps the second, or left hand, parameter of the given input.
|
<A,B,C,D> (P<A,B>) -> P<C,D> dimap((C) -> A g, (B) -> D h)
C to the input type A and a function from the input
type B to the output type D, and returns a function from a container of A, B to
a container of C, D.
A straightforward example of an implementation of dimap is the method Function.andThen(Function).
For functions, the expression
dimap(g, h).apply(f)
is equivalent to
g.andThen(f).andThen(h)
A - The first input type.B - The second input type.C - The first output type.D - The second output type.g - A function from output to input.h - A function from input to output.dimap(App2, Function, Function)default <A,B,C,D> P<C,D> dimap(P<A,B> arg, (C) -> A g, (B) -> D h)
dimap(g, h).apply(arg).A - The first input type.B - The second input type.C - The first output type.D - The second output type.arg - The input container.g - A function from output to input.h - A function from input to output.dimap(Function, Function)default <A,B,C,D> P<C,D> dimap(by-name P<A,B> arg, (C) -> A g, (B) -> D h)
dimap(arg.get(), g, h).A - The first input type.B - The second input type.C - The first output type.D - The second output type.arg - The input container.g - A function from output to input.h - A function from input to output.dimap(App2, Function, Function),
dimap(Function, Function)default <A,B,C> P<C,B> lmap(P<A,B> input, (C) -> A g)
A - The first input type.B - The second input and output type.C - The first output type.input - The input container.g - The mapping function.dimap(App2, Function, Function)default <A,B,D> P<A,D> rmap(P<A,B> input, (B) -> D h)
A - The first input and output type.B - The second input type.D - The second output type.input - The input container.h - The mapping function.dimap(App2, Function, Function)