[m-rev.] diff: write_as_doc

Peter Wang novalazy at gmail.com
Thu Aug 25 11:25:52 AEST 2022


On Wed, 24 Aug 2022 10:21:27 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> diff --git a/library/pretty_printer.m b/library/pretty_printer.m
> index a3f75a2af..2c75a1cf8 100644
> --- a/library/pretty_printer.m
> +++ b/library/pretty_printer.m
> @@ -147,6 +147,14 @@
>  % Functions for converting docs to strings and writing them out to streams.
>  %
>  
> +    % write_as_doc(X, !IO):
> +    % write_as_doc(FileStream, X, !IO):
> +    %
> +    % Convert X to a doc, and then call write_doc on the result.
> +    %
> +:- pred write_as_doc(doc::in, io::di, io::uo) is det.
> +:- pred write_as_doc(io.output_stream::in, doc::in, io::di, io::uo) is det.
> +

X is already a doc, so it would pretty print the doc structure.
That's unlikely to be what you intended.

write_as_doc is not the most descriptive. What about write_formatted?

Peter


More information about the reviews mailing list