Lenses for the Mere Mortal: PureScript Edition

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

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. That’s not to say that lots of people haven’t learned them. Many have. But many others have had a hard time, me included. This book teaches lenses differently. I don’t claim I’ve found the single best way to teach them, just that this way is worth a try, whether you’re learning lenses for the first time or you’ve bounced off some other tutorial that didn’t work for you.

Author(s): Brian Marick
Publisher: Lean Publishing
Year: 2018

Language: English
Pages: 90
Tags: Haskell, lenses, functional programming

Table of Contents......Page 3
Introduction......Page 6
Optics are useful......Page 7
Why are optics notoriously confusing?......Page 9
This book's approach......Page 10
About the cover......Page 11
Change log......Page 12
Thanks for the help......Page 13
Tuples and records (lenses for product types)......Page 14
Tuples......Page 15
Records......Page 16
Composition exercise......Page 18
Types......Page 19
Composition exercise two......Page 22
Lens laws......Page 24
What now?......Page 25
A custom implementation......Page 26
At.at......Page 28
Types......Page 30
Composing At lenses......Page 32
What now?......Page 35
Optics and refactoring (optional)......Page 37
Architecture......Page 38
Optics......Page 40
Exercise......Page 42
My solution......Page 43
What now?......Page 45
Working with all the values......Page 46
view......Page 48
Focusing on individual values......Page 50
Composing traversals......Page 51
What now?......Page 56
ix, at, and Map......Page 57
Types......Page 59
Composition......Page 60
What now?......Page 61
Using prisms......Page 62
Making a prism......Page 64
Prism laws......Page 66
Value constructors with more than one argument......Page 67
Types......Page 69
Composing prisms......Page 70
Prisms aren't just for sum types (exercises)......Page 75
What now?......Page 76
Miscellaneous other optics......Page 77
Appendices......Page 78
class At......Page 79
Traversal......Page 80
class Index......Page 81
Prism......Page 82
Prism <<< optic......Page 85
At lens <<< optic......Page 86
Index optic <<< optic......Page 87
I see Strong and At......Page 88
I see Wander alone......Page 89