class MPrelude::Either::Right

Public Instance Methods

bind() { |value| ... } click to toggle source

Evaluate applicative block

@return [Either<Object>]

# File lib/mprelude.rb, line 167
def bind
  yield(value)
end
either(_left, right) click to toggle source

Evaluate right side of branch

@param [#call] _left @param [#call] right

# File lib/mprelude.rb, line 203
def either(_left, right)
  right.call(value)
end
fmap() { |value| ... } click to toggle source

Evaluate functor block

@return [Either::Right<Object>]

# File lib/mprelude.rb, line 160
def fmap
  Right.new(yield(value))
end
from_left() { |value| ... } click to toggle source

Unwrap value from left

@return [Object]

rubocop:disable Style/GuardClause

# File lib/mprelude.rb, line 176
def from_left
  if block_given?
    yield(value)
  else
    fail "Expected left value, got #{inspect}"
  end
end
from_right() click to toggle source

Unwrap value from right

@return [Object]

# File lib/mprelude.rb, line 188
def from_right
  value
end
lmap(&block) click to toggle source

Map over left value

@return [Either::Right<Object>]

# File lib/mprelude.rb, line 195
def lmap(&block)
  require_block(&block)
end