Buy this book
Last edited by cherryblossom
November 9, 2022 | History
Lenses are used (in statically typed functional programming languages) to look inside and "modify" nested data structures. They're notoriously hard to learn, but I believe that's a historical accident. This book teaches lenses in a way tailored to beginners.
Publish Date
2018-08-20
Publisher
Leanpub
Buy this book
Edition | Availability |
---|---|
1 |
aaaa
|
Book Details
First Sentence
"Lens libraries, such as Haskell’s Control.Lens or PureScript’s Data.Lens, have the reputation of being hard to learn, or at least hard to learn well."
Table of Contents
Introduction
Optics are useful
Why are optics notoriously confusing?
This book’s approach
Why PureScript?
Getting ready
About the cover
Your problems and questions
Change log
Thanks for the help
1.
Tuples and records (lenses for product types)
1.1.
Tuples
1.2.
Records
1.3.
Composing lenses
1.4.
Composition exercise
1.5.
Types
1.6.
Composition exercise two
1.7.
Lens laws
1.8.
Law exercise
1.9.
What now?
2.
Maps (At lenses)
2.1.
A custom implementation
2.2.
At.at
2.3.
Types
2.4.
Composing At lenses
2.5.
What now?
3.
Optics and refactoring (optional)
3.1.
Architecture
3.2.
Optics
3.3.
Exercise
3.4.
My solution
3.5.
What now?
4.
Operating on whole collections (Traversal, part 1)
4.1.
Working with all the values
4.2.
view
4.3.
Focusing on individual values
4.4.
preview
4.5.
Composing traversals
4.6.
A sort of base class
4.7.
What now?
5.
Single elements in arrays and fixed-size maps (Index)
5.1.
ix, at, and Map
5.2.
Array
5.3.
Types
5.4.
Composition
5.5.
What now?
6.
Sum types (prisms)
6.1.
Using prisms
6.2.
Making a prism
6.3.
Prism laws
6.4.
Value constructors with more than one argument
6.5.
Types
6.6.
Composing prisms
6.7.
Prisms aren’t just for sum types (exercises)
6.8.
What now?
7.
Miscellaneous other optics
Appendices
A cheat sheet for the optic types
Lens
class At
Traversal
class Index
Prism
A catalog of compositions
Lens <<< optic
Prism <<< optic
Traversal <<< optic
At lens <<< optic
Index optic <<< optic
Identifying an optic from type spewage
I see Choice
I see Strong alone
I see Strong and Choice
I see Strong and At
I see Index and Wander
I see Wander alone
Notes
Edition Notes
The Physical Object
ID Numbers
Links outside Open Library
Community Reviews (0)
Feedback?November 9, 2022 | Edited by cherryblossom | Edited without comment. |
November 9, 2022 | Edited by cherryblossom | Edited without comment. |
November 9, 2022 | Edited by cherryblossom | init |
November 9, 2022 | Created by cherryblossom | Added new book. |