def flatten_with_monad(depth=nil)
      if depth.is_a? Integer
        depth.times.inject(self) { |e, _| e.shallow_flatten }
      else
        bind do |x|
          if x.is_a?(Monad) && x.can_flatten_in_monad?
            x.flatten_with_monad
          else
            self.class.unit(x)
          end
        end
      end
    end
def flatten_with_monad(depth=nil)
      if depth.is_a? Integer
        depth.times.inject(self) { |e, _| e.shallow_flatten }
      else
        bind do |x|
          if x.is_a?(Monad) && x.can_flatten_in_monad?
            x.flatten_with_monad
          else
            self.class.unit(x)
          end
        end
      end
    end
Returns a monad whose elements are the ultimate (non-monadic) values contained in all nested monads

 NOTE: normally aliased as +flatten+ when +Monad+ is mixed into a class

 @example
   [Some(Some(1)), Some(Some(None))], [None]].flatten_with_monad
   #=> [1]