All Downloads are FREE. Search and download functionalities are using the official Maven repository.

monocle.std.Either.scala Maven / Gradle / Ivy

The newest version!
package monocle.std

import monocle.{PPrism, Prism}

object either extends EitherOptics

trait EitherOptics {
  final def pStdLeft[A, B, C]: PPrism[Either[A, B], Either[C, B], A, C] =
    PPrism[Either[A, B], Either[C, B], A, C] {
      case Left(a)  => Right(a)
      case Right(b) => Left(Right(b))
    }(Left.apply)

  final def stdLeft[A, B]: Prism[Either[A, B], A] =
    pStdLeft[A, B, A]

  final def pStdRight[A, B, C]: PPrism[Either[A, B], Either[A, C], B, C] =
    PPrism[Either[A, B], Either[A, C], B, C] {
      case Left(a)  => Left(Left(a))
      case Right(b) => Right(b)
    }(Right.apply)

  final def stdRight[A, B]: Prism[Either[A, B], B] =
    pStdRight[A, B, B]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy