Modify

dev.constructive.eo.optics.Modify
See theModify companion class
object Modify

Constructor for Modify — write-only single-focus optic, backed by ModifyF. The caller applies a function at the focus but cannot read it back; useful when observation would leak information or when the focus is genuinely unreadable (e.g. inside a closure).

'''This is Monocle's / Haskell lens's Setter, renamed.''' The mapping is Setter.modifyModify.modify and Setter.setModify.replace — do not look for a Setter type here.

Modify.apply returns a concrete Modify, so a Modify composes with another Modify through the ordinary andThen (the fused Modify.andThen) — s1.andThen(s2).modify(f) == s1.modify(s2.modify(f)) — exactly as Iso / Lens / Getter compose via their own fused subclasses, bypassing the generic AssociativeFunctor[ModifyF] round-trip.

Attributes

Companion
class
Source
Modify.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Modify.type

Members list

Grouped members

Constructors

def apply[S, T, A, B](modify: (A => B) => S => T): Modify[S, T, A, B]

Construct from modify: (A => B) => S => T.

Construct from modify: (A => B) => S => T.

Attributes

Example
case class Config(values: Map[String, Int])
val bumpAll = Modify[Config, Config, Int, Int] { f => cfg =>
 cfg.copy(values = cfg.values.view.mapValues(f).toMap)
}
bumpAll.modify(_ + 1)(cfg)
Source
Modify.scala
def functor[F[_], A, B](using F: Functor[F]): Modify[F[A], F[B], A, B]

Write-only Modify over any Functor[F]: modify = F.map — the Traversal.each analog for containers that are mappable but not foldable into view (Function1[R, *], Eval, …). Polymorphic in the focus (map is); Modify extends CanModifyP directly, so the result is capability evidence as-is.

Write-only Modify over any Functor[F]: modify = F.map — the Traversal.each analog for containers that are mappable but not foldable into view (Function1[R, *], Eval, …). Polymorphic in the focus (map is); Modify extends CanModifyP directly, so the result is capability evidence as-is.

Attributes

Source
Modify.scala