Module: Dry::Monads::Maybe::Mixin::Constructors

Included in:
Dry::Monads, Dry::Monads::Maybe::Mixin
Defined in:
lib/dry/monads/maybe.rb

Instance Method Summary collapse

Instance Method Details

#Maybe(value) ⇒ Maybe::Some, Maybe::None

Parameters:

  • value (Object)

    the value to be stored in the monad

Returns:


198
199
200
# File 'lib/dry/monads/maybe.rb', line 198

def Maybe(value)
  Maybe.coerce(value)
end

#NoneMaybe::None

Returns:


218
219
220
# File 'lib/dry/monads/maybe.rb', line 218

def None
  None.new(RightBiased::Left.trace_caller)
end

#Some(value) ⇒ Maybe::Some #Some(&block) ⇒ Maybe::Some

Some constructor

Overloads:


212
213
214
215
# File 'lib/dry/monads/maybe.rb', line 212

def Some(value = Undefined, &block)
  v = Undefined.default(value, block || Unit)
  Some.new(v)
end