Class: Fr::Maybe
Defined Under Namespace
Constant Summary collapse
- None =
Singleton instance
None_.new
Class Method Summary collapse
- .bind(x, &f) ⇒ Object
-
.plus(a, b) ⇒ Object
-
Maybe a -> Maybe a -> Maybe a.
-
.run(computation) ⇒ Object
Evaluators.
-
.unit(value) ⇒ Object
Combinators.
-
.zero ⇒ Object
-
Maybe a.
Methods included from Monoid
Methods included from Monad
applyM, composeM, filterM, foldM, forM, join, liftM, mapM, sequence, unlessM, whenM, zipM
Methods included from Functor
Class Method Details
.bind(x, &f) ⇒ Object
19 20 21 |
# File 'lib/fr/monad/maybe.rb', line 19 def bind(x, &f) x.fold(x, &f) end |
.plus(a, b) ⇒ Object
-
Maybe a -> Maybe a -> Maybe a
11 12 13 |
# File 'lib/fr/monoid/maybe.rb', line 11 def plus(a, b) (a.none?) ? b : a end |
.run(computation) ⇒ Object
Evaluators
8 9 10 |
# File 'lib/fr/monad/maybe.rb', line 8 def run(computation) computation end |
.unit(value) ⇒ Object
Combinators
15 16 17 |
# File 'lib/fr/monad/maybe.rb', line 15 def unit(value) Maybe::Some.new(value) end |