class MPrelude::Either::Left
Public Instance Methods
bind(&block)
click to toggle source
Evaluate applicative block
@return [Either::Left<Object>]
# File lib/mprelude.rb, line 115 def bind(&block) require_block(&block) end
either(left, _right)
click to toggle source
Evaluate left side of branch
@param [#call] left @param [#call] _right
# File lib/mprelude.rb, line 151 def either(left, _right) left.call(value) end
fmap(&block)
click to toggle source
Evaluate functor block
@return [Either::Left<Object>]
# File lib/mprelude.rb, line 108 def fmap(&block) require_block(&block) end
from_left()
click to toggle source
Unwrap value from left
@return [Object]
# File lib/mprelude.rb, line 122 def from_left value end
from_right() { |value| ... }
click to toggle source
Unwrap value from right
@return [Object]
rubocop:disable Style/GuardClause
# File lib/mprelude.rb, line 131 def from_right if block_given? yield(value) else fail "Expected right value, got #{inspect}" end end
lmap() { |value| ... }
click to toggle source
Map over left value
@return [Either::Right<Object>]
# File lib/mprelude.rb, line 143 def lmap Left.new(yield(value)) end