Class EitherLens

java.lang.Object
com.jnape.palatable.lambda.optics.lenses.EitherLens

public final class EitherLens extends Object
Lenses for Either.
  • Constructor Details

    • EitherLens

      private EitherLens()
  • Method Details

    • _right

      public static <L, R> Lens.Simple<Either<L,R>,Maybe<R>> _right()
      Convenience static factory method for creating a lens over right values, wrapping them in a Maybe. When setting, a Maybe.nothing() value means to leave the Either unaltered, where as a Maybe.just(A) value replaces the either with a right over the Maybe.

      Note that this lens is NOT lawful, since "you get back what you put in" fails for Maybe.nothing().

      Type Parameters:
      L - the left parameter type
      R - the right parameter type
      Returns:
      a lens that focuses on right values
    • _left

      public static <L, R> Lens.Simple<Either<L,R>,Maybe<L>> _left()
      Convenience static factory method for creating a lens over left values, wrapping them in a Maybe. When setting, a Maybe.nothing() value means to leave the Either unaltered, where as a Maybe.just(A) value replaces the either with a left over the Maybe.

      Note that this lens is NOT lawful, since "you get back what you put in" fails for Maybe.nothing().

      Type Parameters:
      L - the left parameter type
      R - the right parameter type
      Returns:
      a lens that focuses on left values