<div dir="ltr">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.<div><br></div><div><a href="https://skillsmatter.com/skillscasts/4251-lenses-compositional-data-access-and-manipulation">https://skillsmatter.com/skillscasts/4251-lenses-compositional-data-access-and-manipulation</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 12:18 PM, David Turner <span dir="ltr"><<a href="mailto:dct25-561bs@mythic-beasts.com" target="_blank">dct25-561bs@mythic-beasts.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm planning on discussing lenses with some colleagues shortly so I'm<br>
consolidating some of my notes into a coherent story. At one point I<br>
found myself describing lenses as a way of packaging up a getter and a<br>
setter into a single thing. However, this raises the question: why not<br>
just use a pair (getter, setter)? More precisely, I believe that the<br>
types (a -> s, s -> a -> a) and (forall f. Functor f => (s -> f s) -><br>
a -> f a) are isomorphic. Is that right?<br>
<br>
I see that one advantage of the lens type is that you can use (.) to<br>
compose them since they're just functions, but that doesn't bother me<br>
much and it seems I could define another operator to compose (getter,<br>
setter) lenses and the rest of the machinery would work either way.<br>
<br>
It's also possible that you can't get the full generality of (forall<br>
f. (s -> f t) -> a -> f b) lenses with getter/setter pairs, although I<br>
haven't worked through the details yet so don't know either way.<br>
<br>
So, my question is: what is the advantage of representing lenses in<br>
the way that they are?<br>
<br>
Many thanks,<br>
<br>
David<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>