Top Level Namespace
- Includes:
- Monadic
Defined Under Namespace
Modules: Either, Monadic Classes: Failure, Success
Constant Summary collapse
Constants included from Monadic
Instance Method Summary collapse
- #Either(value) ⇒ Object
- #Failure(value) ⇒ Object
-
#Option(value) ⇒ Object
(also: #Some, #Maybe)
Helper function which returns Some or None respectively, depending on their value I find this moar simplistic in ruby than the traditional #bind and #unit.
- #Success(value) ⇒ Object
Instance Method Details
#Either(value) ⇒ Object
94 95 96 97 |
# File 'lib/monadic/either.rb', line 94 def Either(value) return Failure(value) if value.nil? || (value.respond_to?(:empty?) && value.empty?) || !value return Success(value) end |
#Failure(value) ⇒ Object
90 91 92 |
# File 'lib/monadic/either.rb', line 90 def Failure(value) Failure.new(value) end |
#Option(value) ⇒ Object Also known as: Some, Maybe
Helper function which returns Some or None respectively, depending on their value I find this moar simplistic in ruby than the traditional #bind and #unit
7 8 9 10 |
# File 'lib/monadic/option.rb', line 7 def Option(value) return Monadic::None if value.nil? || (value.respond_to?(:empty?) && value.empty?) return Monadic::Some.new(value) end |