zio.blocks.schema.patch.Patch
See thePatch companion object
A type-safe patch that can be applied to values of type S.
Patches represent a sequence of operations (set, increment, append, etc.) that transform values. Because patches use serializable operations and reflective optics for navigation, they can be serialized and applied remotely.
Patches can be composed using ++ and applied using the apply method with a PatchMode (Strict, Lenient, or Clobber) to control error handling behavior. Empty patches act as identity (no-op).
import zio.blocks.schema.patch.Patch
case class Person(name: String, age: Int)
object Person extends CompanionOptics[Person] {
implicit val schema: Schema[Person] = Schema.derived
val name: Lens[Person, String] = $(_.name)
val age: Lens[Person, Int] = $(_.age)
}
val patch1 = Patch.set(Person.name, "John")
val patch2 = Patch.increment(Person.age, 1)
val patch3 = patch1 ++ patch2
patch3(Person("Jane", 25)) // Person("John", 26)
Value parameters
- dynamicPatch
-
The untyped patch operations
- schema
-
The schema for type S, enabling type-safe conversion
Attributes
- Companion
- object
- Source
- Patch.scala
- Graph
-
- Supertypes
Members list
In this article