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 an Iso
B - the smaller viewing value of an Iso
S - the larger viewing value of an Iso
T - the larger viewed value of an Iso
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 Object implements Profunctor<S, T, Exchange<A,B,?,?>>
A profunctor used to extract the isomorphic functions an Iso is composed of.
  • Constructor Details

    • Exchange

      public Exchange(Fn1<? super S, ? extends A> sa, Fn1<? super B, ? extends T> bt)
  • Method Details

    • sa

      public Fn1<? super S, ? extends A> sa()
      Extract the mapping S -> A.
      Returns:
      an Fn1<S, A>
    • bt

      public Fn1<? super B, ? extends T> bt()
      Extract the mapping B -> T.
      Returns:
      an Fn1<B, T>
    • 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 to diMapL(lFn).diMapR(rFn).
      Specified by:
      diMap in interface Profunctor<A,B,S>
      Type Parameters:
      Z - the new left parameter type
      C - the new right parameter type
      Parameters:
      lFn - the left parameter mapping function
      rFn - 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:
      diMapL in interface Profunctor<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 that diMapR(f) == fmap(f).
      Specified by:
      diMapR in interface Profunctor<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 map A <- B.
      Specified by:
      contraMap in interface Contravariant<A,B>
      Specified by:
      contraMap in interface Profunctor<A,B,S>
      Type Parameters:
      Z - the new parameter type
      Parameters:
      fn - the mapping function
      Returns:
      the mapped Contravariant functor instance