Interface Optic<P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B>

  • Type Parameters:
    P - the Profunctor bound
    F - the Functor bound
    S - the left side of the output profunctor
    T - the right side's functor embedding of the output profunctor
    A - the left side of the input profunctor
    B - the right side's functor embedding of the input profunctor
    All Known Subinterfaces:
    Iso<S,​T,​A,​B>, Iso.Simple<S,​A>, Lens<S,​T,​A,​B>, Lens.Simple<S,​A>, Optic.Simple<P,​F,​S,​A>, Prism<S,​T,​A,​B>, Prism.Simple<S,​A>, ProtoOptic<P,​S,​T,​A,​B>, Schema<Values>, TypeSafeKey<A,​B>, TypeSafeKey.Simple<A>
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Optic<P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B>
    A generic supertype representation for profunctor optics.

    Precisely stated, for some Profunctor P and some Functor F, and for the types S T A B, an Optic<P, F, S, T, A, B> is a polymorphic function P<A, F<B>> -> P<S, F<T>>.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Optic.Simple<P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​A>
      An convenience type with a simplified signature for optics with unified S/T and A/B types.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default <Z,​C>
      Optic<P,​F,​S,​T,​Z,​C>
      andThen​(Optic<? super P,​? super F,​A,​B,​Z,​C> f)
      Left-to-right composition of optics.
      <CoP extends Profunctor<?,​?,​? extends P>,​CoF extends Functor<?,​? extends F>,​FB extends Functor<B,​? extends CoF>,​FT extends Functor<T,​? extends CoF>,​PAFB extends Profunctor<A,​FB,​? extends CoP>,​PSFT extends Profunctor<S,​FT,​? extends CoP>>
      PSFT
      apply​(PAFB pafb)
      The polymorphic arrow between profunctors in this optic interface.
      default <R,​U>
      Optic<P,​F,​R,​U,​A,​B>
      compose​(Optic<? super P,​? super F,​R,​U,​S,​T> g)
      Right-to-Left composition of optics.
      default <C> Optic<P,​F,​S,​T,​C,​B> mapA​(Fn1<? super A,​? extends C> fn)
      Covariantly map A to C, yielding a new optic.
      default <Z> Optic<P,​F,​S,​T,​A,​Z> mapB​(Fn1<? super Z,​? extends B> fn)
      Contravariantly map B to Z, yielding a new optic.
      default <R> Optic<P,​F,​R,​T,​A,​B> mapS​(Fn1<? super R,​? extends S> fn)
      Contravariantly map S to R, yielding a new optic.
      default <U> Optic<P,​F,​S,​U,​A,​B> mapT​(Fn1<? super T,​? extends U> fn)
      Covariantly map T to U, yielding a new optic.
      default <CoP extends Profunctor<?,​?,​? extends P>,​CoF extends Functor<?,​? extends F>,​FB extends Functor<B,​? extends CoF>,​FT extends Functor<T,​? extends CoF>,​PAFB extends Profunctor<A,​FB,​? extends CoP>,​PSFT extends Profunctor<S,​FT,​? extends CoP>>
      Fn1<PAFB,​PSFT>
      monomorphize()
      Produce a monomorphic Fn1 backed by this Optic.
      static <P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B,​FB extends Functor<B,​? extends F>,​FT extends Functor<T,​? extends F>,​PAFB extends Profunctor<A,​FB,​? extends P>,​PSFT extends Profunctor<S,​FT,​? extends P>>
      Optic<P,​F,​S,​T,​A,​B>
      optic​(Fn1<PAFB,​PSFT> fn)
      Promote a monomorphic function to a compatible Optic.
      static <P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B>
      Optic<P,​F,​S,​T,​A,​B>
      reframe​(Optic<? super P,​? super F,​S,​T,​A,​B> optic)
      Reframe an Optic according to covariant bounds.
    • Method Detail

      • apply

        <CoP extends Profunctor<?,​?,​? extends P>,​CoF extends Functor<?,​? extends F>,​FB extends Functor<B,​? extends CoF>,​FT extends Functor<T,​? extends CoF>,​PAFB extends Profunctor<A,​FB,​? extends CoP>,​PSFT extends Profunctor<S,​FT,​? extends CoP>> PSFT apply​(PAFB pafb)
        The polymorphic arrow between profunctors in this optic interface.
        Type Parameters:
        CoP - the profunctor type constraint witnessed by the application of this optic
        CoF - the functor type constraint witnessed by the application of this optic
        FB - the covariant parameter type of the input profunctor
        FT - the covariant parameter type of the output profunctor
        PAFB - the full input type
        PSFT - the full output type
        Parameters:
        pafb - the input
        Returns:
        the output profunctor
      • monomorphize

        default <CoP extends Profunctor<?,​?,​? extends P>,​CoF extends Functor<?,​? extends F>,​FB extends Functor<B,​? extends CoF>,​FT extends Functor<T,​? extends CoF>,​PAFB extends Profunctor<A,​FB,​? extends CoP>,​PSFT extends Profunctor<S,​FT,​? extends CoP>> Fn1<PAFB,​PSFT> monomorphize()
        Produce a monomorphic Fn1 backed by this Optic.
        Type Parameters:
        CoP - the covariant bound on P
        CoF - the covariant bound on F
        FB - fixed functor over B for inference
        FT - fixed functor over T for inference
        PAFB - the fixed input profunctor type
        PSFT - the fixed output profunctor type
        Returns:
        the monomorphic Fn1 backed by this Optic
      • andThen

        default <Z,​C> Optic<P,​F,​S,​T,​Z,​C> andThen​(Optic<? super P,​? super F,​A,​B,​Z,​C> f)
        Left-to-right composition of optics. Requires compatibility between S and T.
        Type Parameters:
        Z - the new left side of the input profunctor
        C - the new right side's functor embedding of the input profunctor
        Parameters:
        f - the other optic
        Returns:
        the composed optic
      • compose

        default <R,​U> Optic<P,​F,​R,​U,​A,​B> compose​(Optic<? super P,​? super F,​R,​U,​S,​T> g)
        Right-to-Left composition of optics. Requires compatibility between A and B.
        Type Parameters:
        R - the new left side of the output profunctor
        U - the new right side's functor embedding of the output profunctor
        Parameters:
        g - the other optic
        Returns:
        the composed optic
      • mapS

        default <R> Optic<P,​F,​R,​T,​A,​B> mapS​(Fn1<? super R,​? extends S> fn)
        Contravariantly map S to R, yielding a new optic.
        Type Parameters:
        R - the new left side of the output profunctor
        Parameters:
        fn - the mapping function
        Returns:
        the new optic
      • mapT

        default <U> Optic<P,​F,​S,​U,​A,​B> mapT​(Fn1<? super T,​? extends U> fn)
        Covariantly map T to U, yielding a new optic.
        Type Parameters:
        U - the new right side's functor embedding of the output profunctor
        Parameters:
        fn - the mapping function
        Returns:
        the new optic
      • mapA

        default <C> Optic<P,​F,​S,​T,​C,​B> mapA​(Fn1<? super A,​? extends C> fn)
        Covariantly map A to C, yielding a new optic.
        Type Parameters:
        C - the new left side of the input profunctor
        Parameters:
        fn - the mapping function
        Returns:
        the new optic
      • mapB

        default <Z> Optic<P,​F,​S,​T,​A,​Z> mapB​(Fn1<? super Z,​? extends B> fn)
        Contravariantly map B to Z, yielding a new optic.
        Type Parameters:
        Z - the new right side's functor embedding of the input profunctor
        Parameters:
        fn - the mapping function
        Returns:
        the new optic
      • optic

        static <P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B,​FB extends Functor<B,​? extends F>,​FT extends Functor<T,​? extends F>,​PAFB extends Profunctor<A,​FB,​? extends P>,​PSFT extends Profunctor<S,​FT,​? extends P>> Optic<P,​F,​S,​T,​A,​B> optic​(Fn1<PAFB,​PSFT> fn)
        Promote a monomorphic function to a compatible Optic.
        Type Parameters:
        P - the Profunctor bound
        F - the Functor bound
        S - the left side of the output profunctor
        T - the right side's functor embedding of the output profunctor
        A - the left side of the input profunctor
        B - the right side's functor embedding of the input profunctor
        FB - fixed functor over B for inference
        FT - fixed functor over T for inference
        PAFB - the input
        PSFT - the output
        Parameters:
        fn - the function
        Returns:
        the Optic
      • reframe

        static <P extends Profunctor<?,​?,​? extends P>,​F extends Functor<?,​? extends F>,​S,​T,​A,​B> Optic<P,​F,​S,​T,​A,​B> reframe​(Optic<? super P,​? super F,​S,​T,​A,​B> optic)
        Reframe an Optic according to covariant bounds.
        Type Parameters:
        P - the Profunctor type
        F - the Functor type
        S - the left side of the output profunctor
        T - the right side's functor embedding of the output profunctor
        A - the left side of the input profunctor
        B - the right side's functor embedding of the input profunctor
        Parameters:
        optic - the Optic
        Returns:
        the covariantly reframed Optic