class Kind::Result::Monad
Attributes
type[R]
value[R]
Public Class Methods
new(type, value)
click to toggle source
# File lib/kind/result/monad.rb, line 26 def initialize(type, value) @type = type @value = value end
Public Instance Methods
===(m)
click to toggle source
# File lib/kind/result/monad.rb, line 67 def ===(m) return false unless Result::Abstract === m return false unless (self.success? && m.success?) || (self.failure? && m.failure?) self.type == m.type && self.value === m.value end
map(_ = UNDEFINED, &_fn)
click to toggle source
# File lib/kind/result/monad.rb, line 35 def map(_ = UNDEFINED, &_fn) raise NotImplementedError end
on() { |monad| ... }
click to toggle source
# File lib/kind/result/monad.rb, line 47 def on monad = Wrapper.new(self) yield(monad) monad.output end
on_failure(types = Undefined, matcher = Undefined) { |value| ... }
click to toggle source
# File lib/kind/result/monad.rb, line 61 def on_failure(types = Undefined, matcher = Undefined) yield(value) if failure? && result?(types, matcher) self end
on_success(types = Undefined, matcher = Undefined) { |value| ... }
click to toggle source
# File lib/kind/result/monad.rb, line 55 def on_success(types = Undefined, matcher = Undefined) yield(value) if success? && result?(types, matcher) self end
value_or(_method_name = UNDEFINED, &block)
click to toggle source
# File lib/kind/result/monad.rb, line 31 def value_or(_method_name = UNDEFINED, &block) raise NotImplementedError end