Class: Kleisli::Validation::Failure

Inherits:
Either::Left
  • Object
show all
Defined in:
lib/kleisli/validation.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kleisli/validation.rb', line 27

def *(other)
  if other.class == Failure
    unless self.left.class == other.left.class &&
            self.left.respond_to?(:sappend)
      raise ArgumentError,
              "Failures must contain members of a common Semigroup"
    end
    Failure(self.left.sappend(other.left))
  else
    self
  end
end

#to_sObject Also known as: inspect



40
41
42
# File 'lib/kleisli/validation.rb', line 40

def to_s
  "Failure(#{@left.inspect})"
end