Recursion schemes with Higherkindness
summary
Live refactor of list fold/unfold into generic recursion schemes using Scala, Cats and the Droste ideas, extracting a project functor (option of tuple), mapping recursion via Functor.map and then embedding back. Examples compute product of [1,20] = 200 and factorial(4) = 24 by composing anamorphism and catamorphism without allocating the intermediate list. Code compiles and runs; initial naive version is inefficient but the final Droste-style abstractions remove boilerplate and let the same algebra operate over different recursive structures.
AI-written summary · about
chapters (10)
- 0:00Introduction to talk
- 1:08Why recursion schemes matter
- 2:42FoldRight and Unfold basics
- 8:45Refactoring fold and unfold
- 13:10Abstracting over data structures
- 21:16Generic foldRight implementation
- 24:43Using foldRight generically
- 25:54Unfold to anamorphism
- 28:57Combining unfold and fold
- 30:43Conclusion and unconference
related talks
56mAn introduction to recursion schemes
38mRefactoring Recursion
29mIntroduction to Recursion Schemes
34mPeeling the Banana: Recursion Schemes from First Principles
47mHands on With Recursion Schemes - Part 1 of 2
37mGoing bananas with recursion schemes for fixed point data types
23mDuality and How to Delete Half (minus ε) of Your Code
51mGoing bananas with recursion schemes for fixed point data types
