Class: Unsound::Data::Left

Inherits:
Either
  • Object
show all
Defined in:
lib/unsound/data/either.rb

Instance Method Summary collapse

Methods inherited from Either

of

Instance Method Details

#>>Data::Left Also known as: and_then

A Noop

Returns:



44
45
46
# File 'lib/unsound/data/either.rb', line 44

def >>(*)
  self
end

#either(f, _) ⇒ Object

Call a function on the value in the Unsound::Data::Left

Parameters:

  • f (#call)

    a function capable of processing the value

  • _ (#call)

    a function that will never be called



61
62
63
# File 'lib/unsound/data/either.rb', line 61

def either(f, _)
  f[value]
end

#fmapData::Left

A Noop

Returns:



37
38
39
# File 'lib/unsound/data/either.rb', line 37

def fmap(*)
  self
end

#or_else(f = nil, &blk) ⇒ Data::Left, Data::Right

Chain another operation which can result in a Either

Parameters:

  • f (#call) (defaults to: nil)

    the next operation

Returns:



53
54
55
# File 'lib/unsound/data/either.rb', line 53

def or_else(f = nil, &blk)
  (f || blk)[value]
end