[Haskell-cafe] Representation of lenses

Charles Durham ratzes at gmail.com
Tue Jan 27 17:23:34 UTC 2015

You need to sign up for it, but this is a phenomenal talk by simon peyton
jones describing the idea behind lenses the way he understood it.


On Tue, Jan 27, 2015 at 12:18 PM, David Turner <
dct25-561bs at mythic-beasts.com> wrote:

> Hi,
> I'm planning on discussing lenses with some colleagues shortly so I'm
> consolidating some of my notes into a coherent story. At one point I
> found myself describing lenses as a way of packaging up a getter and a
> setter into a single thing. However, this raises the question: why not
> just use a pair (getter, setter)? More precisely, I believe that the
> types (a -> s, s -> a -> a) and (forall f. Functor f => (s -> f s) ->
> a -> f a) are isomorphic. Is that right?
> I see that one advantage of the lens type is that you can use (.) to
> compose them since they're just functions, but that doesn't bother me
> much and it seems I could define another operator to compose (getter,
> setter) lenses and the rest of the machinery would work either way.
> It's also possible that you can't get the full generality of (forall
> f. (s -> f t) -> a -> f b) lenses with getter/setter pairs, although I
> haven't worked through the details yet so don't know either way.
> So, my question is: what is the advantage of representing lenses in
> the way that they are?
> Many thanks,
> David
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150127/878904fa/attachment.html>

More information about the Haskell-Cafe mailing list