Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

KacperFKorban/lightlens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ This codebase is now part of https://github.com/softwaremill/quicklens

lightlens

(Experimantal) implementation of lightweight lenses for Scala 3.

The goal of this project is to provide easy to use lenses functionality by adding one import statement.

Example:

import lightlens.*

case class Name(name: String)
case class AdditionalInfo(friends: List[Name], siblingsNo: Int)
case class Person(firstName: Name, age: Int, id: String, additionalInfo: AdditionalInfo)

val bob = Person(Name("Bob"), 25, "12345", AdditionalInfo(List(Name("Mark"), Name("Anna")), 3))

bob.focus(_.age).set(60)
// Person(Name(Bob),60,12345,AdditionalInfo(List(Name(Mark), Name(Anna)),3))
//                  ^^

bob.focus(_.additionalInfo.friends.each.name).modify(_.toLowerCase)
// Person(Name(Bob),25,12345,AdditionalInfo(List(Name(mark), Name(anna)),3))
//                                                    ^           ^

Inspiration

About

(Experimental) implementation of lightweight lenses for Scala 3

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages