lib/dry/monads/right_biased.rb
# Combines the wrapped value with another monadic value.
# If both values are right-sided, yields a block and passes a tuple
# of values there. If no block given, returns a tuple of values wrapped with
# a monadic structure.
#
# @example
#   include Dry::Monads::Result::Mixin
#
#   Success(3).and(Success(5)) # => Success([3, 5])
#   Success(3).and(Failure(:not_a_number)) # => Failure(:not_a_number)
#   Failure(:not_a_number).and(Success(5)) # => Failure(:not_a_number)
#   Success(3).and(Success(5)) { |a, b| a + b } # => Success(8)
#
# @param mb [RightBiased::Left,RightBiased::Right]
#
# @return [RightBiased::Left,RightBiased::Right]
Combines the wrapped value with another monadic value.
If both values are right-sided, yields a block and passes a tuple
of values there. If no block given, returns a tuple of values wrapped with
a monadic structure.
Combines the wrapped value with another monadic value . If both values are right - sided yields a block and passes a tuple of values there . If no block given returns a tuple of values wrapped with a monadic structure .
def and(mb)
          bind do |a|
            mb.fmap do |b|
              if block_given?
                yield([a, b])
              else
                [a, b]
              end
            end
          end
        end
def and ( mb ) bind do | a | mb . fmap do | b | if block_given? yield ( [ a , b ] ) else [ a , b ] end end end end
Combines the wrapped value with another monadic value.
Combines the wrapped value with another monadic value .
None
RightBiased::Left,RightBiased::Right
mb
<not_specific>
<not_specific>
None
example
include Dry::Monads::Result::Mixin Success(3).and(Success(5)) # => Success([3, 5]) Success(3).and(Failure(:not_a_number)) # => Failure(:not_a_number) Failure(:not_a_number).and(Success(5)) # => Failure(:not_a_number) Success(3).and(Success(5)) { |a, b| a + b } # => Success(8)
include Dry :: Monads :: Result :: Mixin Success ( 3 ) . and ( Success ( 5 )) # = > Success ( [ 3 5 ] ) Success ( 3 ) . and ( Failure ( : not_a_number )) # = > Failure ( : not_a_number ) Failure ( : not_a_number ) . and ( Success ( 5 )) # = > Failure ( : not_a_number ) Success ( 3 ) . and ( Success ( 5 )) { |a b| a + b } # = > Success ( 8 )