Class Exchange<A,B,S,T>
- java.lang.Object
-
- com.jnape.palatable.lambda.functor.builtin.Exchange<A,B,S,T>
-
- Type Parameters:
A- the smaller viewed value of anIsoB- the smaller viewing value of anIsoS- the larger viewing value of anIsoT- the larger viewed value of anIso
- All Implemented Interfaces:
Contravariant<S,Profunctor<?,T,Exchange<A,B,?,?>>>,Profunctor<S,T,Exchange<A,B,?,?>>
public final class Exchange<A,B,S,T> extends java.lang.Object implements Profunctor<S,T,Exchange<A,B,?,?>>
A profunctor used to extract the isomorphic functions anIsois composed of.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Fn1<? super B,? extends T>bt()Extract the mappingB -> T.<Z> Exchange<A,B,Z,T>contraMap(Fn1<? super Z,? extends S> fn)Contravariantly mapA <- B.<Z,C>
Exchange<A,B,Z,C>diMap(Fn1<? super Z,? extends S> lFn, Fn1<? super T,? extends C> rFn)Dually map contravariantly over the left parameter and covariantly over the right parameter.<Z> Exchange<A,B,Z,T>diMapL(Fn1<? super Z,? extends S> fn)Contravariantly map over the left parameter.<C> Exchange<A,B,S,C>diMapR(Fn1<? super T,? extends C> fn)Covariantly map over the right parameter.Fn1<? super S,? extends A>sa()Extract the mappingS -> A.
-
-
-
Method Detail
-
diMap
public <Z,C> Exchange<A,B,Z,C> diMap(Fn1<? super Z,? extends S> lFn, Fn1<? super T,? extends C> rFn)
Dually map contravariantly over the left parameter and covariantly over the right parameter. This is isomorphic todiMapL(lFn).diMapR(rFn).- Specified by:
diMapin interfaceProfunctor<A,B,S>- Type Parameters:
Z- the new left parameter typeC- the new right parameter type- Parameters:
lFn- the left parameter mapping functionrFn- the right parameter mapping function- Returns:
- a profunctor over Z (the new left parameter type) and C (the new right parameter type)
-
diMapL
public <Z> Exchange<A,B,Z,T> diMapL(Fn1<? super Z,? extends S> fn)
Contravariantly map over the left parameter.- Specified by:
diMapLin interfaceProfunctor<A,B,S>- Type Parameters:
Z- the new left parameter type- Parameters:
fn- the mapping function- Returns:
- a profunctor over Z (the new left parameter type) and C (the same right parameter type)
-
diMapR
public <C> Exchange<A,B,S,C> diMapR(Fn1<? super T,? extends C> fn)
Covariantly map over the right parameter. For all profunctors that are also functors, it should hold thatdiMapR(f) == fmap(f).- Specified by:
diMapRin interfaceProfunctor<A,B,S>- Type Parameters:
C- the new right parameter type- Parameters:
fn- the mapping function- Returns:
- a profunctor over A (the same left parameter type) and C (the new right parameter type)
-
contraMap
public <Z> Exchange<A,B,Z,T> contraMap(Fn1<? super Z,? extends S> fn)
Contravariantly mapA <- B.- Specified by:
contraMapin interfaceContravariant<A,B>- Specified by:
contraMapin interfaceProfunctor<A,B,S>- Type Parameters:
Z- the new parameter type- Parameters:
fn- the mapping function- Returns:
- the mapped Contravariant functor instance
-
-