Class: Monadt::ReaderStateEither
- Inherits:
-
Object
- Object
- Monadt::ReaderStateEither
- Extended by:
- Adt
- Defined in:
- lib/monadt/reader_state_either.rb
Class Method Summary collapse
Methods included from Adt
Class Method Details
.bind(m, &blk) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/monadt/reader_state_either.rb', line 8 def bind(m, &blk) ->(e, s) { c, s2 = m.(e, s) match(c, with(Either::Left) {|v| [c, s2]}, with(Either::Right) {|v| blk.call(v).(e, s2) }) } end |
.return(val) ⇒ Object
19 20 21 |
# File 'lib/monadt/reader_state_either.rb', line 19 def return(val) ->(e, s) { [Either.return(val), s] } end |