Monad equivalent in Ruby
问题 What would an equivalent construct of a monad be in Ruby? 回答1: The precise technical definition : A monad, in Ruby, would be any class with bind and self.unit methods defined such that for all instances m: m.class.unit[a].bind[f] == f[a] m.bind[m.class.unit] == m m.bind[f].bind[g] == m.bind[lambda {|x| f[x].bind[g]}] Some practical examples A very simple example of a monad is the lazy Identity monad, which emulates lazy semantics in Ruby (a strict language): class Id def initialize(lam) @v =