Class: Kleisli::Either::Left
- Inherits:
-
Kleisli::Either
- Object
- Functor
- Monad
- Kleisli::Either
- Kleisli::Either::Left
- Defined in:
- lib/kleisli/either.rb
Instance Attribute Summary
Attributes inherited from Kleisli::Either
Instance Method Summary collapse
- #>(f) ⇒ Object
- #fmap(&f) ⇒ Object
-
#initialize(left) ⇒ Left
constructor
A new instance of Left.
- #or(other = self, &other_blk) ⇒ Object
- #to_maybe ⇒ Object
- #to_s ⇒ Object (also: #inspect)
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_maybe ⇒ Object
64 65 66 |
# File 'lib/kleisli/either.rb', line 64 def to_maybe Maybe::None.new end |
#to_s ⇒ Object Also known as: inspect
76 77 78 |
# File 'lib/kleisli/either.rb', line 76 def to_s "Left(#{@left.inspect})" end |