John Wiegley: Putting Lenses to Work

Channel:Bay Area Haskell · Length:47:18 · Published:2017-04-22 · Views:12612

Watch on YouTube

Summary

John Wiegley's BayHac 2017 talk walks through Haskell lenses by example, showing many practical uses beyond simple record access. It is aimed at people who want to become productive with the lens library.

Why HN recommends it

HN recommends it as the fastest way to learn lenses by example, with far-out examples later on.

you can learn enough lens to be productive in 1 hours with this talk without reading docs at all — HN, 2020

Functional programming

Subtitles (excerpt)

responsible hello everybody come to hear about lenses um this talk will not assume any prior experience or understanding of lenses there will be no Theory today I will not delve into lens types and most of the operators I won't touch either I work at BAE Systems my name is John Wigley we do research there and we use Haskell for a lot of the projects we do and in every single Hospital project we have there we use lenses and not because there's that one guy who thinks every project needs to have lenses in it but because all of us on the team have found they're extremely useful um so I kind of want to show you how we use lenses that work not all the things that this can do you can learn a lot of that in from other blog posts but there's sort of a core set of killer apps for lens that it does better than almost any other approach I want you to see that part of life so this is what I'm going to cover if I have all the time so lenses and prisons just to get some Basics out of the way traversals when the power of lens starts really kicking in um and then map and state which those are the two killer ones those are the ones where once you combine lenses prisms maps and state you've already used

On Hacker News

As with anything Haskell, one could simply reply with "here's the formal definition." But in easily digestible terms, it's a way to narrow your view over a collection to a subset that satisfies some property, and perhaps perform some operations on that subset. This video presentation (with a very humorous audience dynamic, might I add) serves as a great introduction by example: [VIDEO] — turboponyy, 2024-07
and you can learn enough lens to be productive in 1 hours with this talk without reading docs at all. You can skip the theory and go straight to usage: [VIDEO] — platz, 2020-06
Definitely agree on lenses being one of the more mind blowing things I've encountered and eventually grokked in programming. I would also recommend [VIDEO] as a good video on lenses in part because the latter portion has some pretty far-out examples of that deep well you mentioned. — lgas, 2022-11
Good examples in "Putting lenses to work" by John Weigley: [VIDEO] Then for a great book that gives a great understanding see Chris Penner's amazing and fun "Optics by example: [LINK] — ParetoOptimal, 2022-06
> Lenses let you do some amazing things, but I think most of their existence is just thanks to how truly horrible (nested) record field access and updates were. Only for the most basic uses. Architecting programs as folds or traversals can be powerful. One simple example of lenses i can think of being useful for more than record access is: > sumOf (folded . folded) [Just 1, Just 2] 3 More are in … — ParetoOptimal, 2022-06

Related videos