class Unparser::Either::Left

Public Instance Methods

bind(&block) click to toggle source

Evaluate applicative block

@return [Either::Left<Object>]

# File lib/unparser/either.rb, line 64
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/unparser/either.rb, line 98
def either(left, _right)
  left.call(value)
end
fmap(&block) click to toggle source

Evaluate functor block

@return [Either::Left<Object>]

# File lib/unparser/either.rb, line 57
def fmap(&block)
  require_block(&block)
end
from_left() click to toggle source

Unwrap value from left

@return [Object]

# File lib/unparser/either.rb, line 71
def from_left
  value
end
from_right() { |value| ... } click to toggle source

Unwrap value from right

@return [Object]

# 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() { |value| ... } click to toggle source

Map over left value

@return [Either::Right<Object>]

# File lib/unparser/either.rb, line 90
def lmap
  Left.new(yield(value))
end