Skip to content

Releases: sagifogel/Proptics

v0.5.2

20 Oct 20:20
16f067c
Compare
Choose a tag to compare

What's Changed

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

11 Oct 17:59
Compare
Choose a tag to compare

What's Changed

v0.5.0

08 Jul 10:50
4a3a697
Compare
Choose a tag to compare

What's Changed

  • support methods with spire type classes for Scala 3 (#213) @sagifogel

v0.4.3

28 May 20:10
e19c6b0
Compare
Choose a tag to compare

What's Changed

v0.4.2

05 Apr 19:29
Compare
Choose a tag to compare

What's Changed

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

23 Mar 22:01
Compare
Choose a tag to compare

What's Changed

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

10 Mar 22:34
Compare
Choose a tag to compare

What's Changed

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

02 Oct 09:51
Compare
Choose a tag to compare

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

10 Sep 15:24
ab7edef
Compare
Choose a tag to compare

What's Changed

v0.3.1

13 Aug 08:44
effbb98
Compare
Choose a tag to compare

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)))