Constructors for Prism — the partial single-focus optic, backed by Either. A Prism[S, A] (short for Optic[S, S, A, A, Either]) encodes a branch of a sum type: getOption(s) succeeds when s matches, reverseGet(a) lifts back. The eo-generics module's prism[S, A] macro derives prisms on enums / sealed traits / union types.
Monomorphic constructor (S = T, A = B). getOrModify returns Right(a) on match and Left(s) on miss.
Monomorphic constructor (S = T, A = B). getOrModify returns Right(a) on match and Left(s) on miss.
Attributes
Example
enum Shape:
case Circle(r: Double)
case Square(s: Double)
val circleP = Prism[Shape, Shape.Circle](
{ case c: Shape.Circle => Right(c); case other => Left(other) },
identity,
)
Option-shaped constructor — returns a PickMendPrism whose fused extensions avoid the intermediate Either the generic constructor must build. Prefer when the projection is already S => Option[A].
Option-shaped constructor — returns a PickMendPrism whose fused extensions avoid the intermediate Either the generic constructor must build. Prefer when the projection is already S => Option[A].