Duality and How to Delete Half (minus ε) of Your Code
summary
Claims that 96% minus ε of duplicated recursion-schemes code disappears by abstracting folds/unfolds over comonads and arrow categories, collapsing monadic, cofree, para/histo variants into one generalized cata. Implements this in Scala using Cats, kind-projector, typelevel/Dotty features and ports a Haskell dualizer to Scala. Demonstrates concrete types (CoFree, tuple comonad, Kleisli-like arrows), compiles with typelevel Scala, and notes tradeoffs: naming headaches, poorer type inference and compile-time cost, but no runtime penalty thanks to erasure.
AI-written summary · about
chapters (10)
- 0:00Talk introduction
- 1:06About the speaker
- 2:29What is a catamorphism
- 5:40Expanding the library
- 9:10Library growth problem
- 9:54Abstracting over comonads
- 12:43Abstracting function arrows
- 15:32Duality in recursion
- 18:00Kind polymorphism solution
- 20:28Final thoughts and summary
related talks
01h 02mPrinciples and tools to cleverly model your data in Scala
01h 14mBeyond Free Monads
32mRecursion schemes with Higherkindness
44mCAN WE FREE CONCURRENT PROGRAMMING FROM THE MONADIC STYLE
52mCategory Theory Through Functional Programming (part 1/3)
38mRefactoring Recursion
36mPoint-Free or Die: Tacit Programming in Haskell and Beyond
54mCategory Theory Through Functional Programming (part 3/3)
