Function Reuse is just Wishful Thinking
summary
A concrete claim: reuse comes from abstracting the wrapping context, not reprinting functions for each case. Using Scala typeclasses and simple combinators—wishful thinking by declaring needed ops—this builds lift, lift2 (via currying and a split/apply), flip for List/F interop, flatten/flatMap and ultimately an applicative+flatMap = monad. The example is a PS5 crawler: affordable, cheapest, totalCostF, itemSeller and reviews are sketched and composed; each step compiles conceptually and requires the corresponding typeclass constraints, so the approach works end to end.
AI-written summary · about
chapters (15)
- 0:00Introduction and motivation
- 3:10Problem with context wrappers
- 7:05Wishful thinking in design
- 12:05Introducing functors
- 15:37Lifting functions with functors
- 18:07Introducing applicatives
- 21:12Applicative operations
- 25:33Total cost with applicatives
- 28:43Pure and applicative summary
- 30:08Filtering scam items
- 33:58Introducing flatten
- 36:27FlatMap and monads
- 43:15Monad summary
- 43:57Recap and closing
- 45:20Q&A session
related talks
44mFunction reuse is just wishful thinking
45mFunctional Refactoring: How to Approach It
01h 03mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 4 of 6
29mIntroduction to Recursion Schemes
32mRecursion schemes with Higherkindness
59mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 3 of 6
26mShapeless Party Tricks in the Enterprise
38mRefactoring Recursion
