class Unsound::Data::Just
Public Instance Methods
>>(f = nil, &blk)
click to toggle source
Chain another operation which can result in a {Data::Maybe}
@param f the next operation @return [Data::Nothing, Data::Just]
# File lib/unsound/data/maybe.rb, line 83 def >>(f = nil, &blk) (f || blk)[value] end
Also aliased as: and_then
fmap(f = nil, &blk)
click to toggle source
Apply a function to a value contained in a {Data::Just}
@param f [#call] the function to apply @return [Data::Just] the result of applying the function
wrapped in a {Data::Just}
# File lib/unsound/data/maybe.rb, line 75 def fmap(f = nil, &blk) self >> Composition.compose(method(:of), (f || blk)) end
maybe(f, _)
click to toggle source
Call a function on the value in the {Data::Just}
@param f [#call] a function capable of processing the value @param _ [#call] a function that will never be called
# File lib/unsound/data/maybe.rb, line 99 def maybe(f, _) f[value] end
or_else(*)
click to toggle source
A Noop
@return [Data::Just]
# File lib/unsound/data/maybe.rb, line 91 def or_else(*) self end