     end
   end
 
-  def slice(string, start, length) when start < 0 and length >= 0 do
+  def slice(string, start, length)
+      when is_binary(string) and is_integer(start) and is_integer(length) and start < 0 and
+             length >= 0 do
     start = length(string) + start
 
     case start >= 0 do


  """
  @spec to_integer(String.t()) :: integer
  def to_integer(string) do
    :erlang.binary_to_integer(string)
  end



  """
  @spec first(t) :: grapheme | nil
  def first(string) when is_binary(string) do
    case next_grapheme(string) do
      {char, _} -> char
      nil -> nil
