Class: Monadt::EitherM

Inherits:
Object
  • Object
show all
Extended by:
Adt
Defined in:
lib/monadt/either.rb

Class Method Summary collapse

Methods included from Adt

match, with

Class Method Details

.bind(m, &blk) ⇒ Object



23
24
25
26
27
# File 'lib/monadt/either.rb', line 23

def bind(m, &blk)
  match(m,
    with(Either::Left) { |v| m },
    with(Either::Right) { |v| blk.call(v) })
end

.return(a) ⇒ Object



29
30
31
# File 'lib/monadt/either.rb', line 29

def return(a)
  Either::Right.new a
end