Class: Unparser::Either::Left
- Inherits:
-
Unparser::Either
- Object
- Unparser::Either
- Unparser::Either::Left
- Defined in:
- lib/unparser/either.rb
Instance Method Summary collapse
-
#bind(&block) ⇒ Either::Left<Object>
Evaluate applicative block.
-
#either(left, _right) ⇒ Object
Evaluate left side of branch.
-
#fmap(&block) ⇒ Either::Left<Object>
Evaluate functor block.
-
#from_left ⇒ Object
Unwrap value from left.
-
#from_right ⇒ Object
Unwrap value from right.
-
#lmap ⇒ Either::Right<Object>
Map over left value.
Methods inherited from Unparser::Either
Instance Method Details
#bind(&block) ⇒ Either::Left<Object>
Evaluate applicative block
64 65 66 |
# File 'lib/unparser/either.rb', line 64 def bind(&block) require_block(&block) end |
#either(left, _right) ⇒ Object
Evaluate left side of branch
98 99 100 |
# File 'lib/unparser/either.rb', line 98 def either(left, _right) left.call(value) end |
#fmap(&block) ⇒ Either::Left<Object>
Evaluate functor block
57 58 59 |
# File 'lib/unparser/either.rb', line 57 def fmap(&block) require_block(&block) end |
#from_left ⇒ Object
Unwrap value from left
71 72 73 |
# File 'lib/unparser/either.rb', line 71 def from_left value end |
#from_right ⇒ Object
Unwrap value from right
79 80 81 82 83 84 85 |
# File 'lib/unparser/either.rb', line 79 def from_right if block_given? yield(value) else fail "Expected right value, got #{inspect}" end end |
#lmap ⇒ Either::Right<Object>
Map over left value
90 91 92 |
# File 'lib/unparser/either.rb', line 90 def lmap Left.new(yield(value)) end |