Effects as Capabilities
summary
A simple guess-the-number program becomes a capabilities demo: random, print and read effects are refactored into implicit parameters (context functions) and invoked via small helpers, while concrete handlers/prompt implementations provide a real JVM RNG, a test RNG, a dev/null printer and a composite TTY handler; tests run deterministically. The claim is that this keeps direct style code unchanged at the term level while tracking effects in types; trade-offs include eager conversion that blurs values vs computations and loss of referential transparency.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:05Capabilities and direct style
- 3:11Guess-a-number game
- 5:58Side effects critique
- 9:31Monads drawbacks
- 13:00Scala’s capabilities
- 15:06Random numbers capability
- 17:29Combinators and helpers
- 18:53Computations vs values
- 20:18Handlers and prompts
- 22:20Recap so far
- 23:00Print line capability
- 25:31Read input safety
- 26:54Composing capabilities
- 27:56Testing with handlers
- 28:38Summary
- 29:20Common questions and drawbacks
related talks
33mRethinking Effects with Effect Systems
51mEffects: to be or not to be?
26mYo Dawg, Heard You Want To FlatMap Your Direct-Style
50mFunctional Programming with Effects
30mLive coding session with James Douglas
46mFunctional effects in perspective
58mEffect-Oriented Programming
31mSide-effects are not your friend
