with Ada.Text_IO; use Ada.Text_IO;

procedure Debug_Dup_Output (S : String) is

   C : Character;
   First : Integer;

   procedure Put_Chunk (Last : Integer) is
   begin
      if First = Last then
         Put (Integer'Image (First));
      else
         Put (Integer'Image (First) & " .." & Integer'Image (Last));
      end if;
      Put (" => '" & C & "'");
   end Put_Chunk;
begin
   if S'Length <= 0 then
      Put ("(" & Integer'Image (S'First) & " .." & Integer'Image (S'Last) & " => <>)");
      return;
   end if;

   Put ("(");

   C := S (S'First);
   First := S'First;

   for i in S'First + 1 .. S'Last loop
      if S (i) /= C then
         Put_Chunk (i - 1);
         Put (",");
         C := S (i);
         First := i;
      end if;
   end loop;

   Put_Chunk (S'Last);
   Put (")");
end Debug_Dup_Output;
