Class: Fr::Either::Left
- Inherits:
-
Fr::Either
- Object
- Fr::Either
- Fr::Either::Left
- Defined in:
- lib/fr/either.rb
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#fold(left, right) ⇒ Object
-
Either a b -> (a -> c) -> (b -> c) -> c.
-
#initialize(value) ⇒ Left
constructor
A new instance of Left.
- #left? ⇒ Boolean
- #map(&f) ⇒ Object
- #right? ⇒ Boolean
Methods inherited from Fr::Either
bind, lefts, partition, plus, rights, unit, zero
Methods included from Monoid
Methods included from Monad
#applyM, #composeM, #filterM, #foldM, #forM, #join, #liftM, #mapM, #sequence, #unlessM, #whenM, #zipM
Methods included from Functor
Constructor Details
#initialize(value) ⇒ Left
Returns a new instance of Left.
30 31 32 |
# File 'lib/fr/either.rb', line 30 def initialize(value) @value = value end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
51 52 53 54 |
# File 'lib/fr/either.rb', line 51 def eql?(other) Either === other and other.fold(lambda{|o| o == @value }, lambda{|_| false }) end |
#fold(left, right) ⇒ Object
-
Either a b -> (a -> c) -> (b -> c) -> c
35 36 37 |
# File 'lib/fr/either.rb', line 35 def fold(left, right) left.call(@value) end |
#left? ⇒ Boolean
47 48 49 |
# File 'lib/fr/either.rb', line 47 def left? true end |
#map(&f) ⇒ Object
39 40 41 |
# File 'lib/fr/either.rb', line 39 def map(&f) self end |
#right? ⇒ Boolean
43 44 45 |
# File 'lib/fr/either.rb', line 43 def right? false end |