[Haskell-cafe] Representation of lenses

Erik Hesselink hesselink at gmail.com
Tue Jan 27 21:45:22 UTC 2015

On Tue, Jan 27, 2015 at 9:29 PM, David Turner
<dct25-561bs at mythic-beasts.com> wrote:
> On 27 January 2015 at 17:23, Charles Durham <ratzes at gmail.com> wrote:
>> 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.
>> https://skillsmatter.com/skillscasts/4251-lenses-compositional-data-access-and-manipulation
> Thanks, I think that was exactly what I needed to know.
> If I understand the key section right, you can do all that stuff with
> a straight get/set pair but it'd be desperately inefficient, so then
> you add an update function, and then one at Maybe and [] and IO and
> they all start to look the same so you generalise to all Functors, and
> then you discover that using Const you get a getter, and Identity
> gives you a setter, so you can throw them away and end up with a lens
> as we know it.
> And then you generalise it in about a billion other directions and you
> end up with the lens library!

Just wanted to note that 'lens' is not the only lens library. There
are many others (data-lens, fclabels, data-accessor, ...) and most use
a getter/setter or getter/modifier combination.


More information about the Haskell-Cafe mailing list