Monads, in my Python?
summary
Shows a concrete maybe monad implemented with decorators where div then sqrt pipelines short circuit on None so failures propagate without try/except boilerplate; demonstrates a list monad that applies and flattens results and points out list comprehensions are a monadic pattern; treats context managers as monads by running __enter__/__exit__ around binds; explains monads as the pair bind and unit and gives working Python code for each example, claims reasonable performance in practice though no heavy optimization is shown.
AI-written summary · about
chapters (29)
- 0:00Start
- 0:52What Are Monads
- 1:15Real Life Code
- 2:24Composition
- 3:25Procedures
- 5:47Functions and Pure Functions
- 7:52Big Deal...
- 8:29Awkward Squad
- 9:34Print Fail!
- 11:02Domains (input)
- 11:30Example in Categories
- 12:16Extend the Range
- 12:41New Ranges (output)
- 13:03Extend the Domain and Ranges
- 13:33Extended Domains + Ranges
- 13:44Tedious
- 14:06Map from This Category
- 14:21Functor
- 14:58Interfaces Recap
- 16:53Monadic Values
- 17:20Maybe Monad
- 18:55Sanity Check
- 19:47List Monad
- 20:04Example Time
- 21:32Seems Familiar...
- 21:57The General Idea
- 22:33Opening Files
- 23:07Sounds Familiar?
- 23:43Other (Possible) Monads
related talks
26mText Parsing the Case for Monads
31mBeyond Try-Except: The Frontier of Python Error Handling with Monads and Railway Magic
27mFunctional Programming for Pythonistas
39mFunctional Programming in Python
36mA fresh take on monorepos in Python
02h 15mAll about decorators
43mFunctional Programming in an Imperative World. Maybe
43mThe Zen of Polymorphism: Choosing between isinstance(), methods, and @singledispatch
