Lenses: fields as values


Details
"Lenses: fields as values" by Seth Tisue (Northwestern University)
Lenses aren’t in the Scala standard library, but two libraries provide them: Scalaz and Miles Sabin’s Shapeless. I’ll show how you to use the Shapeless version, and we’ll look at how it’s implemented.
A lens represents a readable and “settable” location in a possibly nested immutable object. (“Settable” is in quotes because we make a new object rather than mutating the old one.)
This may interest you if:
...you use immutable objects
...you use nested immutable objects
...you want to abstract over different fields in your immutable objects
...you're interested in functional programming
This will overlap a lot with Ed Kmett's 2011 talk on the same subject. If you saw and completely grasped Ed's talk, you might not learn much from this one. Compared to Ed's, my take will be more elementary and less formal. (And I'll be covering only lenses themselves, not bringing in the state monad too.)
hangout afterwards at Catalyst (300 Technology Square, by Main & Albany)
Note this is in a different room than usual.
It's easy to get lost in the Stata Center, so allow some extra time. Enter the building at 32 Vassar Street, opposite the sign for 43 Vassar Street. Take the elevator (under a sign saying "Alexander W Dreyfoos Building" to the fourth floor. (If you find yourself instead in the Gates Building part of the Stata Center, you will need to walk to the other end of the buildling to the Dreyfoos elevators.) Turn left out of the elevator, then immediately turn right, go through the double doors, walk almost all the way across the orange carpeted area, and look for room 32-G449 on your right.
We have had recurring trouble with the building doors being locked despite our requests. If this happens, usually there are enough people coming and going that if you wait a few minutes, someone will enter or leave and you can go in.

Lenses: fields as values