summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-04-30 23:16:03 +0200
committerLudovic Courtès <ludo@gnu.org>2014-04-30 23:16:23 +0200
commit7560b00b1c9f24ceff7a9295ac3453594b14242d (patch)
tree3ab5bfec7d310218b4ba43d7bc44ae482cd243cd
parente1485c7b3846dabc6f9ea2d55bf5766657d0b19b (diff)
downloadpatches-7560b00b1c9f24ceff7a9295ac3453594b14242d.tar
patches-7560b00b1c9f24ceff7a9295ac3453594b14242d.tar.gz
gexp: Add pretty printer.
* guix/gexp.scm (write-gexp): New procedure. <top level>: Add call to 'set-record-type-printer!'.
-rw-r--r--guix/gexp.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index a52360cd11..79b6ec7085 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -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>