Skip to content

Lenses, Folds and Traversals: An Introduction to the Lens Library

Photo of Gershom B
Hosted By
Gershom B.
Lenses, Folds and Traversals: An Introduction to the Lens Library

Details

Edward Kmett will introduce his lens library, which provides a highly composable toolbox for accessing and modifying multiple parts of data structures.

From simple beginnings, starting with building blocks such as fmap and (.), we will build up combinators suitable for working with a wide array of data structures. These generalize the notions you already know how to use into a form that is easier to compose, and simultaneously allow them to be used for monomorphic containers such as Data.Text. All without compromising on your ability to reason about them using laws!

Once we've built up some foundations, we'll do a bit of a deep dive, exploring consequences of this design. We will discuss the efficient generic programming programming framework exported by lens, and type-safe Traversal-based zippers.

Familiarity with the Applicative and Traversable classes from the Haskell base libraries will be helpful (links provided below), but a basic understanding of the concepts will be introduced we go along. Attendees should expect to be gobsmacked with a newfound appreciation for the power of a little (or a lot of) abstraction.

Useful (but not mandatory) references:

The lens library and documentation: http://hackage.haskell.org/package/lens A previous, more introductory talk on how to use the lenses Edward Kmett wrote for the scalaz in the Scala programming language: https://www.youtube.com/watch?v=efv0SQNde5Q The original Applicative paper: http://www.soi.city.ac.uk/~ross/papers/Applicative.pdf Lots of information on Traversable: http://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf A write-up of this talk, as presented at the Bay Area Haskell Users Group: http://google-opensource.blogspot.com/2012/10/lenses-folds-and-traversals-haskell.html

Photo of New York Haskell Users Group group
New York Haskell Users Group
See more events
Pivotal Labs
841 Broadway, 8th Floor · New York, NY