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.



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

def initialize(value)
  @value = value
end

Instance Method Details

#>(block) ⇒ Object



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

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

#fmap(&f) ⇒ Object



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

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

#or(other = nil, &other_blk) ⇒ Object



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

def or(other=nil, &other_blk)
  self
end

#to_sObject Also known as: inspect



68
69
70
# File 'lib/kleisli/maybe.rb', line 68

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