3.0.0
- 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
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)
- [Scala 3 only] operators for
Focus
path. This feature was enabled by a trick found by @yilinwei #1079 - [Scala 3 only] field selection on case classes with a single field generates an
Iso
(#1111) @kenbot
import monocle.Focus
case class UserId(value: Long)
Focus[UserId](_.value)
// res: Iso[UserId, Long]
API updates
- inheritance between optics (#1088 #1116) @julien-truffaut
- add
andThen
to compose (#967 #1000) @julien-truffaut - add
replace
, deprecateset
(#974) @sapizhak - add
replaceOption
, deprecatesetOption
(#1006) @jamesbruce97 - add
filter
, deprecateunsafeSelect
(#988) @julien-truffaut - add type aliases for
AppliedOptics
(#1113) @julien-truffaut - use
monocle.syntax.all._
for all extension methods including macros (#1120) @julien-truffaut - add shortcut to all optics for common composition patterns:
at
andindex
(#978) @sapizhakfilterIndex
(#999) @julien-truffautas
(#1110, #1123) @julien-truffauteach
(#908) @julien-truffautwithDefault
(#886) @julien-truffautto
(#896) @TimWSpence
- add
orElse
on Optional (#1021) @julien-truffaut - add cats instances to
zip
Lenses
together (#1109) @vaslabs - add
optics
extension method, deprecate allapplyX
methods (#1003) @julien-truffaut - generalise
Traversal.applyN
to acceptOptionals
(#1100) @julien-truffaut - add
POptional
intoIor
's left and right (#893) @chwthewke - move
Map
instance forEach
andFilterIndex
fromunsafe
module tocore
(#998) @julien-truffaut
Deprecation
- Deprecate all
codiagonal
exceptLens.codiagonal
(#1115) @julien-truffaut - Deprecate
first
,second
,left
,right
,split
. Movechoice
to cats instance (#1114) @julien-truffaut - deprecate symbolic compose operators (#983) @julien-truffaut
- deprecate
generic
andstate
module - no replacement (#986) @julien-truffaut - deprecate
Possible
- no replacement (#992) @julien-truffaut - deprecate
Cons
,Cons1
,Snoc
,Snoc1
- no replacement (#984) @julien-truffaut - deprecate
Curry
,Empty
,Reverse
- no replacement (#980) @julien-truffaut
Documentation
- enable scalajs-mapSourceURI option if Scala 3 (#1107) @xuwei-k
- add source links to scala 3 documentation. (#1108) @romanowski
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
scalajs
to 1.6.0