     quote do
       fn entry, acc(head, prev, tail) = acc ->
         value = unquote(callback).(entry)
+
         case prev do
           {:value, ^value} -> skip(acc)
           _ -> next_with_acc(unquote(fun), entry, head, {:value, value}, tail)

      else
        {:cont, new_state}
      end
    end, fn {acc_buffer, acc_count} ->
      if leftover == :discard or acc_count == 0 do
        {:cont, []}
      else
        {:cont, :lists.reverse(acc_buffer, Enum.take(leftover, count - acc_count)), []}
      end
    end)
  end

  def chunk_by(chunk_by, enumerable, fun) do
    chunk_by.(enumerable, nil, fn
      entry, nil ->
        {:cont, {[entry], fun.(entry)}}
      entry, {acc, value} ->
        case fun.(entry) do
          ^value -> {:cont, {[entry | acc], value}}
          new_value -> {:cont, :lists.reverse(acc), {[entry], new_value}}
        end
    end, fn
      nil -> {:cont, :done}
      {acc, _value} -> {:cont, :lists.reverse(acc), :done}
    end)
  end

  defmacro chunk_while(callback, fun \\ nil) do

        case curr do
          0 ->
            {:halt, original}

          1 ->
            {_, acc} = next_with_acc(unquote(fun), entry, head, 0, tail)
            {:halt, acc}

          _ ->
            next_with_acc(unquote(fun), entry, head, curr - 1, tail)
        end
