Class: Kleisli::Either::Right
- Inherits:
-
Kleisli::Either
- Object
- Functor
- Monad
- Kleisli::Either
- Kleisli::Either::Right
- Defined in:
- lib/kleisli/either.rb
Instance Attribute Summary
Attributes inherited from Kleisli::Either
Instance Method Summary collapse
- #>(f) ⇒ Object
- #fmap(&f) ⇒ Object
-
#initialize(right) ⇒ Right
constructor
A new instance of Right.
- #or(other = nil, &other_blk) ⇒ Object
- #to_maybe ⇒ Object
- #to_s ⇒ Object (also: #inspect)
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_maybe ⇒ Object
35 36 37 |
# File 'lib/kleisli/either.rb', line 35 def to_maybe Maybe::Some.new(@right) end |
#to_s ⇒ Object Also known as: inspect
43 44 45 |
# File 'lib/kleisli/either.rb', line 43 def to_s "Right(#{@right.inspect})" end |