Class: Array
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from MonadPlus
guard
Methods included from Monad
#>>, #bind_const, included
Class Method Details
.mzero ⇒ Object
16
17
18
|
# File 'lib/do_notation/monads/array.rb', line 16
def self.mzero
[]
end
|
.unit(x) ⇒ Object
6
7
8
|
# File 'lib/do_notation/monads/array.rb', line 6
def self.unit x
[x]
end
|
Instance Method Details
#bind(&f) ⇒ Object
10
11
12
|
# File 'lib/do_notation/monads/array.rb', line 10
def bind &f
map(&f).inject([]){ |a,b| a+b }
end
|