Class: TAlgebra::Monad::Reader
- Inherits:
-
Object
- Object
- TAlgebra::Monad::Reader
- Includes:
- TAlgebra::Monad
- Defined in:
- lib/t_algebra/monad/reader.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from TAlgebra::Monad
Class Method Details
.ask ⇒ Object
11 12 13 |
# File 'lib/t_algebra/monad/reader.rb', line 11 def ask new { |r| r } end |
.pure(a) ⇒ Object
7 8 9 |
# File 'lib/t_algebra/monad/reader.rb', line 7 def pure(a) new { a } end |
Instance Method Details
#bind(&a_to_mb) ⇒ Object
20 21 22 23 24 |
# File 'lib/t_algebra/monad/reader.rb', line 20 def bind(&a_to_mb) Reader.new do |r| (r_to_a >> a_to_mb).call(r).run_reader(r) end end |
#fmap(&a_to_b) ⇒ Object
16 17 18 |
# File 'lib/t_algebra/monad/reader.rb', line 16 def fmap(&a_to_b) Reader.new(&(r_to_a >> a_to_b)) end |
#run_reader(r) ⇒ Object
26 27 28 |
# File 'lib/t_algebra/monad/reader.rb', line 26 def run_reader(r) r_to_a.call(r) end |