Code by Shape
summary
Shows how folding simple ADTs (Either, Option, List) maps to commuting diagrams and then to code: implements a recursive, not stack-safe foldRight for lists, derives the functor view 1 + A and the Option[(A, tail)] encoding, and packs the initial value plus binary op into a single algebra and coalgebra pair. Reconstructs a hylomorphism that reproduces foldRight by mapping and composing but notes composing ana+cata is inefficient while tracing the diagram perimeter gives the efficient recursion scheme.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:18Talk goals and category theory
- 2:44Spatial intuition for code
- 4:53Commutative diagrams
- 6:43Folding lists to diagrams
- 9:13Folding Either and co-products
- 12:46Folding Option and terminal objects
- 15:32Option folding with diagrams
- 17:43Understanding foldRight in Scala
- 24:37From foldRight to Hilah morphisms
- 30:54Recursion schemes and intuition
- 34:10Summary
- 35:35Q&A
related talks
57mSums, Products, Exponents, Monoids, Functors, Oh My!
59mModular Higher-Order Effects
45mDesign Patterns in Scala
36mDiagrammar: Simply Make Interactive Diagrams
16mClojure vs Design Patterns
44mTyped Design Patterns for the Functional Era
55m20000 Leagues under the FreeMonads Coproducts & purely functional DI
52mTidy First? A Daily Exercise in Empirical Design
