From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 48A137F869 for ; Mon, 10 Mar 2014 12:28:43 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of bob.atkey@gmail.com) identity=pra; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bob.atkey@gmail.com"; x-sender="bob.atkey@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of bob.atkey@gmail.com designates 209.85.215.48 as permitted sender) identity=mailfrom; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bob.atkey@gmail.com"; x-sender="bob.atkey@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f48.google.com) identity=helo; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bob.atkey@gmail.com"; x-sender="postmaster@mail-la0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgCAIehHVPRVdcwlWdsb2JhbABaFoMrV6pzlkmBEggWDgEBAQEHDQkJEiqCJQEBAQRAARsSCwEDDAYFCw0NISIBEQEFAQoSGRKHUgEDEQ2iJIxfgw6VUwoZJwMKZIYjEQEFDIxTgXwHFoQiBJhFgTKPDRgphFo9 X-IPAS-Result: AjgCAIehHVPRVdcwlWdsb2JhbABaFoMrV6pzlkmBEggWDgEBAQEHDQkJEiqCJQEBAQRAARsSCwEDDAYFCw0NISIBEQEFAQoSGRKHUgEDEQ2iJIxfgw6VUwoZJwMKZIYjEQEFDIxTgXwHFoQiBJhFgTKPDRgphFo9 X-IronPort-AV: E=Sophos;i="4.97,623,1389740400"; d="scan'208";a="62103935" Received: from mail-la0-f48.google.com ([209.85.215.48]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Mar 2014 12:28:42 +0100 Received: by mail-la0-f48.google.com with SMTP id gf5so4529508lab.35 for ; Mon, 10 Mar 2014 04:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1pA1GznmJ6BzMxRU0odEf00Vuv7DeHqTfRM3zgQYNtM=; b=wCpkXSJMOAosM4ejCvGHXjMp8w3pfQ7ND1v+zNTFwEq93rQFLfqHH4mwEM0sFBp9YR Uvv8RYwb2SPoqL4AmU+1vLZ2jqOBUQ9+XdNOxNtFk0MP5KGoFl+9AFa2b+HeqytHvLIf qnFygJLbyAnZmAZWYQwuc/foHXafsrXN090eh37PvAu1kmPFvmnyXgvHyyyJNO8gz/hV o5X72hW3TDFLenLtI6+tCwKO8VlIy6yddbHqZXVfGnyWbov1vyxZvkuE5bvfc0zwBogi BJLu6qyFq/HRvr3G+ZAp/VYkU/xhqFFVCyip8kyMq8HR9GVTEs+va6JOvQXejRWXoKbS FMog== MIME-Version: 1.0 X-Received: by 10.152.21.166 with SMTP id w6mr1175827lae.39.1394450921982; Mon, 10 Mar 2014 04:28:41 -0700 (PDT) Received: by 10.113.10.40 with HTTP; Mon, 10 Mar 2014 04:28:41 -0700 (PDT) In-Reply-To: <20140310004725.65096.qmail@www1.g3.pair.com> References: <20140310004725.65096.qmail@www1.g3.pair.com> Date: Mon, 10 Mar 2014 11:28:41 +0000 Message-ID: From: Bob Atkey To: oleg@okmij.org Cc: raphlalou@gmail.com, "caml-list@inria.fr" , martin.jambon@ens-lyon.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] I never succeeded in using Format 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, 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