gexp: Add pretty printer.

* guix/gexp.scm (write-gexp): New procedure.
  <top level>: Add call to 'set-record-type-printer!'.
This commit is contained in:
Ludovic Courtès 2014-04-30 23:16:03 +02:00
parent e1485c7b38
commit 7560b00b1c
1 changed files with 10 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#:use-module (guix packages)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:export (gexp
@ -56,6 +57,15 @@
(references gexp-references) ; ((DRV-OR-PKG OUTPUT) ...)
(proc gexp-proc)) ; procedure
(define (write-gexp gexp port)
"Write GEXP on PORT."
(display "#<gexp " port)
(write (apply (gexp-proc gexp) (gexp-references gexp)) port)
(format port " ~a>"
(number->string (object-address gexp) 16)))
(set-record-type-printer! <gexp> write-gexp)
;; Reference to one of the derivation's outputs, for gexps used in
;; derivations.
(define-record-type <output-ref>