What's Changed
- addition of Scala3 macros for Lens/ALens and Prism/APrism (#134) @sagifogel
import proptics.Lens
import proptics.macros.GLens
final case class Person(name: String, address: Address)
final case class Address(city: String, street: Street)
final case class Street(name: String, number: Int)
val personNameLens: Lens[Person, Int] = GLens[Person](_.address.street.number)
val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9)))
personNameLens.set(308)(person)
// Person(Walter White,Address(Albuquerque,Street(Negra Arroyo Lane,308)))
import proptics.Prsims
import proptics.macros.GPrism
sealed trait Request
final case class GET(path: List[String]) extends Request
final case class POST(path: List[String], body: String) extends Request
val webServerPrism = GPrism[Request, GET]
webServerPrism.preview(GET(List("path")))
// Some(GET(List(path)))
webServerPrism.preview(POST(List("path"), "body"))
// None