Note: This is taken from the Chicken Wiki, where a more recent version could be available.
The strictly-pretty library is an implementation of the algebraic pretty printer described by Christian Lindig in his paper Strictly Pretty.
A predicate that returns true if the given argument is a pretty-printer object constructed with the procedures in this library.
Returns an empty document object.
Returns a document object that contains the concatenated pair of documents.
Returns a document object that contains the given string.
Returns an inner document group that contains the given document, which will be broken up at the given indentation.
Returns an optional line break object.
Returns an optional line break object that uses the given string to delimit the break.
Returns a document group that contains the given document.
Concatenates the documents in the given list.
A parameterizable formatter for infix binary operation expressions. Given an indentation level INDENT, returns a procedure that takes a left operand (document object), operator (string), and a right operand (document object) and returns a document object that contains the formatted expression.
A parameterizable formatter for if-then-else expressions. Given an indentation level INDENT, and document objects that represent if,then,else keywords, respectively, returns a procedure that takes a condition (document object), true branch (string), and false branch (document object) and returns a document object that contains the formatted expression.
A parameterizable formatter for list expressions. Given an indentation level INDENT, a procedure that creates document object representations of the elements of the list, and a document object that represents the list element separator, returns a procedure that takes a list of elements and returns a document object that contains the formatted expression.
A parameterizable formatter for block expressions. Given an indentation level INDENT, and document objects that represent block open and close markers, returns a procedure that takes a document object and returns a new document object that encloses the given object in a block.
A parameterizable formatter for let expressions (local binding). Given an indentation level INDENT, and document objects that represent let,in,end keywords, respectively, returns a procedure that takes bindings block (document object) and body block (document object) and returns a document object that contains the formatted expression.
Formatted display procedure.
A procedure that generates simple document representation of the given document object.
A predicate that returns true if the given argument is a simple document object.
Generates string representation of the given simple document object.
(define cond1 ((doc:binop 2) (doc:text "a") (doc:text "==") (doc:text "b"))) (define e1 ((doc:binop 2) (doc:text "a") (doc:text "<<") (doc:text "2"))) (define e2 ((doc:binop 2) (doc:text "c") (doc:text "+") (doc:text "d"))) (define doc1 ((doc:ifthen 2 (doc:text "if") (doc:text "then") (doc:text "else")) cond1 e1 e2)) (define doc2 ((doc:block 2 (doc:text "(") (doc:text ")")) doc1)) (define doc3 ((doc:list 2 (lambda (x) x) doc:break) (list e1 e2))) (define doc4 ((doc:letblk 2 (doc:text "program") (doc:text "in") (doc:text "end")) doc3 doc1)) (print (sdoc->string (doc:format 32 doc4))) (print (sdoc->string (doc:format 10 doc4)))
Ivan Raikov
Copyright 2008 Ivan Raikov and the Okinawa Institute of Science and Technology.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.