3 ms·
(1991) needed I must note that the notion of lenses meant by this paper is very different from what is commonly called lenses nowadays. The modern definition o
by kccqzy 5y ago
(1991) needed
I must note that the notion of lenses meant by this paper is very different from what is commonly called lenses nowadays. The modern definition of a lens is a function p a (f b) -> p s (f t) where p is a profunctor and f is a functor. It's the functional programming equivalent of getters and setters, but composable.
- sfvisser 5y agoThat definition is just one of the many possible definitions. And one of the obscurer ones tbh. :) It’s an abstract concept that you can implement in many different ways.
- chas 5y agoBut lenses as functional references are very common in the Haskell world, whereas the only place I've heard of anamorphisms (unfolds) being referred to as lenses is in this paper. It also confused me quite a bit when I first ran into it, but the name just comes from the notation used in the paper. It is super hard to google for other references to anamorphisms being called lenses for short though because of yet another unrelated concept: https://en.wikipedia.org/wiki/Anamorphic_format https://en.wikipedia.org/wiki/Anamorphic_format
- hither_shores 5y agoExplicit getter-setter lenses and profunctor lenses are not quite the same thing, although they happen to be equivalent in Haskell. For example: the getter-setter encoding only works when you have diagonals (~ copying data).
- ebingdom 5y ago> The modern definition of a lens is When you say "the modern definition of X is Y", it tends to suggest that the older definition is no longer relevant or useful, even though I know that's not what you mean. So to clarify for everyone here, and to reinforce your first sentence, these are just unrelated concepts that happen to use the same term "lens". The lenses in this paper are still as relevant as ever, but these days they are usually called "unfold" (or "anamorphism" for the category theorists).