Releases: sagifogel/Proptics
Releases · sagifogel/Proptics
v0.5.2
What's Changed
- update Scala version o 2.13.10 (#246) @sagifogel
This fixes CWE-502 in Scala 2.13.x before 2.13.9
and fixes Scala 2.13.9 regression affecting binary compatibility.
v0.5.1
What's Changed
- rename reuse method of Review to use (#237) @sagifogel
v0.5.0
What's Changed
- support methods with spire type classes for Scala 3 (#213) @sagifogel
v0.4.3
What's Changed
- forall fix (#208) @sagifogel
- add cotraverse/zipWithF to AppliedLens (#203) @sagifogel
- remove isEmpty/nonEmpty from Lens, add failover to AffineTraversal op… (#201) @sagifogel
v0.4.2
What's Changed
- addition of syntax to OptionOptics/EitherOptics (#192) @sagifogel
import proptics.syntax.all._
import proptics.instances.all._
List(Some("Some"), None, Some(" Of These Days"))
.foldable
.some
.view
// val res0: String = Some Of These Days
import proptics.syntax.all._
import proptics.instances.all._
List(Some("some"), None, Some(" Of These Days"), None, None)
.foldable
.none
.length
// val res0: Int = 3
import proptics.syntax.all._
import proptics.instances.all._
List(Right("That's"), Left(true), Right(" right"), Left(false))
.foldable
.right
.view
// val res0: String = That's right
import proptics.syntax.all._
import proptics.instances.all._
List(Right(true), Left("That's"), Right(true), Left(" wrong"))
.foldable
.left
.view
// val res0: String = That's wrong
v0.4.1
What's Changed
- add syntax for typeclasses methods (#188) @sagifogel
import proptics.syntax.all._
import proptics.instances.all._
case class Oscars(bestPicture: Map[Int, String])
Oscars(Map(1975 -> "The Godfather: Part II", 2008 -> "No Country for Old Men"))
.lens(_.bestPicture)
.index(1975)
.suffix(": Part II")
.viewOrModify
// val res0: Either[Oscars,String] = Right(The Godfather)
v0.4.0
What's Changed
- improved performance for take/drop for Traversal/Fold (#186) @sagifogel
- Addition of applied syntax (#140) @sagifogel
Lens
final case class Person(name: String, address: Address)
final case class Address(city: String, street: Street)
final case class Street(name: String, number: Int)
val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9)))
person
.lens(_.address.street.number)
.set(308)
// val res: Person = Person(Walter White,Address(Albuquerque,Street(Negra Arroyo Lane,308)))
Traversal
import cats.syntax.semigroup._
import proptics.syntax.all._
import proptics.instances.all._
val hktSupport = Set("Scala", "Haskell")
List("Erlang", "F#", "Scala", "Haskell")
.each
.toWords
.filter(hktSupport.contains)
.over(_ |+| " √")
// val res: List[String] = List(Erlang, F#, Scala √, Haskell √)
Fold
import proptics.syntax.all._
import proptics.instances.all._
val input = List("Say Anything", "My Octopus Teacher", "Name of the Rose")
input
.foldable
.andThen(words.take(1))
.viewAll
// val res: List[String] = List(Say, My, Name)
v0.3.4
What's Changed
- addition of Scala3 macros for Lens/ALens and Prism/APrism (#134) @sagifogel
import proptics.Lens
import proptics.macros.GLens
final case class Person(name: String, address: Address)
final case class Address(city: String, street: Street)
final case class Street(name: String, number: Int)
val personNameLens: Lens[Person, Int] = GLens[Person](_.address.street.number)
val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9)))
personNameLens.set(308)(person)
// Person(Walter White,Address(Albuquerque,Street(Negra Arroyo Lane,308)))
import proptics.Prsims
import proptics.macros.GPrism
sealed trait Request
final case class GET(path: List[String]) extends Request
final case class POST(path: List[String], body: String) extends Request
val webServerPrism = GPrism[Request, GET]
webServerPrism.preview(GET(List("path")))
// Some(GET(List(path)))
webServerPrism.preview(POST(List("path"), "body"))
// None
v0.3.2
What's Changed
- Support scala 3 (#126) @sagifogel
v0.3.1
What's Changed
- change compose/andThen to be aligned with function composition (#116) @sagifogel
import proptics.Lens
final case class Person(name: String, address: Address)
final case class Address(city: String, street: Street)
final case class Street(name: String, number: Int)
val addressLens = Lens[Person, Address](_.address)(person => address => person.copy(address = address))
val streetLens = Lens[Address, Street](_.street)(address => street => address.copy(street = street))
val numberLens = Lens[Street, Int](_.number)(street => number => street.copy(number = number))
val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9)))
compose
val composed = numberLens compose streetLens compose addressLens
composed.set(308)(person)
// Person(Walter White,Address(Albuquerque,Street(Negra Arroyo Lane,308)))
andThen
val composedUsingAndThen = addressLens andThen streetLens andThen numberLens
composed.set(308)(person)
// Person(Walter White,Address(Albuquerque,Street(Negra Arroyo Lane,308)))