Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb51e93f

Browse files
committed
adding unification parameter to Profunctor
1 parentb3306e4 commitb51e93f

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

‎src/main/java/com/jnape/palatable/lambda/functions/Fn1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @param <B> The result type
1414
*/
1515
@FunctionalInterface
16-
publicinterfaceFn1<A,B>extendsFunctor<B,Fn1<A, ?>>,Profunctor<A,B>,Function<A,B> {
16+
publicinterfaceFn1<A,B>extendsFunctor<B,Fn1<A, ?>>,Profunctor<A,B,Fn1>,Function<A,B> {
1717

1818
/**
1919
* Invoke this function with the given argument.

‎src/main/java/com/jnape/palatable/lambda/functor/Profunctor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @see Fn1
2020
*/
2121
@FunctionalInterface
22-
publicinterfaceProfunctor<A,B> {
22+
publicinterfaceProfunctor<A,B,PFextendsProfunctor> {
2323

2424
/**
2525
* Contravariantly map over the left parameter.
@@ -28,7 +28,7 @@ public interface Profunctor<A, B> {
2828
* @param fn the mapping function
2929
* @return a profunctor over Z (the new left parameter type) and C (the same right parameter type)
3030
*/
31-
default <Z>Profunctor<Z,B>diMapL(Function<Z,A>fn) {
31+
default <Z>Profunctor<Z,B,PF>diMapL(Function<Z,A>fn) {
3232
returndiMap(fn,id());
3333
}
3434

@@ -40,7 +40,7 @@ default <Z> Profunctor<Z, B> diMapL(Function<Z, A> fn) {
4040
* @param fn the mapping function
4141
* @return a profunctor over A (the same left parameter type) and C (the new right parameter type)
4242
*/
43-
default <C>Profunctor<A,C>diMapR(Function<B,C>fn) {
43+
default <C>Profunctor<A,C,PF>diMapR(Function<B,C>fn) {
4444
returndiMap(id(),fn);
4545
}
4646

@@ -54,5 +54,5 @@ default <C> Profunctor<A, C> diMapR(Function<B, C> fn) {
5454
* @param rFn the right parameter mapping function
5555
* @return a profunctor over Z (the new left parameter type) and C (the new right parameter type)
5656
*/
57-
<Z,C>Profunctor<Z,C>diMap(Function<Z,A>lFn,Function<B,C>rFn);
57+
<Z,C>Profunctor<Z,C,PF>diMap(Function<Z,A>lFn,Function<B,C>rFn);
5858
}

‎src/test/java/com/jnape/palatable/lambda/functor/ProfunctorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public class ProfunctorTest {
1515
@Test
1616
publicvoiddiMapLUsesIdentityForRightDiMapFunction() {
1717
AtomicReference<Function>rightInvocation =newAtomicReference<>();
18-
Profunctor<String,Integer>profunctor =newInvocationRecordingProfunctor<>(newAtomicReference<>(),rightInvocation);
18+
Profunctor<String,Integer,InvocationRecordingProfunctor>profunctor =newInvocationRecordingProfunctor<>(newAtomicReference<>(),rightInvocation);
1919
profunctor.diMapL(Object::toString);
2020
assertThat(rightInvocation.get(),is(id()));
2121
}
2222

2323
@Test
2424
publicvoiddiMapRUsesIdentityForLeftDiMapFunction() {
2525
AtomicReference<Function>leftInvocation =newAtomicReference<>();
26-
Profunctor<String,Integer>profunctor =newInvocationRecordingProfunctor<>(leftInvocation,newAtomicReference<>());
26+
Profunctor<String,Integer,InvocationRecordingProfunctor>profunctor =newInvocationRecordingProfunctor<>(leftInvocation,newAtomicReference<>());
2727
profunctor.diMapR(String::valueOf);
2828
assertThat(leftInvocation.get(),is(id()));
2929
}

‎src/test/java/testsupport/applicatives/InvocationRecordingProfunctor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
importjava.util.concurrent.atomic.AtomicReference;
66
importjava.util.function.Function;
77

8-
publicfinalclassInvocationRecordingProfunctor<A,B>implementsProfunctor<A,B> {
8+
publicfinalclassInvocationRecordingProfunctor<A,B>implementsProfunctor<A,B,InvocationRecordingProfunctor> {
99
privatefinalAtomicReference<Function>leftFn;
1010
privatefinalAtomicReference<Function>rightFn;
1111

@@ -17,9 +17,9 @@ public InvocationRecordingProfunctor(AtomicReference<Function> leftFn,
1717

1818
@Override
1919
@SuppressWarnings("unchecked")
20-
public <C,D>Profunctor<C,D>diMap(Function<C,A>lFn,Function<B,D>rFn) {
20+
public <C,D>InvocationRecordingProfunctor<C,D>diMap(Function<C,A>lFn,Function<B,D>rFn) {
2121
leftFn.set(lFn);
2222
rightFn.set(rFn);
23-
return (Profunctor<C,D>)this;
23+
return (InvocationRecordingProfunctor<C,D>)this;
2424
}
2525
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp