   @moduledoc false
 
   @doc """
-  Implements the get IO API used by IEX. It receives the
+  Implements the get IO API used by IEx. It receives the
   code cache, the instructions counter and needs to
   return a list with the new characters inserted.
   """

    match: _
      "...> "
    end
    binary_to_list(:unicode.characters_to_binary(Erlang.io.get_line(prompt)))
  end

  @doc """
  Implements the put IO API used by IEX. It receives the
  result and prints it.
  """
  def put(result) do
    IO.inspect result
  end
end


  end

  defp do_loop(config) do
    io = config.io

    config  = config.increment_counter
    counter = config.counter
    cache   = config.cache
    code    = cache ++ io.get(cache, counter)

    new_config =
      try do
        { result, new_binding, scope } =
          Erlang.elixir.eval(code, config.binding, 'iex', counter, config.scope)
        io.put result
        config.binding(new_binding).cache('').scope(scope)
      rescue: TokenMissingError
        config.cache(code)
      rescue: exception
        stacktrace = Code.stacktrace
        io.error "** (#{inspect exception.__record__(:name)}) #{exception.message}"
        print_stacktrace io, stacktrace
        config.cache('')
      catch: kind, error
        stacktrace = Code.stacktrace
        io.error "** (#{kind}) #{inspect(error)}"
        print_stacktrace io, stacktrace
        config.cache('')
      end

    do_loop(new_config)
  end

  defp print_stacktrace(io, stacktrace) do
    Enum.each stacktrace, fn(s, do: io.error "    #{format_stacktrace(s)}")
  end
end