Class: Unparser::Either::Right
- Inherits:
-
Unparser::Either
- Object
- Unparser::Either
- Unparser::Either::Right
- Defined in:
- lib/unparser/either.rb
Overview
Left
Instance Method Summary collapse
-
#bind {|value| ... } ⇒ Either<Object>
Evaluate applicative block.
-
#either(_left, right) ⇒ Object
Evaluate right side of branch.
-
#fmap ⇒ Either::Right<Object>
Evaluate functor block.
-
#from_left ⇒ Object
Unwrap value from left.
-
#from_right ⇒ Object
Unwrap value from right.
-
#lmap(&block) ⇒ Either::Right<Object>
Map over left value.
Methods inherited from Unparser::Either
Instance Method Details
#bind {|value| ... } ⇒ Either<Object>
Evaluate applicative block
114 115 116 |
# File 'lib/unparser/either.rb', line 114 def bind yield(value) end |
#either(_left, right) ⇒ Object
Evaluate right side of branch
148 149 150 |
# File 'lib/unparser/either.rb', line 148 def either(_left, right) right.call(value) end |
#fmap ⇒ Either::Right<Object>
Evaluate functor block
107 108 109 |
# File 'lib/unparser/either.rb', line 107 def fmap Right.new(yield(value)) end |
#from_left ⇒ Object
Unwrap value from left
122 123 124 125 126 127 128 |
# File 'lib/unparser/either.rb', line 122 def from_left if block_given? yield(value) else fail "Expected left value, got #{inspect}" end end |
#from_right ⇒ Object
Unwrap value from right
133 134 135 |
# File 'lib/unparser/either.rb', line 133 def from_right value end |
#lmap(&block) ⇒ Either::Right<Object>
Map over left value
140 141 142 |
# File 'lib/unparser/either.rb', line 140 def lmap(&block) require_block(&block) end |