Class: Funkr::Types::Container
- Extended by:
- Monoid::ClassMethods
- Includes:
- Functor, Categories, Monoid
- Defined in:
- lib/funkr/types/container.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ Container
constructor
A new instance of Container.
- #map(&block) ⇒ Object
- #mplus(c_y) ⇒ Object
- #to_s ⇒ Object
- #unbox ⇒ Object
Constructor Details
#initialize(value) ⇒ Container
Returns a new instance of Container.
9 10 11 |
# File 'lib/funkr/types/container.rb', line 9 def initialize(value) @value = value end |
Instance Method Details
#map(&block) ⇒ Object
19 20 21 |
# File 'lib/funkr/types/container.rb', line 19 def map(&block) self.class.new(yield(@value)) end |
#mplus(c_y) ⇒ Object
26 27 28 |
# File 'lib/funkr/types/container.rb', line 26 def mplus(c_y) self.class.new(@value.mplus(c_y.unbox)) end |
#to_s ⇒ Object
15 |
# File 'lib/funkr/types/container.rb', line 15 def to_s; format("{- %s -}", @value.to_s); end |
#unbox ⇒ Object
13 |
# File 'lib/funkr/types/container.rb', line 13 def unbox; @value; end |