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).

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