Optics By Example (@opticsbyexample) header
Optics By Example (@opticsbyexample) profile picture

The lenses book for Haskell and other functional programming languages by @chrislpenner https://xitter.gq/t.co/HOXV9Vvkt5

Joined September 2019
Photo by Optics By Example (@opticsbyexample)Photo by Optics By Example (@opticsbyexample)Photo by Optics By Example (@opticsbyexample)Photo by Optics By Example (@opticsbyexample)
🔍Optics By Example has LAUNCHED! 🥳🎉 Go grab your copy! leanpub.com/optics-by-exampl… Learn about the magic of Lenses, Traversals and Folds ✨ Thanks to everyone in the community who's helped make this a reality 😀 RTs appreciated ✅
Optics By Example is on Sale! For a limited time you can grab the comprehensive guide to lenses, prisms, traversals and more for only $30! That's 50% off the suggested price 😵 If you were waiting for a sale, this is it! 😄 leanpub.com/optics-by-exampl…
2
2
3
12
In case you missed it the first time around: 🔎Optics By Example is hot off the (digital) presses! Go grab it on leanpub, complete with exercises, in pdf, epub, or mobi 😄 Reviews are positive so far and I'd love to hear what you think leanpub.com/optics-by-exampl…
4
7
Day 2 of #AdventOfOptics and going strong!
Day 2 of #AdventOfOptics was a doozy, but it's done! chrispenner.ca/posts/advent-… Lots of indexed optics in this one, and some fun optical MonadState stuff too! Hoping day 3 is a bit less imperative 😅 Check out @opticsbyexample for more lensy goodness! #AdventOfCode
2
To celebrate the launch of #OpticsByExample later this month I'm attempting to solve #AdventOfCode puzzles using only optics (for better or worse). Day 1 went wonderfully: chrispenner.ca/posts/advent-… Add your email here to hear when the book launches: leanpub.com/optics-by-exampl…
Hey everyone! I'll be answering any and all lenses & optics questions you have for the next 2 hours or so. I welcome questions on how to accomplish certain tasks, the lenses ecosystem, even helping with specific problems you're solving at the moment. Bring it on!
2
2
1
7
I wrote a huge chunk about Isos today! very excited to get it in front of people! There are powers untold hidden deep within the unknowns of the lens library, let me be your guide! 🧭🏴‍☠️🗺️
3
New chapters just released! Learn to write custom traversals from scratch! Get an introduction to Van Laarhoven encoding, learn how to manipulate lists and maps using lenses, and get an introduction to Prisms too! patreon.com/posts/31174088
4
Did you know prisms can be used for any pattern matching, not only Sum-type Constructors? Here's a fun prism which matches on the "pattern" of being divisible by a (non-zero) integer. Chapters on prisms dropping later this week! patreon.com/ChrisPenner
2
1
7
Meaning of course, that prisms can help you pass your next job interview! Here's a little diddy you might recognize...
1
2
1
12
Updates for #OpticsByExample coming up in just a few days! Learn to write custom traversals by hand, when it's okay to break traversal laws, using lenses to work with indexed data, and an introduction to Prisms: pattern matching using optics! Early Access: patreon.com/chrispenner
1
2
Working hard to come up with small, motivating, and comprehensible Prism examples; getting tricky to find the appropriate subset that's reasonable to teach without getting too archaic! After that, just Isomorphisms to go and the book will be ready for an initial release!
1
3
Did you know that you can index into functions by argument type using `ix`? It's true! You can set or mutate the return value of a function given a specific argument. Here's an example of a really silly way to write a safe division function:
3
4
31
Examples that are a bit more practical are coming to #OpticsByExample soon!
1
Traversals have landed! I just published some new chapters covering higher-order Folds, Filtering, and Traversals! Learn the sacred art of the mighty and noble traversal 😎 You can pick it up by signing up here: patreon.com/ChrisPenner Cheers everyone!
2
2
14
Did you know you can project functions under Prisms using `outside`? You can then modify only the portion of the function which runs when arguments match the Prism! Here's an example where we make some edits to the failing portion of an error handler:
1
1
3
We can use this Prism trick to fix the partial version of `tail` from the Prelude. We focus on only the portion of the `tail` function which runs when the argument is empty, then set the result of that function to [ ]!
Teaching Traversals using Dragon Ball Z? Yes I think so... #OpticsByExample
3
12
#OpticsByExample tip of the day! Did you know that you can use most optics from `lens` directly as a custom traversal? Check out some examples! Learn optics with larger-than-tweet sized examples: patreon.com/chrispenner gist.github.com/ChrisPenner/…
2
2
Having a little too much fun inventing legally ambiguous Poogeymanz for book examples 👾
1
5
Another reason to get the book in early access: you get to see my gorgeous ASCII art diagrams before I replace them with nicer ones👨‍🎨 patreon.com/chrispenner
2
3
8