gexp: Add printers for <gexp-input> and <gexp-output>.
authorLudovic Courtès <ludo@gnu.org>
Mon, 30 Mar 2015 20:59:24 +0000 (22:59 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 20 Apr 2015 13:41:41 +0000 (15:41 +0200)
* guix/gexp.scm (write-gexp-input, write-gexp-output): New procedures.
  (<gexp-input>, <gexp-output>): Use them as printers.

guix/gexp.scm

index de8b7bb..a2da72e 100644 (file)
@@ -179,6 +179,15 @@ This is the declarative counterpart of the 'interned-file' monadic procedure."
   (output    gexp-input-output)      ;string
   (native?   gexp-input-native?))    ;Boolean
 
+(define (write-gexp-input input port)
+  (match input
+    (($ <gexp-input> thing output #f)
+     (format port "#<gexp-input ~s:~a>" thing output))
+    (($ <gexp-input> thing output #t)
+     (format port "#<gexp-input native ~s:~a>" thing output))))
+
+(set-record-type-printer! <gexp-input> write-gexp-input)
+
 (define* (gexp-input thing                        ;convenience procedure
                      #:optional (output "out")
                      #:key native?)
@@ -193,6 +202,13 @@ whether this should be considered a \"native\" input or not."
   gexp-output?
   (name gexp-output-name))
 
+(define (write-gexp-output output port)
+  (match output
+    (($ <gexp-output> name)
+     (format port "#<gexp-output ~a>" name))))
+
+(set-record-type-printer! <gexp-output> write-gexp-output)
+
 (define raw-derivation
   (store-lift derivation))