match, with
9 10 11 12 13 14 15 16 17 18 19 20 21
# File 'lib/monadt/async_either.rb', line 9 def bind(m, &blk) a = m.resume match(a, with(Either::Left) { |v| Async.return a }, with(Either::Right) { |v| m2 = blk.call(v) if m2.alive? m2 else Async.return a end }) end
23 24 25
# File 'lib/monadt/async_either.rb', line 23 def return(a) Async.return(Either.return(a)) end