Refactoring Ruby with Monads
summary
Claims that monads are practical in Ruby and shows concrete refactorings: replace nil-check pyramids, flatten nested collections, and sequence asynchronous callbacks. Implements decorator classes Optional, Many, Eventually with operations and_then and from_value plus within that chain safely; examples traverse models, aggregate words from comments, and call the GitHub API, and the patterns run end to end. Code appears packaged as a gem and published on GitHub.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:48ANALOGIES
- 15:50MULTIPLE RESULTS
- 18:33ASYNCHRONOUS CODE
- 24:15ABSTRACT DATA TYPE
- 25:56COMMON INTERFACE
related talks
42mTaking inspiration from the functional world
43mMonads: Exploring Railway Oriented Programming in Ruby
27mUsing Monads for Elegant Error Handling
25mError handling with Monads in Ruby
44mFunctional Programming for Rubyists
44mReal-World Functional Ruby
26mBlending Functional and OO Programming in Ruby
30mDucks and monads: wonders of Ruby types
