In this chapter we will look at folds and unfolds as abstractions. In a precise technical sense, folds and unfolds are the natural patterns of computation over recursive datatypes; unfolds generate data structures and folds consume them.
On day 9 we looked at how to update immutable data structure using TreeLoc for Trees and Zipper for Streams. We also picked up a few typeclasses like Id, Index and Length. Now that we are done with Learn You a Haskell for Great Good, we need to find our own topic.
Yesterday we looked at Monad typeclass, which introduces flatMap. We looked at how monadic chaining can add contexts to values. Because both Option and List already have flatMap in the standard library, it was more about changing the way we see things rather than introducing new code. We also reviewed for syntax as a way of chaining monadic operations.
On day 4 we reviewed typeclass laws like Functor laws and used ScalaCheck to validate on arbitrary examples of a typeclass. We also looked at three different ways of using Option as Monoid, and looked at Foldable that can foldMap etc.