Release Notes

2.0.1

09 January 2020

  • bug fix: use fully qualified name in Lens macro #793 (thanks to enzief)
  • add parModifyF to Traversal leveraging cats.Parallel #751 (thanks to nigredo-tori)
  • add At, Index and Each instances for ListMap #740, #742 #747 (thanks to jan0sch)

2.0.0 (cats only)

11 September 2019

  • everything in 1.6.0
  • add instances for NonEmptyVector #564 (thanks to valydia)
  • add optics for cats Chain and NonEmptyChain #609 (thanks to dcastro)
  • add missing functions (mod, assign and variants) to State module #564 (thanks to valydia)
  • depends on cats 2.0.0

1.6.0 (scalaz only, last major release with scalaz)

14 July 2019

  • add apply helper methods to typeclasses #560 (thanks to jbgi)
  • add coProductIso, coProductDisjunctionIso and toGeneric #578 (thanks to dcastro)
  • add override modifiers in macro generated code #581 (thanks to omervk)
  • add FieldsSyntax to global import #583 (thanks to kubukoz)
  • fix name collisions in implicit classes #629 (thanks to vladimirkl)
  • release from ci, stop support of scala 2.11 and scala native #646
  • support scala 2.13 #669 (thanks to xuwei-k)

1.5.0 and 1.5.0-cats

3 January 2018

  • add coalgebroid-based constructors for Lens and Traversal #502 (thanks to jeslg)
  • add state syntax for traversal #533 (thanks to jeslg)
  • add modifyF to Apply syntax #525 (thanks to colin-passiv)
  • add optics composition table #532 (thanks to jdegoes)
  • support scala native #508 (thanks to aoiroaoino)
  • bug fix: allow for annotations on companion objects of @Lenses-annotated case classes #524 (thanks to hrhino)

  • create a cats branch where cats replaces scalaz #528 and #539 (thanks to sellout and tpolecat)

1.4.0

14 January 2017

Addition

Other

  • deprecate global constructor of typeclasses #478
  • remove deprecated methods sum and product #479
  • execute packageSrc in travis-ci to avoid regressing like #492 #494 (thanks to xuwei-k)

1.4.0-M2

23 December 2016

  • do not require java 8 for scala 2.11 #463
  • add Possible typeclass #450 (thanks to kenbot)
  • add zip and unzip for Getter #453 and #458 (thanks to lunaryorn)
  • upgrade scala to 2.12.1 and fix doc issue around SI-7139 #435
  • upgrade scala.js to 0.6.14 #466

1.4.0-M1

16 December 2016

Addition

Refactor

  • major refactor of typeclasses #405:
    • abstract class instead of trait. This would allow to add methods without breaking binary compatibility
    • move typeclass instances from monocle.std._ to the typeclass companion object. This change will reduce the number of imports required to use a typeclass
  • curry find, exist and all #425
  • improve performance of Index instance for List and Vector #413
  • simplify Plated instance for Free #404 (thanks to aoiroaoino)
  • remove Order instance for Char #405
  • prevent warning for higherKinds in Lens macro #434 (thanks to cvogt)

Doc

Other

1.3.2

02 November 2016

  • add support for scala 2.12.0 #408
  • use Free.roll in Plated[Free[S, A]] instance #404 (thanks to aoiroaoino )
  • update build settings for scala.js #406 (thanks to aoiroaoino )

1.3.1

21 October 2016

  • add support for scala 2.12.0-RC2

1.3.0

18 October 2016

Addition

  • add unsafe module with select #394 (thanks to cesartl)
  • refactor optics laws to use random functions #357
  • add Wrapped typeclass #365 (thanks to puffnfresh)
  • add State syntax for Optional #387 (thanks to cb372)
  • add transformM and transformCounting to Plated #391 (thanks to arkadius)
  • add applyN for Traversal #379 (thanks to jule64)
  • add mapping #396 (thanks to mdulac)

Deprecation

  • remove all deprecated elements from 1.1 e.g. (Lenser, headMaybe, getMaybe, setMaybe, modifyMaybe) (see)

Upgrades

dependencies monocle 1.2.2 monocle 1.3.0
scalaz 7.2.2 7.2.6
shapeless 2.2.5 2.3.2
refined 0.3.2 0.5.0
discipline 0.4 0.7

1.2.2

9 June 2016

Addition

  • add apply methods for Prism and Iso #354 (thanks to sellout)
  • add unapply methods for Prism and Iso #361 (thanks to sellout)
  • add partial constructor for Prism #355 (thanks to sellout)

Documentation

1.2.1

13 April 2016

Addition

  • support for scala.js #335 (thanks to japgolly)
  • remove: delete a value associated with a key in a Map-like container #341 (thanks to dabd)
  • doubleToFloat, bigDecimalToLong and bigDecimalToInt #312 (thanks to mikaelv)
  • optics for Tuple1 #313 (thanks to exlevan)
  • use random index for AtTests and IndexTests #343 (thanks to pvillega)
  • Each instance for tuples and case classes with fields of the same type #347 (thanks to Astrac)

Bug Fixes

  • fix implicit not found message for Plated #320 (thanks to aoiroaoino)
  • fix stringToBoolean such as it satisfies 2nd prism law #340 (thanks to hasumedic)
  • fix stringToLong such as it satisfies 2nd prism law #339 (thanks to pvillega)
  • fix bit indexing for Long #343 (thanks to pvillega)

Upgrades

  • scala 2.11.8
  • scalaz to 7.2.2

1.2.0

17 December 2015

Documentation

  • add example, typeclass and faq sections to the website #314, #316
  • document SI-7139 limitation for optics constructor in REPL and tut #309

Bug Fixes

  • generate fresh type-parameter name for modifyF #300 (thanks to puffnfresh)
  • publish monocle-refined with all the other modules #311
  • publish snapshot automatically for scala 2.10 and 2.11 #310

Upgrades

  • scalaz to 7.2.0
  • refined to 0.3.2
  • macro paradise to 2.1.0

1.2.0-M2

22 November 2015

Thanks to all the 14 contributors since 1.2.0-M1

Addition

  • add only Prism to match a single value see
  • add below Prism to lift a Prism in a Traverse see
  • add length for Fold and Traversal #236 (thanks to aoiroaoino)
  • add optics for scalaz.Either3 #242 (thanks to aoiroaoino)
  • add optNelToList Iso see
  • add fromIso combinator for all optics #245
  • add left and right methods for Iso, Prism, Getter and Fold #273
  • add safe down cast from BigInt #267
  • add productToTuple Iso between case class and tuple using shapeless #247
  • add GenIso.fields white box that generates the same Iso than productToTuple with better performances but less IDE support #297 (thanks to japgolly)
  • add @PLenses macro annotation to generate PLens for case class with type parameters #114 (thanks to exlevan)
  • add Plated typeclass #289 (thanks to puffnfresh)
  • add optics for scalaz.Cofree #290 (thanks to LiamGoodacre)

Non backward compatible change

  • change mega imports from package object to all object, e.g. import monocle.function._ becomes import monocle.function.all._ #243
  • change At definition from def at(index: I): Lens[S, Option[A]] to def at(index: I): Lens[S, A]
  • change At instance for Set and ISet from Lens[S, Option[Unit]] to Lens[S, Boolean]
  • remove Index instances for bit indexing primitive Long, Int, Char, Bye from monocle-core
  • add monocle-refined module with At instances for bit indexing primitive Long, Int, Char, Bye #291 (thanks to fthomas and julien-truffaut)

Deprecation

  • deprecate theseDisjunction to theseToDisjunction see
  • deprecate nelAndOneIso to nelToOneAnd see
  • deprecate sum to choice and product to split #239

Documentation

  • add tut examples for Prism #228
  • add tut examples for Iso #279 (thanks to justjoheinz)
  • add examples for Http Request optics usage #262 (thanks to 1ambda)
  • add learning resources to the website #251

Bug Fixes

  • fix long parser #244 (thanks to NightRa)
  • fix GenIso case class with type parameter #263

Optimisation

  • improve performances of index for Vector #258 (thanks to spebbe)

Upgrades

  • scala to 2.10.6
  • scalaz to 7.1.4
  • shapeless to 2.2.5
  • macro-compat to 1.1.0
  • macro paradise to 2.1.0-M5

1.2.0-M1

06 July 2015

  • laws definition move to core module see. Properties are still defined in law module with discipline
  • optics defined for scalaz.Validation #211 (thanks to anakos)
  • hListAt is now public see
  • add basic state support for Lens in an experimental state module see
  • add void for Optional, Traversal, Fold and Setter see
  • add Setter constructor using scalaz.Contravariant and scalaz.Profunctor see
  • GenIso for object and empty case classes #219 and #223 (thanks to adelbertc)
  • add optionToDisjunction Iso #226 (thanks to aoiroaoino)
  • add monomorphic optics for Option, Either, scalaz.Disjunction, scalaz.Validation #181

Build

  • publish snapshot automatically #207
  • create basic web site using compile time verified examples with tut #227

Bug Fixes

Upgrades

  • scala to 2.10.5 and 2.11.7
  • scalaz to 7.1.3
  • shapeless to 2.2.3
  • kind projector to 0.6.0

1.1.0

31 Mars 2015

All Optics are now abstract classes

  • easier to change implementation and maintain backward compatibility
  • offer faster implementation using macros or new (not recommended)

Deprecate use of Maybe and IList in interface

  • 1.0.0 replaced Option by scalaz.Maybe but it turns out that Maybe advantages are not worth the cost of moving away from scala std.
  • same between List and scalaz.IList
  • type classes e.g. Compose, Category, Arrow, Choice
  • methods e.g. id, codiagonal, first, second, sum, product

Macro

  • monocle.macros.GenIso generates Iso for case class with a single accessor
  • monocle.macros.GenPrism generates Prism for sealed trait
  • @Lenses now supports case classes with type parameters see
  • Lenser is deprecated, use GenLens instead (same functionality but more consistent naming)

Spark friendly

  • Optics and type classes extends Serializable

Syntax

  • using optics as an infix operator operator requires a single import monocle.syntax.apply or monocle.syntax._

1.0.0

14 December 2014

Rename Optics

  • Iso, Lens, Prism, Optional, Traversal and Setter were prepended by a P for Polymorphic
  • SimpleIso, SimpleLens, SimplePrism, SimpleOptional, SimpleTraversal and SimpleSetter lost Simple
  • for example, Lens was renamed to PLens and SimpleLens to Lens
  • benefits: in practice most optics are not polymorphic, so it is more convenient to have a shorter name for the most used optics.

No inheritance between Optics

  • All Optics use asX methods to transform Optics, e.g. Prism[S, T, A, B] has methods asOptional: Optional[S, T, A, B], asTraversal: Traversal[S, T, A, B], … methods

Compose direction

  • in 0.5, composeY meant that the result of the composition is an Optic of type Y
  • in 1.0, composeY means that you compose with an Optic of type Y

Main method changes

  • removed set, modify, setOption, modifyOption
  • setF became set
  • setFOption became setMaybe
  • modifyF became modify
  • modifyFOption became modifyMaybe
  • modifyF became lift or multiLift depending on the Optic
  • getOption became getMaybe

Simplified Constructors

  • Curry Optics constructor and merged Simple Optic constructors
  • Shuffle methods and parameters order to be consistent between Optics

Use Maybe and IList from scalaz instead of Option and List from std

  • Maybe can be transformed to Option by calling toOption
  • IList can be transformed to List by calling toList
  • benefits: no variance, better scalaz support, safer methods

Simplified type classes

  • merged HeadOption and TailOption into Cons
  • merged Head and Tail into Cons1
  • merged InitOption and LastOption into Snoc
  • merged Init and Last into Snoc1
  • removed SafeCast as it was simply a way to summon Prism implicitly
  • removed AtBit and defined Index[S, Int, Boolean] where S is a numeric type

Macros

  • all macros have been moved to monocle.macros package
  • mkLens has been moved to monocle.macros.internal, i.e. it is not public anymore. Use Lenser or @Lenses

0.5.1

29 September 2014

Macros

  • Add @Lenses Macro annotation to generate SimpleLens automatically for case classes
  • Add Lenser Macro to generate SimpleLens with a better IDE support than Macro annotation
  • Deprecate mkLens Macro as Lenser is strictly more powerful

Bug Fix

  • Fix SafeCast between String to Int

0.5.0

03 August 2014

Build and Dependencies

  • Upgrade scalaz dependency from 7.0.6 to 7.1
  • Upgrade specs2 dependency from 2.3.11 to 2.4
  • Build with scala 2.11.2
  • Use sbt-typelevel plugin

Breaking Changes

  • SimpleOptional apply method takes a setter function from (S, A) => A instead of (S, Option[A]) => A
  • Polymorphic optics instance reorganisation: All instances has been move from the companion objects of the polymorphic optics to packages:
    • monocle.std for standard Scala and scalaz classes
    • monocle.generic for shapeless classes

    Check out this example to see how it affects imports

  • reverseModify has been moved from Monocle package object to Prism syntax

New Features

  • Add setOption and modifyOption for Optional
  • Flipped curried version of set => setF, modify => modifyF, setOption => setOptionF, modifyOption => modifyOptionF See example
  • New constructors for simple optics with better type inference, see example
  • implicit not found annotations have been added to polymorphic optics to help user figuring out which import is missing
  • monocle.scalaz.Either has been renamed monocle.scalaz.Disjunction to avoid clashes with monocle.std.Either
  • Add Each, Index, Field1, Head, Tail and LastOption instances for scalaz.OneAnd
  • Add Each, HeadOption, and LastOption for scala.Some

0.4.0

28 May 2014

Modularity and build

  • Cross build for scala 2.10.4 and 2.11.0
  • Move Optic Laws from module core to law module
  • Move Macro from module core to macro module
  • Update dependencies
    • Remove scalacheck, scala-reflect and scala-compiler dependencies from core
    • upgrade scalacheck to 1.11.3
  • Add Mima support on core to check for binary compatibility between minor version for next releases

New major concept: Optional

  • Add Optional a new major concept that represents a 0-1 Traversal. Optional is a sub class of Traversal and a super class of Lens and Prism. Composing a Lens and a Prism creates an Optional instead of a Traversal, hence we maintain information that the resulting Optic zooms to an optional object and not a list
  • Rename Head -> HeadOption, Last -> LastOption, Tail -> TailOptionand Init -> InitOption
  • Change HeadOption, LastOption, TailOption, InitOption Optic from Traversal to Optional

Functions

  • Generalize Reverse, Tail and Init from 1 to 2 types parameters.
  • Add Head, Last, Tail, Init functions with the same semantic than the Option (HeadOption, …) variant except that their Optic is a Lens and not an Optional. This implies that Head, Last, Tail, Init can only be defined on elements with a mandatory head, last, tail and init. Implemented on 2-6 tuple and HList.
  • Implemented Reverse instances on all tuple and HList.
  • Implemented Reverse, Head, Last, Tail, Init instances on all tuple and HList.
  • Implemented HeadOption, LastOption, TailOption, InitOption, Each, Index and FilterIndex for scalaz IList.

Miscellaneous

  • Add reverseModify on SimplePrism as an alias for getOption map modify.
  • Add syntax for Getter, Fold and Setter.
  • Add non symbolic functions to use Optics as operators, e.g. List(1,2,3) applyTraversal each getAll instead of List(1,2,3) |->> each getAll
  • Add import for all syntax: import monocle.syntax._

0.3.0

02 May 2014

  • Update dependencies - scala to 2.10.4 - shapeless to 2.0.0 - macro paradise to 2.0.0 - quasi quotes to 2.0.0
  • Add apply4 to apply6 methods to Traversal
  • Add Each instance for 4 to 6 tuple of same type
  • Generic sub module: - Add Field1 to Field6 instances for HList - Add SafeCast instance for Coproduct, hence supporting Prism for sealed family - Remove _1, _2, _3 Lens using shapeless Generic, since composing toHList Iso and Fields Lens is equivalent

0.2.0

27 April 2014

  • Add generic Lens, Traversal, Iso and Prism in monocle.function:
    • _1, _2, …, _6, Lens to focus on the ith element of a tuple. Implemented for tuple of size 6 or less
    • atBit(i: Int), Lens to focus on ith Bit. Implemented for Boolean, Byte, Char, Int and Long
    • safeCast, Prism defining a safe down casting between two types. Implemented for most primitive type and String
    • curry and uncurry, Iso for functions with up to 5 parameters
    • head and last, Traversal to the first and last element respectively. Implemented for std List, Vector, Stream, Option and String
    • tail and init, Traversal to all elements except first and all elements except last respectively. Implemented for std List, Vector, Stream and String
    • reverse, Iso that reverses the order of elements. Implemented for std List, Vector, Stream, String and scalaz Tree
    • index(i: Int), Traversal to focus on ith element. Implemented for std List, Vector, Stream, Map and String
    • each, Traversal to focus on all elements. Implemented for std List, Vector, Stream, Option, Map, String, pair and triple of same type and scalaz tree
    • filterIndex(predicate: Index => Boolean), Traversal to focus on all elements with index verifying predicate. Implemented for List, Vector, Stream, Map and String
    • at(key: K), Lens to focus on an optional element at a key, strictly more powerful than index as it permits to add and delete elements. Implemented for Map
  • Alias for Iso, Prism, Lens and Traversal composition:
    • <-> == composeIso
    • ?-> == composePrism
    • |-> == composeLens
    • |->> == composeTraversal
  • Add experimental sub project generic, using shapeless to generate Iso between HList and case class or tuple
  • Add documentation in examples

0.1.0

27 February 2014

  • First release