class Kind::Either::Right

Public Instance Methods

and_then(&fn)
Alias for: map
and_then!(&fn)
Alias for: map!
inspect() click to toggle source
# File lib/kind/either/right.rb, line 34
def inspect
  '#<%s value=%p>' % ['Kind::Right', value]
end
map(&fn) click to toggle source
# File lib/kind/either/right.rb, line 13
def map(&fn)
  map!(&fn)
rescue Kind::Monad::Error => e
  raise e
rescue StandardError => e
  Either::Left[e]
end
Also aliased as: then, and_then
map!(&fn) click to toggle source
# File lib/kind/either/right.rb, line 21
def map!(&fn)
  monad = fn.call(@value)

  return monad if Either::Monad === monad

  raise Kind::Monad::Error.new('Kind::Right | Kind::Left', monad)
end
Also aliased as: then!, and_then!
right?() click to toggle source
# File lib/kind/either/right.rb, line 5
def right?
  true
end
then(&fn)
Alias for: map
then!(&fn)
Alias for: map!
value_or(_default = UNDEFINED, &block) click to toggle source
# File lib/kind/either/right.rb, line 9
def value_or(_default = UNDEFINED, &block)
  @value
end