A Modern History of Lenses
Lenses are bidirectional transformations between pairs of connected structures. Asymmetric lenses, where one of those two connected structures is taken to be primary, have been extensively studied. Lenses were first proposed to solve the view-update problem of tree-like data structures by Foster et. al and have also been applied to the construction of a relational database query language. Other work has altered the primitive structure of lenses to achieve different results.
The lens data structure has recently gained increasing attention as a technique for generic programming on algebraic data types. Lenses have been written about using various programming languages including Haskell and Scala and using many different representations.
In this talk, we will look at the lens data structure and its representations, then discuss the trade-offs and motivations for revisions. Some of the theory is discussed, before we look at the most recent incarnation of lenses by Edward Kmett, which take the Twan van Laarhoven representation, apply it to practice and also develops the theory further resulting in to the Control.Lens module.
Control.Lens resolves many of the practical limitations of lenses that had been encountered by earlier implementors by exploiting some insights that had not previously been published.
E. A. Kmett, Lenses, Folds and Traversals available at https://www.youtube.com/watch?v=cefnmjtAolY
Twan van Laarhoven; Institute for Computing and Information Sciences – Intelligent Systems, Foundations Seminar; May 2011
Control.Lens available at https://hackage.haskell.org/package/lens
Russell O’Connor; Polymorphic Update with van Laarhoven Lenses available at https://r6.ca/blog/20120623T104901Z.html
Russell O’Connor; Functor is to Lens as Applicative is to Biplate: Introducing Multiplate; 2011
Foster, J. Nathan and Greenwald, Michael B. and Moore, Jonathan T. and Pierce, Benjamin C. and Schmitt, Alan; Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem; May 2007.
Bohannon, A. and Pierce, B.C. and Vaughan, J.A.; Relational lenses: a language for updatable views; 2006
Foster, J.N. and Pilkiewicz, A. and Pierce, B.C.; Quotient lenses; 2008
Jones, M.; Functional programming with overloading and higher-order polymorphism; 1995