Class: Fr::Either::Right
- Inherits:
-
Fr::Either
- Object
- Fr::Either
- Fr::Either::Right
- Defined in:
- lib/fr/either.rb
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#fold(left, right) ⇒ Object
-
Either a b -> (a -> c) -> (b -> c) -> c.
-
#initialize(value) ⇒ Right
constructor
A new instance of Right.
- #left? ⇒ Boolean
- #map(&f) ⇒ Object
- #right? ⇒ Boolean
Methods inherited from Fr::Either
bind, lefts, partition, plus, rights, unit, zero
Methods included from Monoid
Methods included from Monad
#applyM, #composeM, #filterM, #foldM, #forM, #join, #liftM, #mapM, #sequence, #unlessM, #whenM, #zipM
Methods included from Functor
Constructor Details
#initialize(value) ⇒ Right
Returns a new instance of Right.
60 61 62 |
# File 'lib/fr/either.rb', line 60 def initialize(value) @value = value end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
81 82 83 84 |
# File 'lib/fr/either.rb', line 81 def eql?(other) Either === other and other.fold(lambda{|_| false }, lambda{|o| o == @value }) end |
#fold(left, right) ⇒ Object
-
Either a b -> (a -> c) -> (b -> c) -> c
65 66 67 |
# File 'lib/fr/either.rb', line 65 def fold(left, right) right.call(@value) end |
#left? ⇒ Boolean
77 78 79 |
# File 'lib/fr/either.rb', line 77 def left? false end |
#map(&f) ⇒ Object
69 70 71 |
# File 'lib/fr/either.rb', line 69 def map(&f) Right.new(f.call(@value)) end |
#right? ⇒ Boolean
73 74 75 |
# File 'lib/fr/either.rb', line 73 def right? true end |