Optics By Example: Functional lenses in Haskell

Optics By Example: Functional lenses in Haskell

English | 2020 | 420 Pages | PDF | 10 MB

A comprehensive example-driven guide to optics. Examples in Haskell, but adaptable to other languages.
Become a data-manipulation wizard using optics to manipulate data!
This book takes you from beginner to advanced using Lenses, Traversals, Prisms, and more!
Optics By Example is a one-stop comprehensive guide to mastering optics in functional programming languages. It covers everything you need to know to go from complete beginner to advanced. Each topic is accompanied by copious examples and exercises!
See the Sample for a complete list of chapters, but here are some highlights:

  • Complete introductions to Lenses, Folds, Traversals, Prisms and Isos
  • Learn the magic of Indexed optics
  • Composing Optics
  • Lenses & Records
  • Fixing “The Record Problem”
  • Application design techniques using Classy optics
  • Breakdowns of laws and limitations for each optic type
  • Virtual lenses
  • Validation lenses
  • A guide to fully polymorphic optics
  • A guide to “operator-style”
  • Learn to query, filter, and aggregate data with surgical precision
  • Learn how to use higher-order optics effectively
  • Learn to write custom versions of all optics types for your own applications
  • Manipulate data types with a clean and consistent interface
  • Learn the monadic DSLs for using lenses in real monad stacks

WHY OPTICS?
Optics have become a wonderful and powerful new way of working with immutable data structures. They’re almost a necessity at this point; and the benefits they bring in terms of re-usability, simplification of code maintenance & refactoring, and expressivity are immense! However, learning to use optics can be tricky or even intimidating at first, it’s not always clear how to build up a large complicated mutation or query from the building blocks of optics. Optics by example is here to help!
This book is great as a first guide to optics, as a reference guide for discovering and mastering the optics you need for day-to-day problems, and as a springboard into new ideas and tools which you may not have even heard of.