((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/strictly-pretty" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "strictly-pretty" (toc) (section 3 "Introduction" (p "The " (tt "strictly-pretty") " library is an implementation of the algebraic pretty printer described by Christian Lindig in his paper " (link "http://citeseer.ist.psu.edu/lindig00strictly.html" "Strictly Pretty") ".")) (section 3 "Library procedures" (def (sig (procedure "doc?:: OBJECT -> BOOL" (id doc?))) (p "A predicate that returns true if the given argument is a pretty-printer object constructed with the procedures in this library.")) (def (sig (procedure "doc:empty?:: DOC -> BOOL" (id doc:empty?))) (p "Returns true if the given document object is empty, false otherwise.")) (def (sig (procedure "doc:empty:: () -> DOC" (id doc:empty))) (p "Returns an empty document object.")) (def (sig (procedure "doc:cons:: DOC * DOC -> DOC" (id doc:cons))) (p "Returns a document object that contains the concatenated pair of documents.")) (def (sig (procedure "doc:text:: STRING -> DOC" (id doc:text))) (p "Returns a document object that contains the given string.")) (def (sig (procedure "doc:nest:: INDENT * DOC -> DOC" (id doc:nest))) (p "Returns an inner document group that contains the given document, which will be broken up at the given indentation.")) (def (sig (procedure "doc:break:: () -> DOC" (id doc:break))) (p "Returns an optional line break object.")) (def (sig (procedure "doc:break-with:: STRING -> DOC" (id doc:break-with))) (p "Returns an optional line break object that uses the given string to delimit the break.")) (def (sig (procedure "doc:group:: DOC -> DOC" (id doc:group))) (p "Returns a document group that contains the given document.")) (def (sig (procedure "doc:concat:: LST -> DOC" (id doc:concat))) (p "Concatenates the documents in the given list.")) (def (sig (procedure "doc:binop:: INDENT -> LEFT * OPER * RIGHT -> DOC" (id doc:binop))) (p "A parameterizable formatter for infix binary operation expressions. Given an indentation level " (tt "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.")) (def (sig (procedure "doc:ifthen:: INDENT * IF * THEN * ELSE -> COND * IFTRUE * IFFALSE -> DOC" (id doc:ifthen))) (p "A parameterizable formatter for if-then-else expressions. Given an indentation level " (tt "INDENT") ", and document objects that represent " (tt "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.")) (def (sig (procedure "doc:list:: INDENT * ELEM->DOC * SEP -> LST -> DOC" (id doc:list))) (p "A parameterizable formatter for list expressions. Given an indentation level " (tt "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.")) (def (sig (procedure "doc:block:: INDENT * OPEN * CLOSE -> BODY -> DOC" (id doc:block))) (p "A parameterizable formatter for block expressions. Given an indentation level " (tt "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.")) (def (sig (procedure "doc:letblk:: INDENT * LET * IN * END -> E1 * E2 -> DOC" (id doc:letblk))) (p "A parameterizable formatter for let expressions (local binding). Given an indentation level " (tt "INDENT") ", and document objects that represent " (tt "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.")) (def (sig (procedure "doc:display:: WIDTH * DOC -> UNDEFINED" (id doc:display))) (p "Formatted display procedure.")) (def (sig (procedure "doc:format:: WIDTH * DOC -> SDOC" (id doc:format))) (p "A procedure that generates simple document representation of the given document object.")) (def (sig (procedure "sdoc?:: OBJECT -> BOOL" (id sdoc?))) (p "A predicate that returns true if the given argument is a simple document object.")) (def (sig (procedure "sdoc->string:: SDOC -> STRING" (id sdoc->string))) (p "Generates string representation of the given simple document object."))) (section 3 "Example" (highlight scheme "(define cond1 ((doc:binop 2) (doc:text \"a\") (doc:text \"==\") (doc:text \"b\")))\n(define e1    ((doc:binop 2) (doc:text \"a\") (doc:text \"<<\") (doc:text \"2\")))\n(define e2    ((doc:binop 2) (doc:text \"c\") (doc:text \"+\") (doc:text \"d\")))\n\n(define doc1 ((doc:ifthen 2 (doc:text \"if\") (doc:text \"then\") (doc:text \"else\"))\n\t      cond1 e1 e2))\n\n(define doc2 ((doc:block 2 (doc:text \"(\") (doc:text \")\")) doc1))\n\n(define doc3 ((doc:list 2 (lambda (x) x) doc:break) (list e1 e2)))\n(define doc4 ((doc:letblk 2 (doc:text \"program\") (doc:text \"in\") (doc:text \"end\"))\n\t      doc3 doc1))\n\n(print (sdoc->string (doc:format 32 doc4)))\n\n(print (sdoc->string (doc:format 10 doc4)))")) (section 3 "Author" (p (int-link "/users/ivan-raikov" "Ivan Raikov"))) (section 3 "Version" (dl (dt "1.4") (dd "Ported to Chicken 4") (dt "1.3") (dd "Added doc:empty? procedure") (dt "1.2") (dd "Now using matchable extension") (dt "1.1") (dd "Added doc:connect to list of exports") (dt "1.0") (dd "Initial version"))) (section 3 "License" (pre "Copyright 2008-2010 Ivan Raikov and the Okinawa Institute of Science\nand Technology.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or (at\nyour option) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nGeneral Public License for more details. \n\nA full copy of the GPL license can be found at\n<http://www.gnu.org/licenses/>."))))