caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bob Atkey <bob.atkey@gmail.com>
To: oleg@okmij.org
Cc: raphlalou@gmail.com, "caml-list@inria.fr" <caml-list@inria.fr>,
	martin.jambon@ens-lyon.org
Subject: Re: [Caml-list] I never succeeded in using Format
Date: Mon, 10 Mar 2014 11:28:41 +0000	[thread overview]
Message-ID: <CA+aevF_n0T1FQeka029scoXKy2dd+j3RWVeQUp988+UVgL6kmQ@mail.gmail.com> (raw)
In-Reply-To: <20140310004725.65096.qmail@www1.g3.pair.com>

Hi Oleg,

Have you compared your implementation to Christian Lindig's 'Strictly Pretty'?:

   http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2200

I think the runtime of his implementation is dependent on page width,
due to repeated use of the fits function to measure whether a group
fits within the current line. A simple optimisation is to precompute
this width, as (I think) you do. I did this in my simple
implementation of Lindig's idea:

   https://github.com/bobatkey/pretty-monospace/blob/master/lib/Pretty.ml

Neither of these implementations are incremental though; both require
the entire document to be present up front.

Bob



On 10 March 2014 00:47,  <oleg@okmij.org> wrote:
>
>> Another alternative to format for pretty-printing code (or other things): PPrint
>>
>> Release blog post (with some examples of use):
>> http://gallium.inria.fr/blog/first-release-of-pprint/
>> Documentation: http://gallium.inria.fr/~fpottier/pprint/doc/PPrint.html
>> Installation instruction: `opam install pprint`
>
> That formatter uses Wadler's Pretty-printer, which is not optimal. The
> optimal one takes linear time in the size of the document (regardless
> of the page width), and, for constant page width, formats documents of
> any size in constant space. It is obviously incremental and has
> bounded latency. There are several optimal formatters. The recent one
> was based on simple generators, described in
>         http://okmij.org/ftp/continuations/PPYield/index.html#pp
>
> Curiously, a Clojure programmer has read our paper and re-wrote the
> algorithm in Clojure -- without any help from us. It seems he is very
> satisfied with the results:
>         https://github.com/brandonbloom/fipp
> That web page has a few examples.
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

  reply	other threads:[~2014-03-10 11:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 16:34 Matthieu Dubuget
2014-03-06 16:46 ` Jeremy Yallop
2014-03-06 16:47 ` Benoit Vaugon
2014-03-06 17:02   ` Matthieu Dubuget
2014-03-06 17:06     ` David Sheets
2014-03-06 17:09       ` Matthieu Dubuget
2014-03-06 19:08         ` Martin Jambon
2014-03-07  7:20           ` Raphaël Proust
2014-03-10  0:47             ` oleg
2014-03-10 11:28               ` Bob Atkey [this message]
2014-03-11  9:32                 ` oleg
2014-03-14 10:21                   ` Francois Pottier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+aevF_n0T1FQeka029scoXKy2dd+j3RWVeQUp988+UVgL6kmQ@mail.gmail.com \
    --to=bob.atkey@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=martin.jambon@ens-lyon.org \
    --cc=oleg@okmij.org \
    --cc=raphlalou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).