module Dry::Monads::RightBiased::Right::Left
Left/wrong/erroneous part
@api public
Public Class Methods
Source
# File lib/dry/monads/right_biased.rb, line 237 def self.trace_caller = caller_locations(2, 1)[0].to_s # Raises an error on accessing internal value def value! = raise UnwrapError, self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def bind(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def tee(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def fmap(...) = self # Left-biased #bind version. # # @example # Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" # Dry::Monads.None.or('no value') # => "no value" # Dry::Monads.None.or { Time.now } # => current time # # @return [Object] def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH
@private @return [String] Caller location
Public Instance Methods
Source
# File lib/dry/monads/right_biased.rb, line 275 def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end end
Returns the passed value. Works in pair with {RightBiased::Right#|}.
@param alt [RightBiased::Right, RightBiased::Left]
@return [RightBiased::Right, RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 319 def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end
Returns self back. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 301 def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end end end end
Ignores the input parameter and returns self. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 246 def bind(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def tee(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def fmap(...) = self # Left-biased #bind version. # # @example # Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" # Dry::Monads.None.or('no value') # => "no value" # Dry::Monads.None.or { Time.now } # => current time # # @return [Object] def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end
Ignores the input parameter and returns self. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 332 def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end
Pattern matching
@example
case Success(x) in Success(Integer) then ... in Success(2..100) then ... in Success(2..200 => code) then ... in Failure(_) then ... end
@api private
Source
# File lib/dry/monads/right_biased.rb, line 351 def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end
Pattern matching hash values
@example
case Failure(x) in Failure(code: 400...500) then :user_error in Failure(code: 500...600) then :server_error end
@api private
Source
# File lib/dry/monads/right_biased.rb, line 307 def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end end end
Returns self back. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 313 def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end end
Returns self back. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 258 def fmap(...) = self # Left-biased #bind version. # # @example # Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" # Dry::Monads.None.or('no value') # => "no value" # Dry::Monads.None.or { Time.now } # => current time # # @return [Object] def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end
Ignores the input parameter and returns self. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 268 def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end
Left-biased bind
version.
@example
Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" Dry::Monads.None.or('no value') # => "no value" Dry::Monads.None.or { Time.now } # => current time
@return [Object]
Source
# File lib/dry/monads/right_biased.rb, line 284 def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end end end end
A lifted version of ‘#or`. This is basically `#or` + `#fmap`.
@example
Dry::Monads.None.or_fmap('no value') # => Some("no value") Dry::Monads.None.or_fmap { Time.now } # => Some(current time)
@return [RightBiased::Left, RightBiased::Right
]
Source
# File lib/dry/monads/right_biased.rb, line 252 def tee(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def fmap(...) = self # Left-biased #bind version. # # @example # Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" # Dry::Monads.None.or('no value') # => "no value" # Dry::Monads.None.or { Time.now } # => current time # # @return [Object] def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end
Ignores the input parameter and returns self. It exists to keep the interface identical to that of {RightBiased::Right}.
@return [RightBiased::Left]
Source
# File lib/dry/monads/right_biased.rb, line 240 def value! = raise UnwrapError, self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def bind(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def tee(...) = self # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def fmap(...) = self # Left-biased #bind version. # # @example # Dry::Monads.Left(ArgumentError.new('error message')).or(&:message) # => "error message" # Dry::Monads.None.or('no value') # => "no value" # Dry::Monads.None.or { Time.now } # => current time # # @return [Object] def or(...) = raise NotImplementedError # Returns the passed value. Works in pair with {RightBiased::Right#|}. # # @param alt [RightBiased::Right, RightBiased::Left] # # @return [RightBiased::Right, RightBiased::Left] def |(alt) = self.or(alt) # A lifted version of `#or`. This is basically `#or` + `#fmap`. # # @example # Dry::Monads.None.or_fmap('no value') # => Some("no value") # Dry::Monads.None.or_fmap { Time.now } # => Some(current time) # # @return [RightBiased::Left, RightBiased::Right] def or_fmap(...) = raise NotImplementedError # Returns the passed value # # @return [Object] def value_or(val = nil) if block_given? yield else val end end # Ignores the input parameter and returns self. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def apply(...) = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def discard = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def flatten = self # Returns self back. It exists to keep the interface # identical to that of {RightBiased::Right}. # # @return [RightBiased::Left] def and(_, &) = self # Pattern matching # # @example # case Success(x) # in Success(Integer) then ... # in Success(2..100) then ... # in Success(2..200 => code) then ... # in Failure(_) then ... # end # # @api private def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end # Pattern matching hash values # # @example # case Failure(x) # in Failure(code: 400...500) then :user_error # in Failure(code: 500...600) then :server_error # end # # @api private def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end
Raises an error on accessing internal value
Source
# File lib/dry/monads/right_biased.rb, line 289 def value_or(val = nil) if block_given? yield else val end end
Returns the passed value
@return [Object]