module Fear::For::Mixin

Include this mixin to access convenient factory method for For. @example

include Fear::For::Mixin

For(Fear.some(2), Fear.some(3)) { |a, b| a * b } #=> Fear.some(6)
For(Fear.some(2), Fear.none()) { |a, b| a * b }  #=> Fear.none()

For(proc { Fear.some(2) }, proc { Fear.some(3) }) do |a, b|
  a * b
end #=> Fear.some(6)

For(proc { Fear.none() }, proc { raise }) do |a, b|
  a * b
end #=> Fear.none()

For(Fear.right(2), Fear.right(3)) { |a, b| a * b } #=> Fear.right(6)
For(Fear.right(2), Fear.left(3)) { |a, b| a * b }  #=> Fear.left(3)

For(Fear.success(2), Fear.success(3)) { |a| a * b } #=> Fear.success(3)
For(Fear.success(2), Fear.failure(...)) { |a, b| a * b }  #=> Fear.failure(...)

Public Instance Methods

For(*monads, &block) click to toggle source

@param monads [{#map, flat_map}] @return [{#map, flat_map}]

# File lib/fear/for.rb, line 66
def For(*monads, &block)
  Fear.for(*monads, &block)
end