Skip to content

3.1.0

Compare
Choose a tag to compare
@julien-truffaut julien-truffaut released this 01 Sep 08:31
· 263 commits to master since this release
40221ed

What's Changed

  • Add refocus to all optics as an alias for .andThen(Focus(...)) (#1184) @kenbot
case class User(name: String, address: Address)
case class Address(streetNumber: Int, street: Option[Street])

val elise = User("Elise", Address(12, Some(Street("high street"))))

val addressLens: Lens[User, Address] = Focus[User](_.address)
val newLens    : Lens[User, Int]     = addressLens.refocus(_.streetNumber)

newLens.replace(50)(elise)

// or using the applied syntax
import monocle.syntax.all._

elise.focus(_.address).refocus(_.streetNumber)

Dependencies