Download Latest Version 3.3.0 source code.tar.gz (10.3 MB)
Email in envelope

Get an email when there's a new version of Monocle

Home / v3.0.0
Name Modified Size InfoDownloads / Week
Parent folder
3.0.0 source code.tar.gz 2021-07-03 10.3 MB
3.0.0 source code.zip 2021-07-03 10.5 MB
README.md 2021-07-03 3.6 kB
Totals: 3 Items   20.8 MB 0
  • Change the organisation from com.github.julien-truffaut to dev.optics

    :::scala 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

    :::scala import monocle.Focus

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

    FocusUser // res: Lens[User, String] FocusUser // res: Lens[User, Int] * pre-apply Focus to an object (#1039) @kenbot

    :::scala 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

    :::scala import monocle.Focus

    case class UserId(value: Long)

    FocusUserId // 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
Source: README.md, updated 2021-07-03