diff mbox series

[bug#36162,3/4] inferior: Add 'read-repl-response'.

Message ID 20190610214130.19378-3-ludo@gnu.org
State Accepted
Headers show
Series [bug#36162,1/4] gexp: Add 'lower-gexp' and express'gexp->derivation' in terms of it. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Ludovic Courtès June 10, 2019, 9:41 p.m. UTC
* guix/inferior.scm (read-repl-response): New procedure.
(read-inferior-response): Use it.
---
 guix/inferior.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/guix/inferior.scm b/guix/inferior.scm
index 63c95141d7..fee97750b6 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -59,6 +59,7 @@ 
             inferior-eval
             inferior-eval-with-store
             inferior-object?
+            read-repl-response
 
             inferior-packages
             inferior-available-packages
@@ -183,7 +184,8 @@  equivalent.  Return #f if the inferior could not be launched."
 
 (set-record-type-printer! <inferior-object> write-inferior-object)
 
-(define (read-inferior-response inferior)
+(define (read-repl-response port)
+  "Read a (guix repl) response from PORT and return it as a Scheme object."
   (define sexp->object
     (match-lambda
       (('value value)
@@ -191,12 +193,15 @@  equivalent.  Return #f if the inferior could not be launched."
       (('non-self-quoting address string)
        (inferior-object address string))))
 
-  (match (read (inferior-socket inferior))
+  (match (read port)
     (('values objects ...)
      (apply values (map sexp->object objects)))
     (('exception key objects ...)
      (apply throw key (map sexp->object objects)))))
 
+(define (read-inferior-response inferior)
+  (read-repl-response (inferior-socket inferior)))
+
 (define (send-inferior-request exp inferior)
   (write exp (inferior-socket inferior))
   (newline (inferior-socket inferior)))