The cl-wadler-pprint Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-wadler-pprint Reference Manual

This is the cl-wadler-pprint Reference Manual, version 0.1.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Dec 02 09:53:33 2019 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

cl-wadler-pprint

An implementation of "A Prettier Printer" by Philip Wadler in Common Lisp.

Example

(defclass foo ()
  ((bar :initarg :bar :reader bar)
   (baz :initarg :baz :reader quux)))

(def-pretty-object foo ()
  (bar baz))

; at width 80
(pretty t (make-instance 'foo :bar 1 :baz 2))
; #<FOO :BAR 1 :BAZ 2>

; at width 20
(pretty t (make-instance 'foo :bar 1 :baz 2))
; #<FOO :BAR 1
;       :BAZ 2>

TODOs

Notes

ABCL

In my entrypoint (written in Java), I've got a method:

import java.io.IOException;
import java.util.Scanner;
import org.armedbear.lisp.JavaObject;
import org.armedbear.lisp.Packages;

public static void updateRightMargin() {
	int rightMargin;
	try {
		Process proc = new ProcessBuilder("tput", "cols")
			.inheritIO()
			.redirectOutput(ProcessBuilder.Redirect.PIPE)
			.start();
		rightMargin = new Scanner(proc.getInputStream()).nextInt();
		if(proc.waitFor() != 0) {
			logError("Failed to update *PRINT-RIGHT-MARGIN*.");
			return;
		}
	} catch(InterruptedException ex) {
		logError("Failed to update *PRINT-RIGHT-MARGIN*: " + ex);
		return;
	} catch(IOException ex) {
		logError("Failed to update *PRINT-RIGHT-MARGIN*: " + ex);
		return;
	}

	Packages.findPackage("COMMON-LISP")
		.findAccessibleSymbol("*PRINT-RIGHT-MARGIN*")
		.setSymbolValue(JavaObject.getInstance(rightMargin, true));
}

and in main, code like:

import sun.misc.Signal;
import sun.misc.SignalHandler;

Signal.handle(new Signal("WINCH"), new SignalHandler() {
	public void handle(Signal sig) {
		Main.updateRightMargin();
	}
});
updateRightMargin();

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-wadler-pprint

Author

Nathan Ringo <nathan@remexre.xyz>

License

Apache-2.0/MIT

Description

An implementation of A Prettier Printer in Common Lisp.

Version

0.1.0

Source

cl-wadler-pprint.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-wadler-pprint.asd

Location

cl-wadler-pprint.asd

Systems

cl-wadler-pprint (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-wadler-pprint/package.lisp

Parent

cl-wadler-pprint (system)

Location

package.lisp

Packages

wadler-pprint


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cl-wadler-pprint/wadler-pprint.lisp

Dependency

package.lisp (file)

Parent

cl-wadler-pprint (system)

Location

wadler-pprint.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 wadler-pprint

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: def-pretty-object CLASS (&key PRINT-OBJECT) (&rest SLOTS)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: bracket L R &rest BODY
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: group &rest DOC
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: nest WIDTH &rest DOC
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: newline-or STR
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: pretty STREAM VALUE &key WIDTH

Pretty-prints a VALUE to the given STREAM, with the given WIDTH.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: pretty* STREAM DOC &key WIDTH

Pretty-prints a DOCument to the given STREAM, with the given WIDTH.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: spread &rest DOCS
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: stack &rest DOCS
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: text STR
Package

wadler-pprint

Source

wadler-pprint.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: pretty-object OBJECT

Converts an object to a document.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Methods
Method: pretty-object OBJ
Method: pretty-object (OBJ vector)
Method: pretty-object (OBJ cons)

Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Structures

Structure: nest ()
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: width
Type

fixnum

Initform

(error "must provide width")

Readers

nest-width (function)

Writers

(setf nest-width) (function)

Slot: doc
Type

wadler-pprint::doc

Initform

(error "must provide doc")

Readers

nest-doc (function)

Writers

(setf nest-doc) (function)

Structure: text ()
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: string
Type

string

Initform

(error "must provide string")

Readers

text-string (function)

Writers

(setf text-string) (function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: be WIDTH POSN DOCS
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: best WIDTH POSN DOC
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: better WIDTH POSN X Y
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: copy-flatten INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: copy-nest INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: copy-newline INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: copy-text INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: copy-union-doc INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: docp DOC

Returns whether the given value is a document.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: first-layout DOCS
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: fits WIDTH LAYOUT-DOC

Returns whether a given LAYOUT-DOC occupies no more than WIDTH bytes.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: flatten DOC
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: flatten-doc INSTANCE
Function: (setf flatten-doc) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: flatten-p OBJECT
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: join LIST SEP
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: make-flatten &key (DOC DOC)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: make-nest &key (WIDTH WIDTH) (DOC DOC)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: make-newline &key (STRING STRING)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: make-text &key (STRING STRING)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: make-union-doc &key (LHS LHS) (RHS RHS)
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: nest-doc INSTANCE
Function: (setf nest-doc) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: nest-p OBJECT
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: nest-width INSTANCE
Function: (setf nest-width) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: newline-p OBJECT
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: newline-string INSTANCE
Function: (setf newline-string) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: pretty-tail OBJ
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: text-p OBJECT
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: text-string INSTANCE
Function: (setf text-string) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: union-doc-lhs INSTANCE
Function: (setf union-doc-lhs) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: union-doc-p OBJECT
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Function: union-doc-rhs INSTANCE
Function: (setf union-doc-rhs) VALUE INSTANCE
Package

wadler-pprint

Source

wadler-pprint.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Structures

Structure: flatten ()
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: doc
Type

wadler-pprint::doc

Initform

(error "must provide doc")

Readers

flatten-doc (function)

Writers

(setf flatten-doc) (function)

Structure: newline ()
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: string
Type

string

Initform

(error "must provide string")

Readers

newline-string (function)

Writers

(setf newline-string) (function)

Structure: union-doc ()
Package

wadler-pprint

Source

wadler-pprint.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: lhs
Type

wadler-pprint::doc

Initform

(error "must provide lhs")

Readers

union-doc-lhs (function)

Writers

(setf union-doc-lhs) (function)

Slot: rhs
Type

wadler-pprint::doc

Initform

(error "must provide rhs")

Readers

union-doc-rhs (function)

Writers

(setf union-doc-rhs) (function)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Types

Type: doc ()

An imprecise check for whether a value is a document.

Package

wadler-pprint

Source

wadler-pprint.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-wadler-pprint.asd: The cl-wadler-pprint․asd file
cl-wadler-pprint/package.lisp: The cl-wadler-pprint/package․lisp file
cl-wadler-pprint/wadler-pprint.lisp: The cl-wadler-pprint/wadler-pprint․lisp file

F
File, Lisp, cl-wadler-pprint.asd: The cl-wadler-pprint․asd file
File, Lisp, cl-wadler-pprint/package.lisp: The cl-wadler-pprint/package․lisp file
File, Lisp, cl-wadler-pprint/wadler-pprint.lisp: The cl-wadler-pprint/wadler-pprint․lisp file

L
Lisp File, cl-wadler-pprint.asd: The cl-wadler-pprint․asd file
Lisp File, cl-wadler-pprint/package.lisp: The cl-wadler-pprint/package․lisp file
Lisp File, cl-wadler-pprint/wadler-pprint.lisp: The cl-wadler-pprint/wadler-pprint․lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
B   C   D   F   G   J   M   N   P   S   T   U  
Index Entry  Section

(
(setf flatten-doc): Internal functions
(setf nest-doc): Internal functions
(setf nest-width): Internal functions
(setf newline-string): Internal functions
(setf text-string): Internal functions
(setf union-doc-lhs): Internal functions
(setf union-doc-rhs): Internal functions

B
be: Internal functions
best: Internal functions
better: Internal functions
bracket: Exported functions

C
copy-flatten: Internal functions
copy-nest: Internal functions
copy-newline: Internal functions
copy-text: Internal functions
copy-union-doc: Internal functions

D
def-pretty-object: Exported macros
docp: Internal functions

F
first-layout: Internal functions
fits: Internal functions
flatten: Internal functions
flatten-doc: Internal functions
flatten-p: Internal functions
Function, (setf flatten-doc): Internal functions
Function, (setf nest-doc): Internal functions
Function, (setf nest-width): Internal functions
Function, (setf newline-string): Internal functions
Function, (setf text-string): Internal functions
Function, (setf union-doc-lhs): Internal functions
Function, (setf union-doc-rhs): Internal functions
Function, be: Internal functions
Function, best: Internal functions
Function, better: Internal functions
Function, bracket: Exported functions
Function, copy-flatten: Internal functions
Function, copy-nest: Internal functions
Function, copy-newline: Internal functions
Function, copy-text: Internal functions
Function, copy-union-doc: Internal functions
Function, docp: Internal functions
Function, first-layout: Internal functions
Function, fits: Internal functions
Function, flatten: Internal functions
Function, flatten-doc: Internal functions
Function, flatten-p: Internal functions
Function, group: Exported functions
Function, join: Internal functions
Function, make-flatten: Internal functions
Function, make-nest: Internal functions
Function, make-newline: Internal functions
Function, make-text: Internal functions
Function, make-union-doc: Internal functions
Function, nest: Exported functions
Function, nest-doc: Internal functions
Function, nest-p: Internal functions
Function, nest-width: Internal functions
Function, newline-or: Exported functions
Function, newline-p: Internal functions
Function, newline-string: Internal functions
Function, pretty: Exported functions
Function, pretty*: Exported functions
Function, pretty-tail: Internal functions
Function, spread: Exported functions
Function, stack: Exported functions
Function, text: Exported functions
Function, text-p: Internal functions
Function, text-string: Internal functions
Function, union-doc-lhs: Internal functions
Function, union-doc-p: Internal functions
Function, union-doc-rhs: Internal functions

G
Generic Function, pretty-object: Exported generic functions
group: Exported functions

J
join: Internal functions

M
Macro, def-pretty-object: Exported macros
make-flatten: Internal functions
make-nest: Internal functions
make-newline: Internal functions
make-text: Internal functions
make-union-doc: Internal functions
Method, pretty-object: Exported generic functions
Method, pretty-object: Exported generic functions
Method, pretty-object: Exported generic functions

N
nest: Exported functions
nest-doc: Internal functions
nest-p: Internal functions
nest-width: Internal functions
newline-or: Exported functions
newline-p: Internal functions
newline-string: Internal functions

P
pretty: Exported functions
pretty*: Exported functions
pretty-object: Exported generic functions
pretty-object: Exported generic functions
pretty-object: Exported generic functions
pretty-object: Exported generic functions
pretty-tail: Internal functions

S
spread: Exported functions
stack: Exported functions

T
text: Exported functions
text-p: Internal functions
text-string: Internal functions

U
union-doc-lhs: Internal functions
union-doc-p: Internal functions
union-doc-rhs: Internal functions

Jump to:   (  
B   C   D   F   G   J   M   N   P   S   T   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   D   L   R   S   W  
Index Entry  Section

D
doc: Exported structures
doc: Internal structures

L
lhs: Internal structures

R
rhs: Internal structures

S
Slot, doc: Exported structures
Slot, doc: Internal structures
Slot, lhs: Internal structures
Slot, rhs: Internal structures
Slot, string: Exported structures
Slot, string: Internal structures
Slot, width: Exported structures
string: Exported structures
string: Internal structures

W
width: Exported structures

Jump to:   D   L   R   S   W  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   D   F   N   P   S   T   U   W  
Index Entry  Section

C
cl-wadler-pprint: The cl-wadler-pprint system

D
doc: Internal types

F
flatten: Internal structures

N
nest: Exported structures
newline: Internal structures

P
Package, wadler-pprint: The wadler-pprint package

S
Structure, flatten: Internal structures
Structure, nest: Exported structures
Structure, newline: Internal structures
Structure, text: Exported structures
Structure, union-doc: Internal structures
System, cl-wadler-pprint: The cl-wadler-pprint system

T
text: Exported structures
Type, doc: Internal types

U
union-doc: Internal structures

W
wadler-pprint: The wadler-pprint package

Jump to:   C   D   F   N   P   S   T   U   W