Class: Monadt::MaybeM

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

Class Method Summary collapse

Methods included from Adt

match, with

Class Method Details

.bind(m, &blk) ⇒ Object



22
23
24
25
26
# File 'lib/monadt/maybe.rb', line 22

def bind(m, &blk)
  match(m,
    with(Maybe::Just) { |v| blk.call(v) },
    with(Maybe::Nothing) { m })
end

.return(a) ⇒ Object



28
29
30
# File 'lib/monadt/maybe.rb', line 28

def return(a)
  Maybe::Just.new a
end