Class: Kleisli::Maybe::Some

Inherits:
Kleisli::Maybe show all
Defined in:
lib/kleisli/maybe.rb

Instance Attribute Summary

Attributes inherited from Kleisli::Maybe

#value

Instance Method Summary collapse

Methods inherited from Kleisli::Maybe

#*, #==, lift

Methods inherited from Kleisli::Monad

#>>

Constructor Details

#initialize(value) ⇒ Some

Returns a new instance of Some.



47
48
49
# File 'lib/kleisli/maybe.rb', line 47

def initialize(value)
  @value = value
end

Instance Method Details

#>(block) ⇒ Object



55
56
57
# File 'lib/kleisli/maybe.rb', line 55

def >(block)
  block.call(@value)
end

#fmap(&f) ⇒ Object



51
52
53
# File 'lib/kleisli/maybe.rb', line 51

def fmap(&f)
  Maybe.lift(f.call(@value))
end

#or(other) ⇒ Object



59
60
61
# File 'lib/kleisli/maybe.rb', line 59

def or(other)
  self
end

#to_sObject Also known as: inspect



63
64
65
# File 'lib/kleisli/maybe.rb', line 63

def to_s
  "Some(#{@value})"
end