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.



47
48
49
# File 'lib/kleisli/either.rb', line 47

def initialize(left)
  @left = left
end

Instance Method Details

#>(f) ⇒ Object



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

def >(f)
  self
end

#fmap(&f) ⇒ Object



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

def fmap(&f)
  self
end

#or(other, &other_blk) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/kleisli/either.rb', line 63

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

#to_maybeObject



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

def to_maybe
  Maybe::None.new
end