 
   # Functional interface to "doc" records
 
-  @type t :: :doc_nil | doc_line | doc_cons | doc_nest | doc_break | doc_group | doc_color | binary
+  @type t ::
+          :doc_nil
+          | doc_line
+          | doc_cons
+          | doc_nest
+          | doc_break
+          | doc_group
+          | doc_color
+          | doc_next_fits
+          | binary
 
   @typep doc_cons :: {:doc_cons, t, t}
   defmacrop doc_cons(left, right) do

    format(width, 0, [{0, :flat, group(doc)}])
  end

  # Record representing the document mode to be rendered
  #
  #   * break - represents a fitted document with breaks as breaks
  #   * flat - represents a fitted document with breaks as flats
  #
  @typep mode :: :break | :flat

  @spec fits?(integer, integer, [{integer, mode, t}]) :: boolean
  defp fits?(_, k, _) when k < 0,                          do: false
  defp fits?(_, _, []),                                    do: true
  defp fits?(w, k, [{_, _, :doc_nil} | t]),                do: fits?(w, k, t)
  defp fits?(_, _, [{_, _, doc_line(:hard)} | _]),         do: false
  defp fits?(w, _, [{i, _, doc_line(:soft)} | t]),         do: fits?(w, w - i, t)
  defp fits?(w, k, [{i, m, doc_cons(x, y)} | t]),          do: fits?(w, k, [{i, m, x} | [{i, m, y} | t]])

  @typep doc_group :: {:doc_group, t}
  defmacrop doc_group(group) do
    quote do: {:doc_group, unquote(group)}
  end

  @typep doc_next_fits :: {:doc_next_fits, t}
  defmacrop doc_next_fits(group) do
    quote do: {:doc_next_fits, unquote(group)}
  end

  @typep doc_color :: {:doc_color, t, IO.ANSI.ansidata}
