Index your State for Safer Functional APIs
summary
Claims that using IndexedState in Scala (via Scalaz/StateT) enforces API call order at compile time rather than relying on runtime checks. Demonstrates transforming a mutable-style connection/cache API into an immutable, indexed-state API that threads a cache through Future-based effects and rejects invalid call sequences (e.g., update before lock) by failing to compile. Shows types, flatMap mechanics, contravariance benefits, and a small transactional cache/lock/update/commit example that works under the indexed-state model.
AI-written summary · about
chapters (7)
- 0:00Identifying API flaws
- 1:47Immutable API design
- 3:22Basics of the state monad
- 7:34State transformers
- 10:46Introduction to indexed state
- 13:34Enforcing state transitions
- 16:54Trade-offs and conclusion
related talks
31mBoring use cases for exciting types
39mShared State In Pure Fp When A State Monad Won't Do
34mThe Art of Functional State Management
38mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 5 of 6
47m10 TIPS TO WRITE FAST STACK-SAFE FUNCTIONAL CODE IN SCALA
29mLearning Scalaz
34mMonad Transformer State
43mMutating the immutable
