     s
   end
 
-  defp io_request({:put_chars, chars}, state(output: output) = s) do
-    {:ok, state(s, output: << output :: binary, String.from_char_data!(chars) :: binary >>)}
-  end
-
-  defp io_request({:put_chars, m, f, as}, state(output: output) = s) do
+  defp io_request({:put_chars, chars}, %StringIO{output: output} = s) do
+    {:ok, %StringIO{s | output: << output :: binary, String.from_char_data!(chars) :: binary >>}}
+  end
+
+  defp io_request({:put_chars, m, f, as}, %StringIO{output: output} = s) do
     chars = apply(m, f, as)
-    {:ok, state(s, output: << output :: binary, String.from_char_data!(chars) :: binary >>)}
+    {:ok, %StringIO{s | output: << output :: binary, String.from_char_data!(chars) :: binary >>}}
   end
 
   defp io_request({:put_chars, _encoding, chars}, s) do

    super(msg, s)
  end

  def handle_call(:contents, _from, state(input: input, output: output) = s) do
    {:reply, {input, output}, s}
  end

  def handle_call(:close, _from, state(input: input, output: output) = s) do
    {:stop, :normal, {:ok, {input, output}}, s}
  end


          output = << output :: binary, String.from_char_data!(prompt) :: binary >>
        end

        {result, %StringIO{s | input: input, output: output}}
    end
  end

