Skip to content

Commit d2bd8cb

Browse files
committed
Added F1Functions#dimap (profunctor pattern)
1 parent a506f06 commit d2bd8cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/java/fj/F1Functions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,11 @@ public static <A, B, C> F<C, B> contramap(F<A, B> target, F<C, A> f) {
677677
return andThen(f, target);
678678
}
679679

680+
/**
681+
* Both map (with g) and contramap (with f) the target function. (Profunctor pattern)
682+
*/
683+
public static <A, B, C, D> F<C, D> dimap(F<A, B> target, F<C, A> f, F<B, D> g) {
684+
return c -> g.f(target.f(f.f(c)));
685+
}
686+
680687
}

0 commit comments

Comments
 (0)