What would an equivalent construct of a monad be in Ruby?
Monads are not language constructs. They're just types that implement a particular interface, and since Ruby is dynamically typed, any class that implement something like collect
in arrays, a join method (like flatten
but only flattens one level), and a constructor that can wrap anything, is a monad.