Class: Array

Inherits:
Object
  • Object
show all
Extended by:
Monad, MonadPlus
Defined in:
lib/do_notation/monads/array.rb

Class Method Summary collapse

Methods included from Monad

bind_const, compose, run

Methods included from MonadPlus

guard

Class Method Details

.bind(value, &f) ⇒ Object



11
12
13
# File 'lib/do_notation/monads/array.rb', line 11

def self.bind value, &f
  value.map(&f).inject([], &:+)
end

.mplus(a, b) ⇒ Object



21
22
23
# File 'lib/do_notation/monads/array.rb', line 21

def self.mplus(a, b)
  a + b
end

.mzeroObject



17
18
19
# File 'lib/do_notation/monads/array.rb', line 17

def self.mzero
  []
end

.unit(x) ⇒ Object



7
8
9
# File 'lib/do_notation/monads/array.rb', line 7

def self.unit x
  [x]
end