Class: Kleisli::Either::Left

Inherits:
Kleisli::Either show all
Defined in:
lib/kleisli/either.rb

Instance Attribute Summary

Attributes inherited from Kleisli::Either

#left, #right

Instance Method Summary collapse

Methods inherited from Kleisli::Either

#*, #==

Methods inherited from Monad

#>>

Constructor Details

#initialize(left) ⇒ Left

Returns a new instance of Left.



52
53
54
# File 'lib/kleisli/either.rb', line 52

def initialize(left)
  @left = left
end

Instance Method Details

#>(f) ⇒ Object



56
57
58
# File 'lib/kleisli/either.rb', line 56

def >(f)
  self
end

#fmap(&f) ⇒ Object



60
61
62
# File 'lib/kleisli/either.rb', line 60

def fmap(&f)
  self
end

#or(other = self, &other_blk) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/kleisli/either.rb', line 68

def or(other=self, &other_blk)
  if other_blk
    other_blk.call(@left)
  else
    other
  end
end

#to_maybeObject



64
65
66
# File 'lib/kleisli/either.rb', line 64

def to_maybe
  Maybe::None.new
end

#to_sObject Also known as: inspect



76
77
78
# File 'lib/kleisli/either.rb', line 76

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