Optics Dev Monocle Versions Save

Optics library for Scala

v3.2.0

1 year ago

What's new

Bug Fix

New Contributors

Full Changelog: https://github.com/optics-dev/Monocle/compare/v3.1.0...v3.2.0

v3.1.0

2 years ago

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)
  • Add GenIso to Scala 3 (#1185) @japgolly
  • Add Iso.fields (#1197) @kenbot
  • index is now a direct method for all optics for better Cats compat (#1192) @kenbot
  • Avoid indirect call to AsPrismImpl (#1186) @nicolasstucki
  • Fix #1177 where Focus could not operate on type aliases (#1178) @kenbot

Dependencies

  • Update sbt-scalajs, scalajs-compiler, ... to 1.7.0 (#1187) @scala-steward
  • Update refined, refined-scalacheck to 0.9.27 (#1179) @scala-steward

v3.0.0

2 years ago
  • 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]
  • pre-apply Focus to an object (#1039) @kenbot
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
    • as (#1050 #1112) @kenbot
    • withDefault (#1094) @kenbot
    • at, index (#1081) @kenbot
    • each (#1072) @kenbot
    • some @kenbot
  • [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, deprecate set (#974) @sapizhak
  • add replaceOption, deprecate setOption (#1006) @jamesbruce97
  • add filter, deprecate unsafeSelect (#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 and index (#978) @sapizhak
    • filterIndex (#999) @julien-truffaut
    • as (#1110, #1123) @julien-truffaut
    • each (#908) @julien-truffaut
    • withDefault (#886) @julien-truffaut
    • to (#896) @TimWSpence
  • add orElse on Optional (#1021) @julien-truffaut
  • add cats instances to zip Lenses together (#1109) @vaslabs
  • add optics extension method, deprecate all applyX methods (#1003) @julien-truffaut
  • generalise Traversal.applyN to accept Optionals (#1100) @julien-truffaut
  • add POptional into Ior's left and right (#893) @chwthewke
  • move Map instance for Each and FilterIndex from unsafe module to core (#998) @julien-truffaut

Deprecation

  • Deprecate all codiagonal except Lens.codiagonal (#1115) @julien-truffaut
  • Deprecate first, second, left, right, split. Move choice to cats instance (#1114) @julien-truffaut
  • deprecate symbolic compose operators (#983) @julien-truffaut
  • deprecate generic and state 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 scalajsto 1.6.0

v3.0.0-RC2

2 years ago

What's Changed

  • move organisation from Julien account to dev.optics (#1162) @julien-truffaut
libraryDependencies ++= Seq(
 "dev.optics" %% "monocle-core"  % "3.0.0-RC2",
 "dev.optics" %% "monocle-macro" % "3.0.0-RC2", // only for Scala 2.13
)
  • Scala 3.0.0 (#1158) @xuwei-k
  • Update alleycats-core, cats-core, cats-free, ... to 2.6.0 (#1139) @scala-steward
  • Update sbt-scalajs, scalajs-compiler, ... to 1.5.1 (#1134) @scala-steward

v3.0.0-M4

3 years ago

Focus macro

  • add subtype constraint to as (#1112) @kenbot
  • field selection on case classes with a single field generates an Iso (#1111) @kenbot

API update

  • add cats instances to zip Lenses together (#1109) @vaslabs
  • add as extension method to all optics (#1110, #1123) @julien-truffaut
  • use monocle.syntax.all._ for all extension methods (including macros) for both Scala 2 and 3 (#1120) @julien-truffaut
  • add inheritance between AppliedOptics (#1116) @julien-truffaut
  • add type aliases for AppliedOptics (#1113) @julien-truffaut
  • Deprecate all codiagonal except Lens.codiagonal (#1115) @julien-truffaut
  • Deprecate first, second, left, right, split. Move choice to cats instance (#1114) @julien-truffaut

Documentation

  • enable scalajs-mapSourceURI option if Scala 3 (#1107) @xuwei-k
  • add source links to scala 3 documentation. (#1108) @romanowski

v3.0.0-M3

3 years ago

Focus Macro

  • add support for tuple field selection (#1095) @kenbot
  • withDefault feature, remove Eq constraint (#1094) @kenbot
  • at, index features (#1081) @kenbot
  • use KeywordContext to restrict Focus syntax (#1079) @kenbot

API changes

  • inheritance between optics (#1088) @julien-truffaut
  • add Focus[X]() and .focus() to generate Iso/ApplyIso (#1098) @julien-truffaut
  • generalise Traversal.applyN to take Optionals (#1100) @julien-truffaut
  • remove At instance for tuples, use Focus on tuples instead (#1096) @julien-truffaut
  • improve Iso.id composition performance (#1099) @julien-truffaut

v3.0.0-M1

3 years ago

New features

  • add orElse on Optional (#1021) @julien-truffaut
  • add filterIndex shortcut on all optics (#999) @julien-truffaut
  • add at and index shortcut on all optics (#978) @sapizhak
  • add each shortcut on all optics (#908) @julien-truffaut
  • add withDefault to fallback when on a None (#886) @julien-truffaut
  • add to which lifts a function to Getter (#896) @TimWSpence
  • add POptional into Ior's left and right (#893) @chwthewke

API changes

  • add andThen, deprecate all composeX methods (#967 #1000) @julien-truffaut
  • add replace, deprecate set (#974) @sapizhak
  • add replaceOption, deprecate setOption (#1006) @jamesbruce97
  • add optics extension method, deprecate all applyX methods (#1003) @julien-truffaut
  • move Map instance for Each and FilterIndex from unsafe module to core (#998) @julien-truffaut
  • add filter, deprecate unsafeSelect (#988) @julien-truffaut
  • add at(1), at(2) ... for tuples, deprecate FieldX (#959) @julien-truffaut
  • deprecate symbolic compose operators (#983) @julien-truffaut
  • deprecate generic and state 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

Focus macro

  • add as feature (#1050) @kenbot
  • add each feature (#1072) @kenbot
  • add Focus to all syntax import (#1058) @julien-truffaut
  • Focus macro pre-applied to object (#1039) @kenbot

Macro for Scala 3

  • GenLens redirect to Focus (#1037) @julien-truffaut
  • GenPrism redirect to Focus (#1063) @asjad02

Bug Fix

  • ApplyXXX methods not fully applied (#1044) @julien-truffaut

Build and Dependency upgrade

  • Update refined to 0.9.21 (#1078) @scala-steward
  • Update cats to 2.4.2 (#1068) @scala-steward
  • Update discipline-core to 1.1.4 (#1066) @scala-steward
  • Update scalajsto 1.5.0 (#1053) @scala-steward
  • Update sbt to 1.4.7 (#1017) @scala-steward
  • Bump coursier/cache-action from v3 to v5 (#963) @dependabot
  • add dependabot.yml (#962) @xuwei-k
  • Upgrade obsolete github actions (#958) @cquiroz
  • Port tests to munit (#943) @cquiroz
  • Scala 3.0.0 (#937) @cquiroz
  • Update scalafmt (#915) @cquiroz

v2.1.0

3 years ago

What's changed:

  • Add Iso involuton #869
  • Fix broken class diagram link in docs. #870
  • Replace deprecated ? with * #881

Updates

  • Update sbt-mdoc to 2.2.5 #883
  • Update sbt-scalajs, scalajs-compiler to 1.1.1 #873
  • Update sbt to 1.3.13 #872
  • Update sbt-microsites to 1.2.1 #875
  • Update sbt-scalafmt to 2.4.2 #879
  • Update scalaz-core to 7.3.2 #874

v2.0.4

4 years ago
  • Support Scala.js 1.0