Class: Mutant::Either::Left Private

Inherits:
Mutant::Either show all
Defined in:
lib/mutant/base.rb

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

Instance Method Summary collapse

Methods inherited from Mutant::Either

wrap_error

Instance Method Details

#apply(&block) ⇒ Either::Left<Object>

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.

Evaluate applicative block

Returns:



99
100
101
# File 'lib/mutant/base.rb', line 99

def apply(&block)
  require_block(&block)
end

#either(left, _right) ⇒ Object

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.

Evaluate left side of branch

Parameters:

  • left (#call)
  • _right (#call)


135
136
137
# File 'lib/mutant/base.rb', line 135

def either(left, _right)
  left.call(value)
end

#fmap(&block) ⇒ Either::Left<Object>

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.

Evaluate functor block

Returns:



92
93
94
# File 'lib/mutant/base.rb', line 92

def fmap(&block)
  require_block(&block)
end

#from_leftObject

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.

Unwrap value from left

Returns:

  • (Object)


106
107
108
# File 'lib/mutant/base.rb', line 106

def from_left
  value
end

#from_rightObject

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.

Unwrap value from right

rubocop:disable Style/GuardClause

Returns:

  • (Object)


115
116
117
118
119
120
121
# File 'lib/mutant/base.rb', line 115

def from_right
  if block_given?
    yield(value)
  else
    fail "Expected right value, got #{inspect}"
  end
end

#lmapEither::Right<Object>

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.

Map over left value

Returns:



127
128
129
# File 'lib/mutant/base.rb', line 127

def lmap
  Left.new(yield(value))
end