Skip to content

Sample implementation of functional lenses in Java

Notifications You must be signed in to change notification settings

desseim/java-lenses

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of a functional lens in Java, based on this answer [1], given by Daniel Sobral at SO. 

Lense is a convienient way to access and update immutable data structures in a functional world.
Lenses are very useful, when you have a deep hierarchy of objects, and you want to update nested elements in an imperative manner (leaving recreation of the whole object hirarchy behind the scenses). 

Lenses in languages with first-class functions is a quite powerful and elegant tool. In Java, unfortunatelly, you have to use anonymous inner classes to represent function objects, and lenses lose the most of their's glitter.

In some cases, however, lenses can still be useful. E.g., when you want to transform an object, generated by Protobuf builders.

1: http://stackoverflow.com/a/5597750/354067

About

Sample implementation of functional lenses in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 90.8%
  • Scala 6.8%
  • Groovy 2.4%