Module: Monad
- Included in:
- Array, Distribution, Expectation, Maybe, Simulation
- Defined in:
- lib/do_notation/monad.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #>>(n) ⇒ Object
- #bind_const(&block) ⇒ Object
- #joinM ⇒ Object
-
#reflect_that_doesnt_work ⇒ Object
I don’t know why this reflect doesn’t work the class method seems to be the same and work the evaluation moment of the shift in a class method and in a method may be different.
Class Method Details
.included(m) ⇒ Object
78 79 80 |
# File 'lib/do_notation/monad.rb', line 78 def self.included m m.extend ClassMethods end |
Instance Method Details
#>>(n) ⇒ Object
86 87 88 |
# File 'lib/do_notation/monad.rb', line 86 def >> n bind_const { n } end |
#bind_const(&block) ⇒ Object
82 83 84 |
# File 'lib/do_notation/monad.rb', line 82 def bind_const &block bind { |_| block.call() } end |
#joinM ⇒ Object
90 91 92 |
# File 'lib/do_notation/monad.rb', line 90 def joinM bind { |n| n } end |
#reflect_that_doesnt_work ⇒ Object
I don’t know why this reflect doesn’t work the class method seems to be the same and work the evaluation moment of the shift in a class method and in a method may be different
98 99 100 |
# File 'lib/do_notation/monad.rb', line 98 def reflect_that_doesnt_work shift { |k| bind { |v| k.call(v) } } end |