Release Notes
2.0.1
09 January 2020
- bug fix: use fully qualified name in
Lens
macro #793 (thanks to enzief) - add
parModifyF
toTraversal
leveragingcats.Parallel
#751 (thanks to nigredo-tori) - add
At
,Index
andEach
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
andNonEmptyChain
#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
andtoGeneric
#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
andTraversal
#502 (thanks to jeslg)add
modifyF
toApply
syntax #525 (thanks to colin-passiv)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
- add
Each
instance forTry
,Either
,scalaz.\/
,scalaz.Validation
#472 and #476 (thanks to n4to4) - add
Unzip
instance forLens
,Fold
,Optional
,Traversal
,Setter
#474 (thanks to n4to4) - add refined
startsWith
andendWith
#480 and #483 (thanks to valydia, mrcmatuszak and fthomas) - add
uuid
,url
,uri
#487 and #490 (thanks to mjjc and n4to4)
Other
- deprecate global constructor of typeclasses #478
- remove deprecated methods
sum
andproduct
#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
andunzip
forGetter
#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
- add macro based syntax for
ApplyLens
#434 (thanks to cvogt) - add lookup methods to various optics #425 (thanks to kubum, emmedema and julien-truffaut)
- add state ops for
Getter
andSetter
#415 (thanks to jeslg) - add
extract
,extracts
,assign_
andmod_
to state ops #415 (thanks to jeslg) - add
select
#441 (thanks to sepulkarz) - add
lowerCase
andupperCase
#446 (thanks to sindoudou)
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
andall
#425 - improve performance of
Index
instance forList
andVector
#413 - simplify
Plated
instance forFree
#404 (thanks to aoiroaoino) - remove
Order
instance forChar
#405 - prevent warning for
higherKinds
inLens
macro #434 (thanks to cvogt)
Doc
- use
sbt-microsite
#411 and #444 (thanks to VlachJosef) - new icons for website and stickers #421 (thanks to mbcltd)
- add doc for
Optional
#424 (thanks to mdulac) - add doc for
Traversal
#423
Other
kenji
aka xuwei-k is now a maintainer- update build settings for scala.js #406 (thanks to aoiroaoino)
1.3.2
02 November 2016
- add support for scala 2.12.0 #408
- use
Free.roll
inPlated[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 withselect
#394 (thanks to cesartl) - refactor optics laws to use random functions #357
- add
Wrapped
typeclass #365 (thanks to puffnfresh) - add
State
syntax forOptional
#387 (thanks to cb372) - add
transformM
andtransformCounting
toPlated
#391 (thanks to arkadius) - add
applyN
forTraversal
#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 forPrism
andIso
#354 (thanks to sellout) - add
unapply
methods forPrism
andIso
#361 (thanks to sellout) - add
partial
constructor forPrism
#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
andbigDecimalToInt
#312 (thanks to mikaelv)- optics for
Tuple1
#313 (thanks to exlevan) - use random index for
AtTests
andIndexTests
#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 aPrism
in aTraverse
see - add
length
forFold
andTraversal
#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
andright
methods forIso
,Prism
,Getter
andFold
#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 sameIso
thanproductToTuple
with better performances but less IDE support #297 (thanks to japgolly) - add
@PLenses
macro annotation to generatePLens
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._
becomesimport monocle.function.all._
#243 - change
At
definition fromdef at(index: I): Lens[S, Option[A]]
todef at(index: I): Lens[S, A]
- change
At
instance forSet
andISet
fromLens[S, Option[Unit]]
toLens[S, Boolean]
- remove
Index
instances for bit indexing primitiveLong
,Int
,Char
,Bye
frommonocle-core
- add
monocle-refined
module withAt
instances for bit indexing primitiveLong
,Int
,Char
,Bye
#291 (thanks to fthomas and julien-truffaut)
Deprecation
- deprecate
theseDisjunction
totheseToDisjunction
see - deprecate
nelAndOneIso
tonelToOneAnd
see - deprecate
sum
tochoice
andproduct
tosplit
#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
Optimisation
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 inlaw
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 experimentalstate
module see - add
void
forOptional
,Traversal
,Fold
andSetter
see - add
Setter
constructor usingscalaz.Contravariant
andscalaz.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)
Maybe
and IList
in interface
Deprecate use of - 1.0.0 replaced
Option
byscalaz.Maybe
but it turns out thatMaybe
advantages are not worth the cost of moving away from scala std. - same between
List
andscalaz.IList
Category
related instances and methods
Add - type classes e.g.
Compose
,Category
,Arrow
,Choice
- methods e.g.
id
,codiagonal
,first
,second
,sum
,product
Macro
monocle.macros.GenIso
generatesIso
for case class with a single accessormonocle.macros.GenPrism
generatesPrism
for sealed trait@Lenses
now supports case classes with type parameters seeLenser
is deprecated, useGenLens
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
ormonocle.syntax._
1.0.0
14 December 2014
Rename Optics
Iso
,Lens
,Prism
,Optional
,Traversal
andSetter
were prepended by a P for PolymorphicSimpleIso
,SimpleLens
,SimplePrism
,SimpleOptional
,SimpleTraversal
andSimpleSetter
lostSimple
- for example,
Lens
was renamed toPLens
andSimpleLens
toLens
- 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 methodsasOptional: 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 typeY
- in 1.0,
composeY
means that you compose with an Optic of typeY
Main method changes
- removed
set
,modify
,setOption
,modifyOption
setF
becameset
setFOption
becamesetMaybe
modifyF
becamemodify
modifyFOption
becamemodifyMaybe
modifyF
becamelift
ormultiLift
depending on the OpticgetOption
becamegetMaybe
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 toOption
by callingtoOption
IList
can be transformed toList
by callingtoList
- benefits: no variance, better scalaz support, safer methods
Simplified type classes
- merged
HeadOption
andTailOption
intoCons
- merged
Head
andTail
intoCons1
- merged
InitOption
andLastOption
intoSnoc
- merged
Init
andLast
intoSnoc1
- removed
SafeCast
as it was simply a way to summonPrism
implicitly - removed
AtBit
and definedIndex[S, Int, Boolean]
whereS
is a numeric type
Macros
- all macros have been moved to
monocle.macros
package mkLens
has been moved tomonocle.macros.internal
, i.e. it is not public anymore. UseLenser
or@Lenses
0.5.1
29 September 2014
Macros
- Add
@Lenses
Macro annotation to generateSimpleLens
automatically for case classes - Add
Lenser
Macro to generateSimpleLens
with a better IDE support than Macro annotation - Deprecate
mkLens
Macro asLenser
is strictly more powerful
Bug Fix
- Fix
SafeCast
betweenString
toInt
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 classesmonocle.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 renamedmonocle.scalaz.Disjunction
to avoid clashes withmonocle.std.Either
- Add
Each
,Index
,Field1
,Head
,Tail
andLastOption
instances forscalaz.OneAnd
- Add
Each
,HeadOption
, andLastOption
forscala.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-1Traversal
.Optional
is a sub class ofTraversal
and a super class ofLens
andPrism
. Composing aLens
and aPrism
creates anOptional
instead of aTraversal
, hence we maintain information that the resulting Optic zooms to an optional object and not a list - Rename
Head
->HeadOption
,Last
->LastOption
,Tail
->TailOption
andInit
->InitOption
- Change
HeadOption
,LastOption
,TailOption
,InitOption
Optic fromTraversal
toOptional
Functions
- Generalize
Reverse
,Tail
andInit
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 aLens
and not anOptional
. This implies thatHead
,Last
,Tail
,Init
can only be defined on elements with a mandatory head, last, tail and init. Implemented on 2-6 tuple andHList
. - Implemented
Reverse
instances on all tuple andHList
. - Implemented
Reverse
,Head
,Last
,Tail
,Init
instances on all tuple andHList
. - Implemented
HeadOption
,LastOption
,TailOption
,InitOption
,Each
,Index
andFilterIndex
for scalazIList
.
Miscellaneous
- Add reverseModify on
SimplePrism
as an alias forgetOption map modify
. - Add syntax for
Getter
,Fold
andSetter
. - Add non symbolic functions to use Optics as operators, e.g.
List(1,2,3) applyTraversal each getAll
instead ofList(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
toField6
instances forHList
- Add
SafeCast
instance forCoproduct
, hence supporting Prism for sealed family - Remove
_1
,_2
,_3
Lens using shapelessGeneric
, since composingtoHList
Iso andFields
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 lessatBit(i: Int)
, Lens to focus on ith Bit. Implemented for Boolean, Byte, Char, Int and LongsafeCast
, Prism defining a safe down casting between two types. Implemented for most primitive type and Stringcurry
anduncurry
, Iso for functions with up to 5 parametershead
andlast
, Traversal to the first and last element respectively. Implemented for std List, Vector, Stream, Option and Stringtail
andinit
, Traversal to all elements except first and all elements except last respectively. Implemented for std List, Vector, Stream and Stringreverse
, Iso that reverses the order of elements. Implemented for std List, Vector, Stream, String and scalaz Treeindex(i: Int)
, Traversal to focus on ith element. Implemented for std List, Vector, Stream, Map and Stringeach
, Traversal to focus on all elements. Implemented for std List, Vector, Stream, Option, Map, String, pair and triple of same type and scalaz treefilterIndex(predicate: Index => Boolean)
, Traversal to focus on all elements with index verifying predicate. Implemented for List, Vector, Stream, Map and Stringat(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