[m-rev.] diff: write_as_doc

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Aug 25 13:17:36 AEST 2022



On Thu, 25 Aug 2022 11:25:52 +1000, Peter Wang <novalazy at gmail.com> wrote:
> 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.

Another good catch. Thanks.

> write_as_doc is not the most descriptive. What about write_formatted?

There are many kinds of formatting. How about write_doc_formatted?

Zoltan.





More information about the reviews mailing list