Lens Tutorial - Stab & Traversal (Part 2)

In the first article in the series about lenses, we’ve looked at the motivation behind the lens library, and we also derived the basic type of Lens s a. In this article we’ll go deeper and explain the reasoning beheind the more generic Lens s t a b type. We’ll also take a look at how we can get a multi focus lens using a Traversal. Just to reiterate, here’s how looks the type we derived in the previous article.

Read More →

Lens Tutorial - Introduction (part 1)

This article is the first in the upcoming series that aims to explain the Haskell’s lens library and the ideas behind it in an approachable way. Don’t worry if you’re new to Haskell, the only prerequisites here should be understanding of the Functor type class, and understanding how records and algebraic data types work in Haskell. We won’t be using the lens library in this article yet. The API we’ll develop will be exactly the same, but for the sake of learning I’ll try to show you how everything works and why it works by re-implementing it from scratch.

Read More →