Managing Side Effects with Swift
summary
Claims that Swift can give deterministic, testable core logic while still performing real IO by: extracting pure logic, using dependency injection for console/random, or describing effects as effect descriptors (an enum with continuations) interpreted by an effect handler. Demonstrates a console number‑guessing game and echo program that run correctly and a testing style that steps through each observable effect, avoiding heavy mocking (mentions Mockingbird) and bridging to async with withCheckedContinuation and macros to restore direct style. Tests validate effect order and return a final playAgain Boolean.
AI-written summary · about
chapters (9)
- 0:00Managing side effects in Swift
- 6:43Pure vs effectful functions
- 10:17Divide and conquer side effects
- 12:44Dependency injection for control
- 18:28Effect descriptors approach
- 27:38Testing with effect descriptors
- 31:10Direct vs continuation passing
- 34:04Recap and approach choice
- 36:11Q&A
related talks
01h 00mLogic vs. side effects: functional goodness you don't hear about
39mSwift and You
50mWriting Swift code with great testability
55mEmerging Best Practices
48mLearning From Our Elders: Applying functional insights without losing Swift
01h 01mSwift Driven Development
31mMaking the Most Out of Swift
34mStraying From the Happy Path: Taking Control of Errors in Swift
