Sha256: b5fae951c23093059ce6fc3d2cce55f8bf865e516d4e594336d7c6dfd530b430
Contents?: true
Size: 714 Bytes
Versions: 11
Compression:
Stored size: 714 Bytes
Contents
# frozen_string_literal: true module Kind class Either::Right < Either::Monad def right? true end def value_or(_default = UNDEFINED, &block) @value end def map(&fn) map!(&fn) rescue Kind::Monad::Error => e raise e rescue StandardError => e Either::Left[e] end def map!(&fn) monad = fn.call(@value) return monad if Either::Monad === monad raise Kind::Monad::Error.new('Kind::Right | Kind::Left', monad) end alias_method :then, :map alias_method :then!, :map! alias_method :and_then, :map alias_method :and_then!, :map! def inspect '#<%s value=%p>' % ['Kind::Right', value] end end end
Version data entries
11 entries across 11 versions & 1 rubygems