Type-Driven Design with Swift
summary
Shows a concrete Swift pattern that turns runtime checks into compiler-enforced guarantees by modeling a login flow and a trip-tracker UI with domain types. Implements failable initializer wrappers for Email and Password, uses Result/enum for auth errors, marks SignedInUser as Decodable to prevent bogus construction, and replaces optional-laden User with a tagged union. Demonstrates a nonempty stops type and a parser-frontier for permissive inputs. Code examples use Swift, UIKit/SwiftUI and JSON decoding and succeed in making incorrect flows fail at compile time.
AI-written summary · about
chapters (12)
- 0:00Introduction to type-driven design
- 1:20The fragility of traditional validation
- 6:19Compiler errors as safety guarantees
- 11:08The type-driven development cycle
- 15:54Parsing vs validation
- 20:26Refining types and domain modeling
- 25:15Advanced type modeling
- 30:44Managing data flow with types
- 35:01The lifecycle of type-driven phases
- 37:12Type safety in UI development
- 44:29Postel's Law and API design
- 50:00Conclusion and summary
related talks
30mLeveraging Swift's Type System
40mLeveraging Swift’s Type System
29mAlgebraic Data Types in Swift
23mLessons in Swift Error Handling and Resilience
31mMaking the Most Out of Swift
50mWriting Swift code with great testability
39mSwift and You
48mLearning From Our Elders: Applying functional insights without losing Swift
