Preface lens are one of the most popular, yet confusing aspect of Haskell. To be fair, I could never really understand how they work. This series of posts is going to be my attempt to understand lens, the ideas and implementation details, and also the lens package. I hope I’ll learn something in the process, and you will too (hopefully!). Before we begin, I’d like to give a heads-up about few things, so you know what lies ahead.
Inspiration This post is written after I saw this tweet Every functional programming tutorial: > OK, we're going to talk about currying. Currying is when you break down a function tha- scrolls down > const Y = f => (g => g(g))(g => f(x => g(g)(x))) pic.twitter.com/EPHH9SG5ay — Ben Howdle (@ben_howdle) February 21, 2018 And realized that we need a simpler tutorial to understand currying, the logic behind it, the nuances and the usage.
Foldable Foldable represents data structure type class that provides a generalisation of list folding (foldr and friends). provides operations derived from list foldings to arbitrary data structures You can use a Foldable where you would have to traverse a dataset and reduce it to a single result. Get the product of a list Get the max path value in a tree In short, fold can be understood as function to reduce a large structure into a single result.
Understanding Applicative functors would require some understanding about Functors and Monads. We shall try to look at brief definitions for the scope of this article. Functor According to Haskell docs, a functor is simply something that can be mapped over. In other words, it is an abstraction for a context with the ability to apply a function to all the things inside the context. The context can be defined as container, computation etc.