Class: Fr::Either::Right
Instance Method Summary
collapse
Methods inherited from Fr::Either
bind, lefts, partition, plus, rights, unit, zero
Methods included from Monoid
#filter, #guard, #sum
Methods included from Monad
#applyM, #composeM, #filterM, #foldM, #forM, #join, #liftM, #mapM, #sequence, #unlessM, #whenM, #zipM
Methods included from Functor
#void
Constructor Details
#initialize(value) ⇒ Right
60
61
62
|
# File 'lib/fr/either.rb', line 60
def initialize(value)
@value = value
end
|
Instance Method Details
#eql?(other) ⇒ Boolean
Also known as:
==
81
82
83
84
|
# File 'lib/fr/either.rb', line 81
def eql?(other)
Either === other and
other.fold(lambda{|_| false }, lambda{|o| o == @value })
end
|
#fold(left, right) ⇒ Object
-
Either a b -> (a -> c) -> (b -> c) -> c
65
66
67
|
# File 'lib/fr/either.rb', line 65
def fold(left, right)
right.call(@value)
end
|
#left? ⇒ Boolean
77
78
79
|
# File 'lib/fr/either.rb', line 77
def left?
false
end
|
69
70
71
|
# File 'lib/fr/either.rb', line 69
def map(&f)
Right.new(f.call(@value))
end
|
#right? ⇒ Boolean
73
74
75
|
# File 'lib/fr/either.rb', line 73
def right?
true
end
|