lib/dry/monads/list.rb
# Turns the list into a typed one.
# Type is required for some operations like .traverse.
#
# @param type [Monad] Monad instance
# @return [List] Typed list
Turns the list into a typed one.
Type is required for some operations like .traverse.
Turns the list into a typed one . Type is required for some operations like . traverse .
def typed(type = nil)
        if type.nil?
          if size.zero?
            raise ArgumentError, "Cannot infer a monad for an empty list"
          else
            self.class.warn(
              "Automatic monad inference is deprecated, pass a type explicitly "\
              "or use a predefined constant, e.g. List::Result\n"\
              "#{caller.find { |l| l !~ %r{(lib/dry/monads)|(gems)} }}"
            )
            self.class.new(value, value[0].monad)
          end
        else
          self.class.new(value, type)
        end
      end
def typed ( type = nil ) if type . nil? if size . zero? raise ArgumentError , "Cannot infer a monad for an empty list" else self . class . warn ( "Automatic monad inference is deprecated, pass a type explicitly " "or use a predefined constant, e.g. List::Result\n" "#{caller.find { |l| l !~ %r{(lib/dry/monads)|(gems)} }}" ) self . class . new ( value , value [ 0 ] . monad ) end else self . class . new ( value , type ) end end
Turns the list into a typed one.
Turns the list into a typed one .
None
List
type
None