Module: Fear::For::Mixin Private

Included in:
Mixin
Defined in:
lib/fear/for.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Include this mixin to access convenient factory method for For.

Examples:

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(...)

Instance Method Summary collapse

Instance Method Details

#For(*monads, &block) ⇒ {#map, #flat_map}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • monads ({#map, #flat_map})

Returns:

  • ({#map, #flat_map})


66
67
68
# File 'lib/fear/for.rb', line 66

def For(*monads, &block)
  Fear.for(*monads, &block)
end