Class: Kleisli::Either::Right

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(right) ⇒ Right

Returns a new instance of Right.



23
24
25
# File 'lib/kleisli/either.rb', line 23

def initialize(right)
  @right = right
end

Instance Method Details

#>(f) ⇒ Object



27
28
29
# File 'lib/kleisli/either.rb', line 27

def >(f)
  f.call(@right)
end

#fmap(&f) ⇒ Object



31
32
33
# File 'lib/kleisli/either.rb', line 31

def fmap(&f)
  Right.new(f.call(@right))
end

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



39
40
41
# File 'lib/kleisli/either.rb', line 39

def or(other=nil, &other_blk)
  self
end

#to_maybeObject



35
36
37
# File 'lib/kleisli/either.rb', line 35

def to_maybe
  Maybe::Some.new(@right)
end

#to_sObject Also known as: inspect



43
44
45
# File 'lib/kleisli/either.rb', line 43

def to_s
  "Right(#{@right.inspect})"
end