Skip to content

Latest commit

Β 

History

History
57 lines (44 loc) Β· 2.71 KB

File metadata and controls

57 lines (44 loc) Β· 2.71 KB

Introduction to the Java Optics

Functional Optics for Modern Java series

Part 1. The Immutability Gap: Why Java Records Need Optics

Part 2. Optics: Lenses, Prisms, and Traversals in Practice

Useful links:

JEP 468. Derived Record Creation

Runnable Demos on GitHub.


                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Fold   β”‚  (read-only, zero-or-more)
                    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                         β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                     β”‚
         β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
         β”‚ Getter  β”‚          β”‚ Traversal β”‚  (read-write, zero-or-more)
         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
              β”‚                     β”‚
              β”‚               β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
              β”‚               β”‚           β”‚
         β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”΄β”€β”€β”€β”
         β”‚  Lens   β”‚    β”‚  Affine   β”‚ β”‚Setter β”‚
         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚         (zero-or-one)
              β”‚               β”‚
              β”‚         β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
              β”‚         β”‚   Prism   β”‚
              β”‚         β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
              β”‚               β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
                 β”‚   Iso   β”‚  (exactly-one, reversible)
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Further reading: Higher-Kinded-J. Composable Effects and Advanced Optics for Java