Class: Maybe
- Inherits:
-
Object
- Object
- Maybe
- Defined in:
- lib/do_notation/monads/maybe.rb
Class Method Summary collapse
Methods included from Monad
Methods included from MonadPlus
Class Method Details
.bind(value, &f) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/do_notation/monads/maybe.rb', line 11 def self.bind value, &f if value.nil? nil else f.call(value) end end |
.mplus(a, b) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/do_notation/monads/maybe.rb', line 25 def self.mplus a, b if b.nil? a else b end end |
.mzero ⇒ Object
21 22 23 |
# File 'lib/do_notation/monads/maybe.rb', line 21 def self.mzero unit(nil) end |
.unit(value) ⇒ Object
7 8 9 |
# File 'lib/do_notation/monads/maybe.rb', line 7 def self.unit value value end |