6 Pretty-Printing
This library provides facilities for pretty-printing Datalog source. It can be required via:
| (require (planet jaymccarthy/datalog:1:0/pretty)) |
This library depends on the pprint PLaneT package, which can be required via:
(require (planet dherman/pprint:4))
See the documentation for pprint for information on how to use it.
| (format-datum d) → doc? |
| d : datum/c |
Formats a datum.
Examples: |
| > (pretty-print (format-datum 'sym)) |
sym |
| > (pretty-print (format-datum "str")) |
"str" |
| (format-variable v) → doc? |
| v : variable? |
Formats a variable.
Examples: |
| > (pretty-print (format-variable (make-variable #f 'Ancestor))) |
Ancestor |
| (format-constant c) → doc? |
| c : constant? |
Formats a constant.
Examples: |
| > (pretty-print (format-constant (make-constant #f 'joseph))) |
joseph |
| > (pretty-print (format-constant (make-constant #f "whom"))) |
"whom" |
| (format-term t) → doc? |
| t : term/c |
Formats a term.
Examples: |
| > (pretty-print (format-term (make-variable #f 'Ancestor))) |
Ancestor |
| > (pretty-print (format-term (make-constant #f 'joseph))) |
joseph |
| > (pretty-print (format-term (make-constant #f "whom"))) |
"whom" |
| (format-literal l) → doc? |
| l : literal? |
Formats a literal.
Examples: | ||||
| > (pretty-print (format-literal (make-literal #f 'true (list)))) | ||||
true | ||||
| ||||
ancestor(A, jay) | ||||
| ||||
joseph = jay |
| (format-literals ls) → doc? |
| ls : (listof literal?) |
Formats a list of literals as assertions for formatting prove results.
Examples: | ||||||||
| ||||||||
|
| (format-clause c) → doc? |
| c : clause? |
Formats a clause.
Examples: | ||||||||||||
| ||||||||||||
ancestor(joseph, jay) | ||||||||||||
| ||||||||||||
ancestor(A, B) :- parent(A, B) | ||||||||||||
| ||||||||||||
ancestor(A, B) :- parent(A, C), ancestor(C, B) |
| (format-assertion a) → doc? |
| a : assertion? |
Formats a assertion.
Examples: | ||||||||
| ||||||||
ancestor(joseph, jay). |
| (format-retraction r) → doc? |
| r : retraction? |
Formats a retraction.
Examples: | ||||||||
| ||||||||
ancestor(joseph, jay)~ |
| (format-query q) → doc? |
| q : query? |
Formats a query.
Examples: | ||||||
| ||||||
ancestor(joseph, jay)? |
| (format-statement s) → doc? |
| s : statement/c |
Formats a statement.
Examples: | ||||||
| ||||||
ancestor(joseph, jay)? |
| (format-program p) → doc? |
| p : program/c |
Formats a program.
Examples: | |||||||||||||
| |||||||||||||
|