Class: Unsound::Data::Right
Instance Method Summary collapse
-
#>>(f = nil, &blk) ⇒ Data::Left, Data::Right
(also: #and_then)
Chain another operation which can result in a Either.
-
#either(_, f) ⇒ Object
Call a function on the value in the Right.
-
#fmap(f = nil, &blk) ⇒ Data::Right
Apply a function to a value contained in a Right.
-
#or_else ⇒ Data::Right
A Noop.
Methods inherited from Either
Instance Method Details
#>>(f = nil, &blk) ⇒ Data::Left, Data::Right Also known as: and_then
Chain another operation which can result in a Either
80 81 82 |
# File 'lib/unsound/data/either.rb', line 80 def >>(f = nil, &blk) (f || blk)[value] end |
#either(_, f) ⇒ Object
Call a function on the value in the Unsound::Data::Right
96 97 98 |
# File 'lib/unsound/data/either.rb', line 96 def either(_, f) f[value] end |
#fmap(f = nil, &blk) ⇒ Data::Right
Apply a function to a value contained in a Unsound::Data::Right
72 73 74 |
# File 'lib/unsound/data/either.rb', line 72 def fmap(f = nil, &blk) self >> Composition.compose(method(:of), (f || blk)) end |
#or_else ⇒ Data::Right
A Noop
88 89 90 |
# File 'lib/unsound/data/either.rb', line 88 def or_else(*) self end |