Skip to content

3.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 12 Jul 10:28
· 264 commits to master since this release
7d59f9a
  • Change the organisation from com.github.julien-truffaut to dev.optics
libraryDependencies ++= Seq(
 "dev.optics" %% "monocle-core"  % "3.0.0",
 "dev.optics" %% "monocle-macro" % "3.0.0", // only for Scala 2.13
)

Focus macro

  • new macro to generate optics from a path (similar to XPath/JsonPath) @kenbot and @yilinwei
import monocle.Focus

case class User(name: String, address: Address)
case class Address(streetNumber: Int, streetName: String)

Focus[User](_.name)
// res: Lens[User, String]
Focus[User](_.address.streetNumber)
// res: Lens[User, Int]
import monocle.syntax.all._

val anna = User("Anna", Address(12, "high street")

anna.focus(_.name).replace("Bob")
anna.focus(_.address.some.streetNumber).modify(_ + 1)
import monocle.Focus

case class UserId(value: Long)

Focus[UserId](_.value)
// res: Iso[UserId, Long]

API updates

Deprecation

Documentation

Dependency upgrade

  • Update Scala to 3.0.0 and 2.13.5
  • Update cats to 2.6.1
  • Update refined to 0.9.26
  • Update scalajsto 1.6.0