[m-rev.] For review: deconstruct non-canonical terms in pretty_printer.m
Ralph Becket
rafe at csse.unimelb.edu.au
Thu Oct 11 14:02:34 AEST 2007
Here's an updated logfile and diff which should address the review
comments:
Support pretty-printing the structure of non-canonical values.
Estimated hours taken: 1
Branches: main
NEWS:
Mention the changes made here.
library/pretty_printer.m:
Rename the format preds to write_doc.
Add an argument to the fully parameterised version of write_doc
specifying whether non-canonical terms should be handled by
just printing the type name and arity (`canonicalize') or by
showing their structure (`include_details_cc').
Make the canonicalize version det and the include_details_cc version
cc_multi and propagate the mode changes and extra argument
through the code.
browser/browse.m:
Call the new version of write_doc with include_details_cc in a
promise_equivalent_solutions scope (this is sound because we're writing
to stdout).
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer.m:
Update the test case to include a non-canonical type.
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.479
diff -u -r1.479 NEWS
--- NEWS 25 Sep 2007 23:18:44 -0000 1.479
+++ NEWS 11 Oct 2007 04:02:48 -0000
@@ -23,6 +23,11 @@
Changes to the Mercury standard library:
+* The pretty_printer module interface has changed. The `format' preds are
+ now named `write_doc'. The fully parameterised version of write_doc now
+ takes an extra argument controlling how non-canonical values should be
+ handled.
+
* A module for handling directed graphs, digraph.m, has been added. This
supersedes relation.m and svrelation.m in that has a more consistent
interface (which supports state variable notation), provides more type
@@ -242,6 +247,8 @@
Changes to the Mercury debugger:
+* The pretty printer now shows the structure of non-canonical values.
+
* A `track' mdb command has been added.
* The `dd' command now accepts a `--reset-knowledge-base' option.
Index: browser/browse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.71
diff -u -r1.71 browse.m
--- browser/browse.m 22 Aug 2007 22:36:16 -0000 1.71
+++ browser/browse.m 9 Oct 2007 06:55:26 -0000
@@ -1222,7 +1222,10 @@
Limit = linear(Size)
),
- format(S, Formatters, Width, Lines, Limit, Doc, !IO).
+ promise_equivalent_solutions [!:IO] (
+ write_doc(S, include_details_cc, Formatters, Width, Lines, Limit, Doc,
+ !IO)
+ ).
%---------------------------------------------------------------------------%
Index: library/pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/pretty_printer.m,v
retrieving revision 1.6
diff -u -r1.6 pretty_printer.m
--- library/pretty_printer.m 3 Sep 2007 16:41:41 -0000 1.6
+++ library/pretty_printer.m 9 Oct 2007 06:52:51 -0000
@@ -44,6 +44,7 @@
:- module pretty_printer.
:- interface.
+:- import_module deconstruct.
:- import_module list.
:- import_module io.
:- import_module stream.
@@ -178,10 +179,13 @@
% MaxLines lines, fomatting format_univ(_) docs using specialised
% formatters Formatters starting with pretty-printer limits Limit.
%
-:- pred format(Stream::in, formatter_map::in, int::in, int::in,
- formatting_limit::in, doc::in, State::di, State::uo)
- is det
+:- pred write_doc(Stream, noncanon_handling, formatter_map, int, int,
+ formatting_limit, doc, State, State)
<= stream.writer(Stream, string, State).
+:- mode write_doc(in, in(canonicalize), in, in, in, in, in, di, uo)
+ is det.
+:- mode write_doc(in, in(include_details_cc), in, in, in, in, in, di, uo)
+ is cc_multi.
% Convenience predicates. A user-configurable set of type-specific
% formatters and formatting parameters are attached to the I/O state.
@@ -216,13 +220,14 @@
:- pred get_default_params(pp_params::out, io::di, io::uo) is det.
:- pred set_default_params(pp_params::in, io::di, io::uo) is det.
- % format(Doc, !IO)
- % format(FileStream, Doc, !IO)
+ % write_doc(Doc, !IO)
+ % write_doc(FileStream, Doc, !IO)
% Format Doc to io.stdout_stream or FileStream respectively, using
- % the default formatter_map and pp_params.
+ % include_details_cc, the default formatter_map, and the default
+ % pp_params.
%
-:- pred format(doc::in, io::di, io::uo) is det.
-:- pred format(io.output_stream::in, doc::in, io::di, io::uo) is det.
+:- pred write_doc(doc::in, io::di, io::uo) is det.
+:- pred write_doc(io.output_stream::in, doc::in, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -326,12 +331,12 @@
%-----------------------------------------------------------------------------%
-format(Stream, FMap, LineWidth, MaxLines, Limit, Doc, !IO) :-
+write_doc(Stream, Canonicalize, FMap, LineWidth, MaxLines, Limit, Doc, !IO) :-
Pri = ops.max_priority(ops.init_mercury_op_table),
RemainingWidth = LineWidth,
Indents = [],
- format(Stream, FMap, LineWidth, [Doc], RemainingWidth, _, Indents, _,
- MaxLines, _, Limit, _, Pri, _, !IO).
+ write_doc(Stream, Canonicalize, FMap, LineWidth, [Doc], RemainingWidth, _,
+ Indents, _, MaxLines, _, Limit, _, Pri, _, !IO).
%-----------------------------------------------------------------------------%
@@ -345,17 +350,20 @@
% - tracking current operator priority !Pri.
% Assumes that Docs is the output of expand.
%
-:- pred format(Stream::in, formatter_map::in, int::in, docs::in,
- int::in, int::out, indents::in, indents::out, int::in, int::out,
- formatting_limit::in, formatting_limit::out,
- ops.priority::in, ops.priority::out, State::di, State::uo)
- is det
+:- pred write_doc(Stream, noncanon_handling, formatter_map, int, docs,
+ int, int, indents, indents, int, int,
+ formatting_limit, formatting_limit,
+ ops.priority, ops.priority, State, State)
<= stream.writer(Stream, string, State).
+:- mode write_doc(in, in(canonicalize), in, in, in,
+ in, out, in, out, in, out, in, out, in, out, di, uo) is det.
+:- mode write_doc(in, in(include_details_cc), in, in, in,
+ in, out, in, out, in, out, in, out, in, out, di, uo) is cc_multi.
-format(_Stream, _FMap, _LineWidth, [],
+write_doc(_Stream, _Canonicalize, _FMap, _LineWidth, [],
!RemainingWidth, !Indents, !RemainingLines, !Limit, !Pri, !IO).
-format(Stream, FMap, LineWidth, [Doc | Docs0],
+write_doc(Stream, Canonicalize, FMap, LineWidth, [Doc | Docs0],
!RemainingWidth, !Indents, !RemainingLines, !Limit, !Pri, !IO) :-
( if !.RemainingLines =< 0 then
stream.put(Stream, "...", !IO)
@@ -386,7 +394,7 @@
Docs = list.(Docs1 ++ Docs0)
;
Doc = format_univ(Univ),
- expand_pp(FMap, Univ, Doc1, !Limit, !.Pri),
+ expand_pp(Canonicalize, FMap, Univ, Doc1, !Limit, !.Pri),
Docs = [Doc1 | Docs0]
;
Doc = format_list(Univs, Sep),
@@ -421,11 +429,11 @@
Doc = pp_internal(open_group),
OpenGroups = 1,
CurrentRemainingWidth = !.RemainingWidth,
- expand_docs(FMap, Docs0, Docs1, OpenGroups, !Limit, !Pri,
- CurrentRemainingWidth, RemainingWidthAfterGroup),
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups,
+ !Limit, !Pri, CurrentRemainingWidth, RemainingWidthAfterGroup),
( if RemainingWidthAfterGroup >= 0 then
- output_current_group(Stream, OpenGroups, Docs1, Docs,
- !RemainingWidth, !IO)
+ output_current_group(Stream, OpenGroups,
+ Docs1, Docs, !RemainingWidth, !IO)
else
Docs = Docs1
)
@@ -443,8 +451,8 @@
!:Pri = NewPri,
Docs = Docs0
),
- format(Stream, FMap, LineWidth, Docs, !RemainingWidth, !Indents,
- !RemainingLines, !Limit, !Pri, !IO)
+ write_doc(Stream, Canonicalize, FMap, LineWidth, Docs,
+ !RemainingWidth, !Indents, !RemainingLines, !Limit, !Pri, !IO)
).
%-----------------------------------------------------------------------------%
@@ -489,23 +497,27 @@
%-----------------------------------------------------------------------------%
- % expand_docs(Docs0, Docs, G, !L, !P, !R) expands out any doc(_),
- % pp_univ(_), format_list(_, _), and pp_term(_) constructors in Docs0 into
- % Docs, until either Docs0 has been completely expanded, or a nl is
- % encountered, or the remaining space on the current line has been
+ % expand_docs(Canonicalize, Docs0, Docs, G, !L, !P, !R) expands out any
+ % doc(_), pp_univ(_), format_list(_, _), and pp_term(_) constructors in
+ % Docs0 into Docs, until either Docs0 has been completely expanded, or a nl
+ % is encountered, or the remaining space on the current line has been
% accounted for.
% G is used to track nested groups.
% !L tracks the limits after accounting for expansion.
% !L tracks the operator priority after accounting for expansion.
% !R tracks the remaining line width after accounting for expansion.
%
-:- pred expand_docs(formatter_map::in, docs::in, docs::out, int::in,
- formatting_limit::in, formatting_limit::out,
- ops.priority::in, ops.priority::out, int::in, int::out) is det.
+:- pred expand_docs(noncanon_handling, formatter_map, docs, docs, int,
+ formatting_limit, formatting_limit, ops.priority, ops.priority,
+ int, int) is cc_multi.
+:- mode expand_docs(in(canonicalize), in, in, out, in, in, out,
+ in, out, in, out) is det.
+:- mode expand_docs(in(include_details_cc), in, in, out, in, in, out,
+ in, out, in, out) is cc_multi.
-expand_docs(_FMap, [], [], _OpenGroups, !Limit, !Pri, !N).
+expand_docs(_Canonicalize, _FMap, [], [], _OpenGroups, !Limit, !Pri, !N).
-expand_docs(FMap, [Doc | Docs0], Docs, OpenGroups,
+expand_docs(Canonicalize, FMap, [Doc | Docs0], Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth) :-
( if
(
@@ -524,7 +536,7 @@
Doc = str(String),
!:RemainingWidth = !.RemainingWidth - string.length(String),
Docs = [Doc | Docs1],
- expand_docs(FMap, Docs0, Docs1, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = nl,
@@ -532,64 +544,64 @@
Docs = [Doc | Docs0]
else
Docs = [Doc | Docs1],
- expand_docs(FMap, Docs0, Docs1, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups,
!Limit, !Pri, !RemainingWidth)
)
;
Doc = docs(Docs1),
- expand_docs(FMap, list.(Docs1 ++ Docs0), Docs, OpenGroups,
- !Limit, !Pri, !RemainingWidth)
+ expand_docs(Canonicalize, FMap, list.(Docs1 ++ Docs0), Docs,
+ OpenGroups, !Limit, !Pri, !RemainingWidth)
;
Doc = format_univ(Univ),
- expand_pp(FMap, Univ, Doc1, !Limit, !.Pri),
- expand_docs(FMap, [Doc1 | Docs0], Docs, OpenGroups,
+ expand_pp(Canonicalize, FMap, Univ, Doc1, !Limit, !.Pri),
+ expand_docs(Canonicalize, FMap, [Doc1 | Docs0], Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = format_list(Univs, Sep),
expand_format_list(Univs, Sep, Doc1, !Limit),
- expand_docs(FMap, [Doc1 | Docs0], Docs, OpenGroups,
+ expand_docs(Canonicalize, FMap, [Doc1 | Docs0], Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = format_term(Name, Univs),
expand_format_term(Name, Univs, Doc1, !Limit, !.Pri),
- expand_docs(FMap, [Doc1 | Docs0], Docs, OpenGroups,
+ expand_docs(Canonicalize, FMap, [Doc1 | Docs0], Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = format_susp(Susp),
expand_format_susp(Susp, Doc1, !Limit),
- expand_docs(FMap, [Doc1 | Docs0], Docs, OpenGroups,
+ expand_docs(Canonicalize, FMap, [Doc1 | Docs0], Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(indent(_)),
Docs = [Doc | Docs1],
- expand_docs(FMap, Docs0, Docs1, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(outdent),
Docs = [Doc | Docs1],
- expand_docs(FMap, Docs0, Docs1, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(open_group),
Docs = [Doc | Docs1],
OpenGroups1 = OpenGroups + ( if OpenGroups > 0 then 1 else 0 ),
- expand_docs(FMap, Docs0, Docs1, OpenGroups1,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups1,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(close_group),
Docs = [Doc | Docs1],
OpenGroups1 = OpenGroups - ( if OpenGroups > 0 then 1 else 0 ),
- expand_docs(FMap, Docs0, Docs1, OpenGroups1,
+ expand_docs(Canonicalize, FMap, Docs0, Docs1, OpenGroups1,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(set_limit(Lim)),
!:Limit = Lim,
- expand_docs(FMap, Docs0, Docs, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
;
Doc = pp_internal(set_op_priority(NewPri)),
!:Pri = NewPri,
- expand_docs(FMap, Docs0, Docs, OpenGroups,
+ expand_docs(Canonicalize, FMap, Docs0, Docs, OpenGroups,
!Limit, !Pri, !RemainingWidth)
)
).
@@ -625,10 +637,14 @@
% that succeeds, otherwise use the generic pretty- printer. If the
% pretty-printer limit has been exhausted then only "..." is produced.
%
-:- pred expand_pp(formatter_map::in, univ::in, doc::out,
- formatting_limit::in, formatting_limit::out, ops.priority::in) is det.
+:- pred expand_pp(noncanon_handling, formatter_map, univ, doc,
+ formatting_limit, formatting_limit, ops.priority).
+:- mode expand_pp(in(canonicalize), in, in, out, in, out, in)
+ is det.
+:- mode expand_pp(in(include_details_cc), in, in, out, in, out, in)
+ is cc_multi.
-expand_pp(FMap, Univ, Doc, !Limit, CurrentPri) :-
+expand_pp(Canonicalize, FMap, Univ, Doc, !Limit, CurrentPri) :-
( if
limit_overrun(!.Limit)
then
@@ -645,7 +661,7 @@
Doc = set_formatting_limit_correctly(!.Limit,
Formatter(Univ, ArgTypeDescs))
else
- deconstruct(univ_value(Univ), canonicalize, Name, _Arity, Args),
+ deconstruct(univ_value(Univ), Canonicalize, Name, _Arity, Args),
expand_format_term(Name, Args, Doc, !Limit, CurrentPri)
).
@@ -680,7 +696,8 @@
% term syntax.
%
:- pred expand_format_term(string::in, list(univ)::in, doc::out,
- formatting_limit::in, formatting_limit::out, ops.priority::in) is det.
+ formatting_limit::in, formatting_limit::out, ops.priority::in)
+ is det.
expand_format_term(Name, Args, Doc, !Limit, CurrentPri) :-
( if Args = [] then
@@ -870,13 +887,16 @@
%-----------------------------------------------------------------------------%
-format(Doc, !IO) :-
- format(io.stdout_stream, Doc, !IO).
+write_doc(Doc, !IO) :-
+ write_doc(io.stdout_stream, Doc, !IO).
-format(Stream, Doc, !IO) :-
+write_doc(Stream, Doc, !IO) :-
get_default_formatter_map(Formatters, !IO),
get_default_params(pp_params(LineWidth, MaxLines, Limit), !IO),
- format(Stream, Formatters, LineWidth, MaxLines, Limit, Doc, !IO).
+ promise_equivalent_solutions [!:IO] (
+ write_doc(Stream, include_details_cc, Formatters, LineWidth, MaxLines,
+ Limit, Doc, !IO)
+ ).
%-----------------------------------------------------------------------------%
Index: tests/hard_coded/test_pretty_printer.exp
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.exp,v
retrieving revision 1.3
diff -u -r1.3 test_pretty_printer.exp
--- tests/hard_coded/test_pretty_printer.exp 2 Sep 2007 22:43:03 -0000 1.3
+++ tests/hard_coded/test_pretty_printer.exp 8 Oct 2007 04:06:48 -0000
@@ -9,6 +9,14 @@
limit = triangular(1), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
[...]
|------------------------------------|
@@ -57,6 +65,14 @@
limit = triangular(1), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[...]
|----------------------------------------------------------------------------|
@@ -107,6 +123,15 @@
limit = triangular(1), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
[...]
|------------------------------------|
@@ -157,6 +182,15 @@
limit = triangular(1), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[...]
|----------------------------------------------------------------------------|
@@ -205,6 +239,14 @@
limit = linear(1), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
[...]
|------------------------------------|
@@ -253,6 +295,14 @@
limit = linear(1), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[...]
|----------------------------------------------------------------------------|
@@ -303,6 +353,15 @@
limit = linear(1), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
[...]
|------------------------------------|
@@ -353,6 +412,15 @@
limit = linear(1), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(...)
+...
+...
+...
+
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[...]
|----------------------------------------------------------------------------|
@@ -401,6 +469,14 @@
limit = triangular(10), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|------------------------------------|
+
+limit = triangular(10), max lines = 3, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...],
[1, 2, 3, 4, 5, 6, 7, ...],
[1, 2, 3, 4, 5, 6, ...],
@@ -461,6 +537,14 @@
limit = triangular(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|----------------------------------------------------------------------------|
+
+limit = triangular(10), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], [1, 2, 3, 4, 5, 6, 7, ...],
[1, 2, 3, 4, 5, 6, ...], [1, 2, 3, 4, 5, ...], [1, 2, 3, 4, ...],
[1, 2, 3, ...], [1, 2, ...], [1, ...], [...], ...]
@@ -518,6 +602,15 @@
limit = triangular(10), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|------------------------------------|
+
+limit = triangular(10), max lines = 10, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...],
[1, 2, 3, 4, 5, 6, 7, ...],
[1, 2, 3, 4, 5, 6, ...],
@@ -589,6 +682,15 @@
limit = triangular(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|----------------------------------------------------------------------------|
+
+limit = triangular(10), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], [1, 2, 3, 4, 5, 6, 7, ...],
[1, 2, 3, 4, 5, 6, ...], [1, 2, 3, 4, 5, ...], [1, 2, 3, 4, ...],
[1, 2, 3, ...], [1, 2, ...], [1, ...], [...], ...]
@@ -644,6 +746,14 @@
limit = triangular(100), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|------------------------------------|
+
+limit = triangular(100), max lines = 3, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -713,6 +823,14 @@
limit = triangular(100), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|----------------------------------------------------------------------------|
+
+limit = triangular(100), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -783,6 +901,15 @@
limit = triangular(100), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|------------------------------------|
+
+limit = triangular(100), max lines = 10, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -894,6 +1021,15 @@
limit = triangular(100), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|----------------------------------------------------------------------------|
+
+limit = triangular(100), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -982,6 +1118,14 @@
limit = linear(10), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|------------------------------------|
+
+limit = linear(10), max lines = 3, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], ...]
|------------------------------------|
@@ -1035,6 +1179,14 @@
limit = linear(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|----------------------------------------------------------------------------|
+
+limit = linear(10), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], ...]
|----------------------------------------------------------------------------|
@@ -1085,6 +1237,15 @@
limit = linear(10), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|------------------------------------|
+
+limit = linear(10), max lines = 10, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], ...]
|------------------------------------|
@@ -1140,6 +1301,15 @@
limit = linear(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|----------------------------------------------------------------------------|
+
+limit = linear(10), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, ...], ...]
|----------------------------------------------------------------------------|
@@ -1188,6 +1358,14 @@
limit = linear(100), max lines = 3, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|------------------------------------|
+
+limit = linear(100), max lines = 3, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -1257,6 +1435,14 @@
limit = linear(100), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+...
+|----------------------------------------------------------------------------|
+
+limit = linear(100), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -1327,6 +1513,15 @@
limit = linear(100), max lines = 10, line width = 38
|------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|------------------------------------|
+
+limit = linear(100), max lines = 10, line width = 38
+|------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@@ -1438,6 +1633,15 @@
limit = linear(100), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+non_canonical_bool(0)
+non_canonical_bool(1)
+non_canonical_bool(42)
+non_canonical_bool(43)
+
+|----------------------------------------------------------------------------|
+
+limit = linear(100), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
Index: tests/hard_coded/test_pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.m,v
retrieving revision 1.2
diff -u -r1.2 test_pretty_printer.m
--- tests/hard_coded/test_pretty_printer.m 2 Sep 2007 22:43:03 -0000 1.2
+++ tests/hard_coded/test_pretty_printer.m 8 Oct 2007 04:02:30 -0000
@@ -52,6 +52,10 @@
; op_tree * op_tree
; op_tree / op_tree.
+:- type non_canonical_bool
+ ---> non_canonical_bool(int)
+ where equality is non_canonical_bool_eq.
+
main(!IO) :-
@@ -215,6 +219,12 @@
indent("_4_", [nl, str("four"),
indent("_5_", [nl, str("five")])])])])])
]),
+ NonCanonTest = docs([
+ format(non_canonical_bool(0)), nl,
+ format(non_canonical_bool(1)), nl,
+ format(non_canonical_bool(42)), nl,
+ format(non_canonical_bool(43)), nl
+ ]),
( Limit = linear(100)
; Limit = linear(10)
; Limit = triangular(100)
@@ -236,6 +246,7 @@
; Doc = fmt_susp_seq(100)
; Doc = format(Tuple)
; Doc = format(Square)
+ ; Doc = NonCanonTest
; Doc = IndentTest
).
@@ -252,5 +263,17 @@
else mk_op_tree(1 + N/2) / mk_op_tree(0 + N/3)
).
+
+
+:- pred non_canonical_bool_eq(non_canonical_bool::in, non_canonical_bool::in)
+ is semidet.
+
+non_canonical_bool_eq(A, B) :-
+ promise_equivalent_solutions [AX, BX] (
+ A = non_canonical_bool(AX),
+ B = non_canonical_bool(BX)
+ ),
+ AX /\ 1 = BX /\ 1.
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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