Peeling The Banana: Recursion Schemes From First Principles
Recursion is at the heart of every functional programmer’s toolkit, but with it comes a lot of boilerplate. In the early 1990s, the seminal paper Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire (Erik Meijer, M.M. Fokkinga, and Ross Paterson) introduced a little-known technique known as recursion schemes. This technique makes recursion generic, removing much of the boilerplate associated with it, and cleanly separating business logic from recursive traversal. It paved the way to many different schemes, each for their own kind of recursive traversal.
This talk explores the technique of recursion schemes and how to use it. We start with primitive recursion, briefly diving into folds, before deriving the catamorphism, a specific recursion schema for the right fold. We shall see that there is a rich zoo of recursion schemes for different types of folds, unfolds and more.
Subscribe to the Lambda World YouTube channel to be updated when new videos are added.