Functional Error Handling
summary
Claim: exceptions break composability because they aren’t part of the type system. Implementation: replace raises with a generic Result type (frozen dataclass) with distinct Success and Failure holding answer or error, catch exceptions into failures, and compose functions with a member bind that forwards unwrapped success or short‑circuits failures. Tooling: demonstrates the third‑party returns library and a comprehension‑based do notation for multiple args. Caveat: mypy needs an extension to fully track error unions and the extension can be fiddly to get working.
AI-written summary · about
chapters (10)
- 0:00Functional error handling intro
- 2:10Composability principle
- 5:02Error handling history
- 7:11Exceptions fail at scale
- 10:26Functional error handling approach
- 13:21Introducing Result type
- 17:06Composing with Result
- 21:26Simplifying bind and do
- 26:29Languages adopting functional errors
- 27:53Q&A
related talks
39mFunctional Error Handling in Python
31mBeyond Try-Except: The Frontier of Python Error Handling with Monads and Railway Magic
01h 26mBeyond Python Enhanced Generators
31mDon't Do This
39mFunctional Programming in Python
18mExploring Function Annotations
37mType Hints: Putting more Buzz in your Fizz
30mFunctional Programming in Python
