[m-rev.] for review: include count of call sequence numbers in Deep.data

Zoltan Somogyi zs at csse.unimelb.edu.au
Thu Oct 5 12:35:39 AEST 2006


For review by Julien. The change to io_combinator.m (the bulk of the diff)
is trivial, and does not need review.

Zoltan.

Include the count of call sequence numbers in the Deep.data file, since the
deep profiler needs to know this to generate percentages.

runtime/mercury_deep_profiling.c:
	Write the count of call sequence numbers to the Deep.data file.

deep_profiler/profile.m:
	Add a field to the profile for holding the count of call sequence
	numbers.

deep_profiler/read_profile.m:
	Read in the count of call sequence numbers from the Deep.data file.

deep_profiler/io_combinator.m:
	Add some functions now required by read_profile.m.

	Convert from DCGs to state variables.

deep_profiler/canonical.m:
deep_profiler/dump.m:
	Conform to the change to profile.m.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
Index: deep_profiler/canonical.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/canonical.m,v
retrieving revision 1.11
diff -u -r1.11 canonical.m
--- deep_profiler/canonical.m	29 Sep 2006 06:15:11 -0000	1.11
+++ deep_profiler/canonical.m	5 Oct 2006 02:10:21 -0000
@@ -837,8 +837,11 @@
     list.foldl(int_add, InstrumentQuantas, 0, InstrumentQuanta),
     list.foldl(int_add, UserQuantas, 0, UserQuanta),
     WordSize = BaseInitDeep ^ init_profile_stats ^ word_size,
+    extract_num_callseqs(BaseInitDeep, BaseNumCallSeqs),
+    list.map(extract_num_callseqs, OtherInitDeeps, OtherNumCallSeqs),
+    list.foldl(int_add, OtherNumCallSeqs, BaseNumCallSeqs, ConcatNumCallSeqs),
     ConcatProfileStats = profile_stats(
-        ConcatMaxCSD, BaseMaxCSS, ConcatMaxPD, BaseMaxPS,
+        ConcatMaxCSD, BaseMaxCSS, ConcatMaxPD, BaseMaxPS, ConcatNumCallSeqs,
         BaseTicksPerSec, InstrumentQuanta, UserQuanta, WordSize, yes),
     % The root part is a temporary lie.
     MergedInitDeep = initial_deep(ConcatProfileStats,
@@ -931,14 +934,12 @@
             Slot = slot_normal(CSDPtr)
         ;
             Slot0 = slot_multi(IsZeroed, CSDPtrs0),
-            array_map_from_0(
-                concat_call_site_dynamic_ptr(PrevMaxCSD),
+            array_map_from_0(concat_call_site_dynamic_ptr(PrevMaxCSD),
                 u(CSDPtrs0), CSDPtrs),
             Slot = slot_multi(IsZeroed, CSDPtrs)
         ),
         svarray.set(Cur, Slot, !Sites),
-        concatenate_profile_slots(Cur + 1, Max, PrevMaxCSD, PrevMaxPD,
-            !Sites)
+        concatenate_profile_slots(Cur + 1, Max, PrevMaxCSD, PrevMaxPD, !Sites)
     ;
         true
     ).
@@ -968,6 +969,7 @@
 %-----------------------------------------------------------------------------%
 
     % array_match_elements(Min, Max, BaseArray, OtherArrays):
+    %
     % Succeeds iff all the elements of all the OtherArrays are equal to the
     % corresponding element of BaseArray.
     %
@@ -984,6 +986,7 @@
     ).
 
     % match_element(TestElement, Index, Arrays):
+    %
     % Succeeds iff the elements of all the Arrays at index Index
     % are equal to TestElement.
     %
Index: deep_profiler/dump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/dump.m,v
retrieving revision 1.6
diff -u -r1.6 dump.m
--- deep_profiler/dump.m	4 Oct 2006 06:59:17 -0000	1.6
+++ deep_profiler/dump.m	5 Oct 2006 00:58:54 -0000
@@ -132,7 +132,7 @@
 
 dump_init_profile_stats(Stats, !IO) :-
     Stats = profile_stats(MaxCSD, MaxCSS, MaxPD, MaxPS, TicksPerSec,
-        InstrumentQuanta, UserQuanta, WordSize, Canonical),
+        InstrumentQuanta, UserQuanta, NumCallSeqs, WordSize, Canonical),
     io.write_string("SECTION PROFILING STATS:\n\n", !IO),
     io.format("\tmax_csd = %d\n", [i(MaxCSD)], !IO),
     io.format("\tmax_css = %d\n", [i(MaxCSS)], !IO),
@@ -141,6 +141,7 @@
     io.format("\tticks_per_sec = %d\n", [i(TicksPerSec)], !IO),
     io.format("\tinstrument_quanta = %d\n", [i(InstrumentQuanta)], !IO),
     io.format("\tuser_quanta = %d\n", [i(UserQuanta)], !IO),
+    io.format("\tnum_call_seqs = %d\n", [i(NumCallSeqs)], !IO),
     io.format("\tword_size   = %d\n", [i(WordSize)], !IO),
     io.write_string("\tcanonical = ", !IO),
     (
Index: deep_profiler/io_combinator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/io_combinator.m,v
retrieving revision 1.7
diff -u -r1.7 io_combinator.m
--- deep_profiler/io_combinator.m	29 Mar 2006 08:07:40 -0000	1.7
+++ deep_profiler/io_combinator.m	5 Oct 2006 02:10:07 -0000
@@ -215,6 +215,35 @@
     pred(in, in, in, in, in, in, in, in, in, in, out) is det,
     out, di, uo) is det.
 
+:- pred io_combinator.sequence_11(
+    pred(io.result(T1), io, io),
+    pred(io.result(T2), io, io),
+    pred(io.result(T3), io, io),
+    pred(io.result(T4), io, io),
+    pred(io.result(T5), io, io),
+    pred(io.result(T6), io, io),
+    pred(io.result(T7), io, io),
+    pred(io.result(T8), io, io),
+    pred(io.result(T9), io, io),
+    pred(io.result(T10), io, io),
+    pred(io.result(T11), io, io),
+    pred(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, io.result(T)),
+    io.result(T), io, io).
+:- mode io_combinator.sequence_11(
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(in, in, in, in, in, in, in, in, in, in, in, out) is det,
+    out, di, uo) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- pred io_combinator.res_sequence_2(
@@ -388,6 +417,35 @@
     pred(in, in, in, in, in, in, in, in, in, in, out) is det,
     out, di, uo) is det.
 
+:- pred io_combinator.res_sequence_11(
+    pred(io.res(T1), io, io),
+    pred(io.res(T2), io, io),
+    pred(io.res(T3), io, io),
+    pred(io.res(T4), io, io),
+    pred(io.res(T5), io, io),
+    pred(io.res(T6), io, io),
+    pred(io.res(T7), io, io),
+    pred(io.res(T8), io, io),
+    pred(io.res(T9), io, io),
+    pred(io.res(T10), io, io),
+    pred(io.res(T11), io, io),
+    pred(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, io.res(T)),
+    io.res(T), io, io).
+:- mode io_combinator.res_sequence_11(
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(in, in, in, in, in, in, in, in, in, in, in, out) is det,
+    out, di, uo) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- pred io_combinator.maybe_error_sequence_2(
@@ -561,6 +619,35 @@
     pred(in, in, in, in, in, in, in, in, in, in, out) is det,
     out, di, uo) is det.
 
+:- pred io_combinator.maybe_error_sequence_11(
+    pred(maybe_error(T1), io, io),
+    pred(maybe_error(T2), io, io),
+    pred(maybe_error(T3), io, io),
+    pred(maybe_error(T4), io, io),
+    pred(maybe_error(T5), io, io),
+    pred(maybe_error(T6), io, io),
+    pred(maybe_error(T7), io, io),
+    pred(maybe_error(T8), io, io),
+    pred(maybe_error(T9), io, io),
+    pred(maybe_error(T10), io, io),
+    pred(maybe_error(T11), io, io),
+    pred(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, maybe_error(T)),
+    maybe_error(T), io, io).
+:- mode io_combinator.maybe_error_sequence_11(
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(out, di, uo) is det,
+    pred(in, in, in, in, in, in, in, in, in, in, in, out) is det,
+    out, di, uo) is det.
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -568,1413 +655,1686 @@
 
 %-----------------------------------------------------------------------------%
 
-io_combinator.sequence_2(P1, P2, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_2(P1, P2, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            { call(Combine, T1, T2, Res) }
+            Res2 = ok(T2),
+            call(Combine, T1, T2, Res)
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_3(P1, P2, P3, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_3(P1, P2, P3, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                { call(Combine, T1, T2, T3, Res) }
+                Res3 = ok(T3),
+                call(Combine, T1, T2, T3, Res)
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_4(P1, P2, P3, P4, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_4(P1, P2, P3, P4, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    { call(Combine, T1, T2, T3, T4, Res) }
+                    Res4 = ok(T4),
+                    call(Combine, T1, T2, T3, T4, Res)
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_5(P1, P2, P3, P4, P5, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_5(P1, P2, P3, P4, P5, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        { call(Combine, T1, T2, T3, T4,
-                            T5, Res) }
+                        Res5 = ok(T5),
+                        call(Combine, T1, T2, T3, T4, T5, Res)
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            { call(Combine, T1, T2,
-                                T3, T4, T5,
-                                T6, Res) }
+                            Res6 = ok(T6),
+                            call(Combine, T1, T2, T3, T4, T5, T6, Res)
                         ;
-                            { Res6 = eof },
-                            { Res = eof }
+                            Res6 = eof,
+                            Res = eof
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_7(P1, P2, P3, P4, P5, P6, P7, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_7(P1, P2, P3, P4, P5, P6, P7, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                { call(Combine, T1, T2, T3, T4, T5, T6, T7,
-                                    Res) }
+                                Res7 = ok(T7),
+                                call(Combine, T1, T2, T3, T4, T5, T6, T7, Res)
                             ;
-                                { Res7 = eof },
-                                { Res = eof }
+                                Res7 = eof,
+                                Res = eof
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = eof },
-                            { Res = eof }
+                            Res6 = eof,
+                            Res = eof
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_8(P1, P2, P3, P4, P5, P6, P7, P8, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_8(P1, P2, P3, P4, P5, P6, P7, P8, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    { call(Combine, T1, T2, T3, T4, T5, T6,
-                                        T7, T8, Res) }
+                                    Res8 = ok(T8),
+                                    call(Combine, T1, T2, T3, T4, T5, T6,
+                                        T7, T8, Res)
                                 ;
-                                    { Res8 = eof },
-                                    { Res = eof }
+                                    Res8 = eof,
+                                    Res = eof
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = eof },
-                                { Res = eof }
+                                Res7 = eof,
+                                Res = eof
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = eof },
-                            { Res = eof }
+                            Res6 = eof,
+                            Res = eof
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.sequence_9(P1, P2, P3, P4, P5, P6, P7, P8, P9, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.sequence_9(P1, P2, P3, P4, P5, P6, P7, P8, P9, Combine, Res,
+        !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        { call(Combine, T1, T2, T3, T4, T5,
-                                            T6, T7, T8, T9, Res) }
+                                        Res9 = ok(T9),
+                                        call(Combine, T1, T2, T3, T4, T5,
+                                            T6, T7, T8, T9, Res)
                                     ;
-                                        { Res9 = eof },
-                                        { Res = eof }
+                                        Res9 = eof,
+                                        Res = eof
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = eof },
-                                    { Res = eof }
+                                    Res8 = eof,
+                                    Res = eof
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = eof },
-                                { Res = eof }
+                                Res7 = eof,
+                                Res = eof
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = eof },
-                            { Res = eof }
+                            Res6 = eof,
+                            Res = eof
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.sequence_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
+    (
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
+        (
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
+            (
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
+                (
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
+                    (
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
+                        (
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
+                            (
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
+                                (
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
+                                    (
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
+                                        (
+                                            Res10 = ok(T10),
+                                            call(Combine, T1, T2, T3, T4, T5,
+                                                T6, T7, T8, T9, T10, Res)
+                                        ;
+                                            Res10 = eof,
+                                            Res = eof
+                                        ;
+                                            Res10 = error(Err),
+                                            Res = error(Err)
+                                        )
+                                    ;
+                                        Res9 = eof,
+                                        Res = eof
+                                    ;
+                                        Res9 = error(Err),
+                                        Res = error(Err)
+                                    )
+                                ;
+                                    Res8 = eof,
+                                    Res = eof
+                                ;
+                                    Res8 = error(Err),
+                                    Res = error(Err)
+                                )
+                            ;
+                                Res7 = eof,
+                                Res = eof
+                            ;
+                                Res7 = error(Err),
+                                Res = error(Err)
+                            )
+                        ;
+                            Res6 = eof,
+                            Res = eof
+                        ;
+                            Res6 = error(Err),
+                            Res = error(Err)
+                        )
+                    ;
+                        Res5 = eof,
+                        Res = eof
+                    ;
+                        Res5 = error(Err),
+                        Res = error(Err)
+                    )
+                ;
+                    Res4 = eof,
+                    Res = eof
+                ;
+                    Res4 = error(Err),
+                    Res = error(Err)
+                )
+            ;
+                Res3 = eof,
+                Res = eof
+            ;
+                Res3 = error(Err),
+                Res = error(Err)
+            )
+        ;
+            Res2 = eof,
+            Res = eof
+        ;
+            Res2 = error(Err),
+            Res = error(Err)
+        )
+    ;
+        Res1 = eof,
+        Res = eof
+    ;
+        Res1 = error(Err),
+        Res = error(Err)
+    ).
+
+io_combinator.sequence_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11,
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        call(P10, Res10),
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
                                         (
-                                            { Res10 = ok(T10) },
-                                            { call(Combine, T1, T2, T3, T4, T5,
-                                                T6, T7, T8, T9, T10, Res) }
+                                            Res10 = ok(T10),
+                                            call(P11, Res11, !IO),
+                                            (
+                                                Res11 = ok(T11),
+                                                call(Combine, T1, T2, T3, T4,
+                                                    T5, T6, T7, T8, T9, T10,
+                                                    T11, Res)
+                                            ;
+                                                Res11 = eof,
+                                                Res = eof
+                                            ;
+                                                Res11 = error(Err),
+                                                Res = error(Err)
+                                            )
                                         ;
-                                            { Res10 = eof },
-                                            { Res = eof }
+                                            Res10 = eof,
+                                            Res = eof
                                         ;
-                                            { Res10 = error(Err) },
-                                            { Res = error(Err) }
+                                            Res10 = error(Err),
+                                            Res = error(Err)
                                         )
                                     ;
-                                        { Res9 = eof },
-                                        { Res = eof }
+                                        Res9 = eof,
+                                        Res = eof
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = eof },
-                                    { Res = eof }
+                                    Res8 = eof,
+                                    Res = eof
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = eof },
-                                { Res = eof }
+                                Res7 = eof,
+                                Res = eof
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = eof },
-                            { Res = eof }
+                            Res6 = eof,
+                            Res = eof
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = eof },
-                        { Res = eof }
+                        Res5 = eof,
+                        Res = eof
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = eof },
-                    { Res = eof }
+                    Res4 = eof,
+                    Res = eof
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = eof },
-                { Res = eof }
+                Res3 = eof,
+                Res = eof
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = eof },
-            { Res = eof }
+            Res2 = eof,
+            Res = eof
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = eof },
-        { Res = eof }
+        Res1 = eof,
+        Res = eof
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 %-----------------------------------------------------------------------------%
 
-io_combinator.res_sequence_2(P1, P2, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_2(P1, P2, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            { call(Combine, T1, T2, Res) }
+            Res2 = ok(T2),
+            call(Combine, T1, T2, Res)
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_3(P1, P2, P3, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_3(P1, P2, P3, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                { call(Combine, T1, T2, T3, Res) }
+                Res3 = ok(T3),
+                call(Combine, T1, T2, T3, Res)
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_4(P1, P2, P3, P4, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_4(P1, P2, P3, P4, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    { call(Combine, T1, T2, T3, T4, Res) }
+                    Res4 = ok(T4),
+                    call(Combine, T1, T2, T3, T4, Res)
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_5(P1, P2, P3, P4, P5, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_5(P1, P2, P3, P4, P5, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        { call(Combine, T1, T2, T3, T4,
-                            T5, Res) }
+                        Res5 = ok(T5),
+                        call(Combine, T1, T2, T3, T4, T5, Res)
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            { call(Combine, T1, T2,
-                                T3, T4, T5,
-                                T6, Res) }
+                            Res6 = ok(T6),
+                            call(Combine, T1, T2, T3, T4, T5, T6, Res)
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_7(P1, P2, P3, P4, P5, P6, P7, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_7(P1, P2, P3, P4, P5, P6, P7, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                { call(Combine, T1, T2, T3, T4, T5, T6, T7,
-                                    Res) }
+                                Res7 = ok(T7),
+                                call(Combine, T1, T2, T3, T4, T5, T6, T7, Res)
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.res_sequence_8(P1, P2, P3, P4, P5, P6, P7, P8, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.res_sequence_8(P1, P2, P3, P4, P5, P6, P7, P8, Combine, Res,
+        !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    { call(Combine, T1, T2, T3, T4, T5, T6,
-                                        T7, T8, Res) }
+                                    Res8 = ok(T8),
+                                    call(Combine, T1, T2, T3, T4, T5, T6,
+                                        T7, T8, Res)
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.res_sequence_9(P1, P2, P3, P4, P5, P6, P7, P8, P9,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        { call(Combine, T1, T2, T3, T4, T5,
-                                            T6, T7, T8, T9, Res) }
+                                        Res9 = ok(T9),
+                                        call(Combine, T1, T2, T3, T4, T5,
+                                            T6, T7, T8, T9, Res)
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.res_sequence_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
+    (
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
+        (
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
+            (
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
+                (
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
+                    (
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
+                        (
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
+                            (
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
+                                (
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
+                                    (
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
+                                        (
+                                            Res10 = ok(T10),
+                                            call(Combine, T1, T2, T3, T4, T5,
+                                                T6, T7, T8, T9, T10, Res)
+                                        ;
+                                            Res10 = error(Err),
+                                            Res = error(Err)
+                                        )
+                                    ;
+                                        Res9 = error(Err),
+                                        Res = error(Err)
+                                    )
+                                ;
+                                    Res8 = error(Err),
+                                    Res = error(Err)
+                                )
+                            ;
+                                Res7 = error(Err),
+                                Res = error(Err)
+                            )
+                        ;
+                            Res6 = error(Err),
+                            Res = error(Err)
+                        )
+                    ;
+                        Res5 = error(Err),
+                        Res = error(Err)
+                    )
+                ;
+                    Res4 = error(Err),
+                    Res = error(Err)
+                )
+            ;
+                Res3 = error(Err),
+                Res = error(Err)
+            )
+        ;
+            Res2 = error(Err),
+            Res = error(Err)
+        )
+    ;
+        Res1 = error(Err),
+        Res = error(Err)
+    ).
+
+io_combinator.res_sequence_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11,
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        call(P10, Res10),
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
                                         (
-                                            { Res10 = ok(T10) },
-                                            { call(Combine, T1, T2, T3, T4, T5,
-                                                T6, T7, T8, T9, T10, Res) }
+                                            Res10 = ok(T10),
+                                            call(P11, Res11, !IO),
+                                            (
+                                                Res11 = ok(T11),
+                                                call(Combine, T1, T2, T3, T4,
+                                                    T5, T6, T7, T8, T9, T10,
+                                                    T11, Res)
+                                            ;
+                                                Res11 = error(Err),
+                                                Res = error(Err)
+                                            )
                                         ;
-                                            { Res10 = error(Err) },
-                                            { Res = error(Err) }
+                                            Res10 = error(Err),
+                                            Res = error(Err)
                                         )
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 %-----------------------------------------------------------------------------%
 
-io_combinator.maybe_error_sequence_2(P1, P2, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.maybe_error_sequence_2(P1, P2, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            { call(Combine, T1, T2, Res) }
+            Res2 = ok(T2),
+            call(Combine, T1, T2, Res)
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.maybe_error_sequence_3(P1, P2, P3, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.maybe_error_sequence_3(P1, P2, P3, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                { call(Combine, T1, T2, T3, Res) }
+                Res3 = ok(T3),
+                call(Combine, T1, T2, T3, Res)
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.maybe_error_sequence_4(P1, P2, P3, P4, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.maybe_error_sequence_4(P1, P2, P3, P4, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    { call(Combine, T1, T2, T3, T4, Res) }
+                    Res4 = ok(T4),
+                    call(Combine, T1, T2, T3, T4, Res)
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.maybe_error_sequence_5(P1, P2, P3, P4, P5, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.maybe_error_sequence_5(P1, P2, P3, P4, P5, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        { call(Combine, T1, T2, T3, T4,
-                            T5, Res) }
+                        Res5 = ok(T5),
+                        call(Combine, T1, T2, T3, T4, T5, Res)
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
-io_combinator.maybe_error_sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res) -->
-    call(P1, Res1),
+io_combinator.maybe_error_sequence_6(P1, P2, P3, P4, P5, P6, Combine, Res, !IO)
+:-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            { call(Combine, T1, T2,
-                                T3, T4, T5,
-                                T6, Res) }
+                            Res6 = ok(T6),
+                            call(Combine, T1, T2, T3, T4, T5, T6, Res)
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.maybe_error_sequence_7(P1, P2, P3, P4, P5, P6, P7,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                { call(Combine, T1, T2, T3, T4, T5, T6, T7,
-                                    Res) }
+                                Res7 = ok(T7),
+                                call(Combine, T1, T2, T3, T4, T5, T6, T7, Res)
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.maybe_error_sequence_8(P1, P2, P3, P4, P5, P6, P7, P8,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    { call(Combine, T1, T2, T3, T4, T5, T6,
-                                        T7, T8, Res) }
+                                    Res8 = ok(T8),
+                                    call(Combine, T1, T2, T3, T4, T5, T6,
+                                        T7, T8, Res)
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.maybe_error_sequence_9(P1, P2, P3, P4, P5, P6, P7, P8, P9,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        { call(Combine, T1, T2, T3, T4, T5,
-                                            T6, T7, T8, T9, Res) }
+                                        Res9 = ok(T9),
+                                        call(Combine, T1, T2, T3, T4, T5,
+                                            T6, T7, T8, T9, Res)
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 io_combinator.maybe_error_sequence_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,
-        Combine, Res) -->
-    call(P1, Res1),
+        Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
+    (
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
+        (
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
+            (
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
+                (
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
+                    (
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
+                        (
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
+                            (
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
+                                (
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
+                                    (
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
+                                        (
+                                            Res10 = ok(T10),
+                                            call(Combine, T1, T2, T3, T4, T5,
+                                                T6, T7, T8, T9, T10, Res)
+                                        ;
+                                            Res10 = error(Err),
+                                            Res = error(Err)
+                                        )
+                                    ;
+                                        Res9 = error(Err),
+                                        Res = error(Err)
+                                    )
+                                ;
+                                    Res8 = error(Err),
+                                    Res = error(Err)
+                                )
+                            ;
+                                Res7 = error(Err),
+                                Res = error(Err)
+                            )
+                        ;
+                            Res6 = error(Err),
+                            Res = error(Err)
+                        )
+                    ;
+                        Res5 = error(Err),
+                        Res = error(Err)
+                    )
+                ;
+                    Res4 = error(Err),
+                    Res = error(Err)
+                )
+            ;
+                Res3 = error(Err),
+                Res = error(Err)
+            )
+        ;
+            Res2 = error(Err),
+            Res = error(Err)
+        )
+    ;
+        Res1 = error(Err),
+        Res = error(Err)
+    ).
+
+io_combinator.maybe_error_sequence_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,
+        P11, Combine, Res, !IO) :-
+    call(P1, Res1, !IO),
     (
-        { Res1 = ok(T1) },
-        call(P2, Res2),
+        Res1 = ok(T1),
+        call(P2, Res2, !IO),
         (
-            { Res2 = ok(T2) },
-            call(P3, Res3),
+            Res2 = ok(T2),
+            call(P3, Res3, !IO),
             (
-                { Res3 = ok(T3) },
-                call(P4, Res4),
+                Res3 = ok(T3),
+                call(P4, Res4, !IO),
                 (
-                    { Res4 = ok(T4) },
-                    call(P5, Res5),
+                    Res4 = ok(T4),
+                    call(P5, Res5, !IO),
                     (
-                        { Res5 = ok(T5) },
-                        call(P6, Res6),
+                        Res5 = ok(T5),
+                        call(P6, Res6, !IO),
                         (
-                            { Res6 = ok(T6) },
-                            call(P7, Res7),
+                            Res6 = ok(T6),
+                            call(P7, Res7, !IO),
                             (
-                                { Res7 = ok(T7) },
-                                call(P8, Res8),
+                                Res7 = ok(T7),
+                                call(P8, Res8, !IO),
                                 (
-                                    { Res8 = ok(T8) },
-                                    call(P9, Res9),
+                                    Res8 = ok(T8),
+                                    call(P9, Res9, !IO),
                                     (
-                                        { Res9 = ok(T9) },
-                                        call(P10, Res10),
+                                        Res9 = ok(T9),
+                                        call(P10, Res10, !IO),
                                         (
-                                            { Res10 = ok(T10) },
-                                            { call(Combine, T1, T2, T3, T4, T5,
-                                                T6, T7, T8, T9, T10, Res) }
+                                            Res10 = ok(T10),
+                                            call(P11, Res11, !IO),
+                                            (
+                                                Res11 = ok(T11),
+                                                call(Combine, T1, T2, T3, T4,
+                                                    T5, T6, T7, T8, T9, T10,
+                                                    T11, Res)
+                                            ;
+                                                Res11 = error(Err),
+                                                Res = error(Err)
+                                            )
                                         ;
-                                            { Res10 = error(Err) },
-                                            { Res = error(Err) }
+                                            Res10 = error(Err),
+                                            Res = error(Err)
                                         )
                                     ;
-                                        { Res9 = error(Err) },
-                                        { Res = error(Err) }
+                                        Res9 = error(Err),
+                                        Res = error(Err)
                                     )
                                 ;
-                                    { Res8 = error(Err) },
-                                    { Res = error(Err) }
+                                    Res8 = error(Err),
+                                    Res = error(Err)
                                 )
                             ;
-                                { Res7 = error(Err) },
-                                { Res = error(Err) }
+                                Res7 = error(Err),
+                                Res = error(Err)
                             )
                         ;
-                            { Res6 = error(Err) },
-                            { Res = error(Err) }
+                            Res6 = error(Err),
+                            Res = error(Err)
                         )
                     ;
-                        { Res5 = error(Err) },
-                        { Res = error(Err) }
+                        Res5 = error(Err),
+                        Res = error(Err)
                     )
                 ;
-                    { Res4 = error(Err) },
-                    { Res = error(Err) }
+                    Res4 = error(Err),
+                    Res = error(Err)
                 )
             ;
-                { Res3 = error(Err) },
-                { Res = error(Err) }
+                Res3 = error(Err),
+                Res = error(Err)
             )
         ;
-            { Res2 = error(Err) },
-            { Res = error(Err) }
+            Res2 = error(Err),
+            Res = error(Err)
         )
     ;
-        { Res1 = error(Err) },
-        { Res = error(Err) }
+        Res1 = error(Err),
+        Res = error(Err)
     ).
 
 %-----------------------------------------------------------------------------%
Index: deep_profiler/profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/profile.m,v
retrieving revision 1.13
diff -u -r1.13 profile.m
--- deep_profiler/profile.m	29 Sep 2006 06:15:11 -0000	1.13
+++ deep_profiler/profile.m	5 Oct 2006 00:56:42 -0000
@@ -38,6 +38,7 @@
                 max_css                     :: int,
                 max_pd                      :: int,
                 max_ps                      :: int,
+                num_callseqs                :: int,
                 ticks_per_sec               :: int,
                 instrument_quanta           :: int,
                 user_quanta                 :: int,
@@ -415,6 +416,7 @@
 :- pred extract_ticks_per_sec(initial_deep::in, int::out) is det.
 :- pred extract_instrument_quanta(initial_deep::in, int::out) is det.
 :- pred extract_user_quanta(initial_deep::in, int::out) is det.
+:- pred extract_num_callseqs(initial_deep::in, int::out) is det.
 :- pred extract_max_css(initial_deep::in, int::out) is det.
 :- pred extract_max_ps(initial_deep::in, int::out) is det.
 :- pred extract_max_csd(initial_deep::in, int::out) is det.
@@ -864,6 +866,9 @@
 extract_user_quanta(InitDeep,
     InitDeep ^ init_profile_stats ^ user_quanta).
 
+extract_num_callseqs(InitDeep,
+    InitDeep ^ init_profile_stats ^ num_callseqs).
+
 extract_max_css(InitDeep, MaxCSS) :-
     array.max(InitDeep ^ init_call_site_statics, MaxCSS).
 
Index: deep_profiler/read_profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/read_profile.m,v
retrieving revision 1.16
diff -u -r1.16 read_profile.m
--- deep_profiler/read_profile.m	4 Oct 2006 06:59:18 -0000	1.16
+++ deep_profiler/read_profile.m	5 Oct 2006 02:10:34 -0000
@@ -54,7 +54,7 @@
         read_id_string(Res1, !IO),
         (
             Res1 = ok(_),
-            io_combinator.maybe_error_sequence_10(
+            io_combinator.maybe_error_sequence_11(
                 read_fixed_size_int,
                 read_fixed_size_int,
                 read_fixed_size_int,
@@ -62,6 +62,7 @@
                 read_num,
                 read_num,
                 read_num,
+                read_num,
                 read_deep_byte,
                 read_deep_byte,
                 read_ptr(pd),
@@ -70,14 +71,15 @@
                         TicksPerSec::in,
                         InstrumentQuanta::in,
                         UserQuanta::in,
+                        NumCallSeqs::in,
                         WordSize::in,
                         CanonicalFlag::in,
                         RootPDI::in,
                         ResInitDeep::out) is det :-
                     InitDeep0 = init_deep(MaxCSD, MaxCSS,
                         MaxPD, MaxPS,
-                        TicksPerSec,
-                        InstrumentQuanta, UserQuanta,
+                        TicksPerSec, InstrumentQuanta, UserQuanta,
+                        NumCallSeqs,
                         WordSize, CanonicalFlag,
                         RootPDI),
                     ResInitDeep = ok(InitDeep0)
@@ -125,18 +127,19 @@
 
 id_string = "Mercury deep profiler data version 2\n".
 
-:- func init_deep(int, int, int, int, int, int, int, int, int, int)
+:- func init_deep(int, int, int, int, int, int, int, int, int, int, int)
     = initial_deep.
 
 init_deep(MaxCSD, MaxCSS, MaxPD, MaxPS, TicksPerSec, InstrumentQuanta,
-        UserQuanta, WordSize, CanonicalByte, RootPDI) = InitDeep :-
+        UserQuanta, NumCallSeqs, WordSize, CanonicalByte, RootPDI)
+        = InitDeep :-
     ( CanonicalByte = 0 ->
         CanonicalFlag = no
     ;
         CanonicalFlag = yes
     ),
     InitStats = profile_stats(MaxCSD, MaxCSS, MaxPD, MaxPS, TicksPerSec,
-        InstrumentQuanta, UserQuanta, WordSize, CanonicalFlag),
+        InstrumentQuanta, UserQuanta, NumCallSeqs, WordSize, CanonicalFlag),
     InitDeep = initial_deep(
         InitStats,
         make_pdptr(RootPDI),
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_deep_profiling.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_deep_profiling.c,v
retrieving revision 1.22
diff -u -r1.22 mercury_deep_profiling.c
--- runtime/mercury_deep_profiling.c	4 Oct 2006 22:25:16 -0000	1.22
+++ runtime/mercury_deep_profiling.c	5 Oct 2006 00:47:07 -0000
@@ -372,6 +372,7 @@
     int                     root_pd_id;
     FILE                    *fp;
     int                     ticks_per_sec;
+    unsigned                num_call_seqs;
     FILE                    *check_fp;
 
     fp = fopen(MR_MDPROF_DATAFILENAME, "wb+");
@@ -389,6 +390,7 @@
     }
 #endif
 
+    /* We overwrite these zeros (and the id string) after the seek below. */
     MR_write_out_id_string(fp);
     MR_write_fixed_size_int(fp, 0);
     MR_write_fixed_size_int(fp, 0);
@@ -400,10 +402,16 @@
 #else
     ticks_per_sec = 0;
 #endif
+#ifdef  MR_DEEP_PROFILING_CALL_SEQ
+    num_call_seqs = MR_deep_prof_cur_call_seq;
+#else
+    num_call_seqs = 0;
+#endif
 
     MR_write_num(fp, ticks_per_sec);
     MR_write_num(fp, MR_quanta_inside_deep_profiling_code);
     MR_write_num(fp, MR_quanta_outside_deep_profiling_code);
+    MR_write_num(fp, num_call_seqs);
     MR_write_byte(fp, sizeof(MR_Word));
     MR_write_byte(fp, 0); /* the canonical flag is MR_FALSE = 0 */
 
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list