Class EitherLens
java.lang.Object
com.jnape.palatable.lambda.optics.lenses.EitherLens
Lenses for
Either.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <L,R> Lens.Simple <Either<L, R>, Maybe<L>> _left()Convenience static factory method for creating a lens over left values, wrapping them in aMaybe.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 aMaybe.
-
Constructor Details
-
EitherLens
private EitherLens()
-
-
Method Details
-
_right
Convenience static factory method for creating a lens over right values, wrapping them in aMaybe. When setting, aMaybe.nothing()value means to leave theEitherunaltered, where as aMaybe.just(A)value replaces the either with a right over theMaybe.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 typeR- the right parameter type- Returns:
- a lens that focuses on right values
-
_left
Convenience static factory method for creating a lens over left values, wrapping them in aMaybe. When setting, aMaybe.nothing()value means to leave theEitherunaltered, where as aMaybe.just(A)value replaces the either with a left over theMaybe.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 typeR- the right parameter type- Returns:
- a lens that focuses on left values
-