Class: Kleisli::Try::Success
- Inherits:
-
Kleisli::Try
- Object
- Functor
- Monad
- Kleisli::Try
- Kleisli::Try::Success
- Defined in:
- lib/kleisli/try.rb
Instance Attribute Summary
Attributes inherited from Kleisli::Try
Instance Method Summary collapse
- #>(f) ⇒ Object
- #fmap(&f) ⇒ Object
-
#initialize(value) ⇒ Success
constructor
A new instance of Success.
- #to_either ⇒ Object
- #to_maybe ⇒ Object
Methods inherited from Kleisli::Try
Methods inherited from Monad
Constructor Details
#initialize(value) ⇒ Success
Returns a new instance of Success.
15 16 17 |
# File 'lib/kleisli/try.rb', line 15 def initialize(value) @value = value end |
Instance Method Details
#>(f) ⇒ Object
19 20 21 22 23 |
# File 'lib/kleisli/try.rb', line 19 def >(f) f.call(@value) rescue => e Failure.new(e) end |
#fmap(&f) ⇒ Object
25 26 27 |
# File 'lib/kleisli/try.rb', line 25 def fmap(&f) Try { f.call(@value) } end |