help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use receive in a phase?


From: Tomas Volf
Subject: How to use receive in a phase?
Date: Sun, 29 Oct 2023 02:24:11 +0100

Hello,

I am trying to use receive in a phase, but for some reason it fails.  I modified
the hello-world example from the cookbook to demonstrate:

    (use-modules (gnu)
                 (guix build-system gnu)
                 (guix download)
                 (guix licenses)
                 (guix packages))
    
    (package
      (name "hello")
      (version "2.10")
      (source (origin
                (method url-fetch)
                (uri (string-append "mirror://gnu/hello/hello-" version
                                    ".tar.gz"))
                (sha256
                 (base32
                  "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
      (build-system gnu-build-system)
      (arguments
       (list
        #:phases #~(modify-phases %standard-phases
                     (add-after 'unpack 'xxx
                       (λ _
                         (use-modules (ice-9 receive))
                         (receive (a b)
                             (values 1 2)
                           (pk a)
                           (pk b)))))))
      (synopsis "Hello, GNU world: An example GNU package")
      (description
       "GNU Hello prints the message \"Hello, world!\" and then exits.  It
    serves as an example of standard GNU coding practices.  As such, it supports
    command-line arguments, multiple languages, and so on.")
      (home-page "https://www.gnu.org/software/hello/";)
      (license gpl3+))

Now when I try to build this package, I get this error:

    starting phase `xxx'
    error: in phase 'xxx': uncaught exception:
    unbound-variable #f "Unbound variable: ~S" (a) #f 
    phase `xxx' failed after 0.0 seconds
    Backtrace:
              11 (primitive-load "/gnu/store/x57gb3dj0cvvpzmy9r2nh32fcnn…")
    In guix/build/gnu-build-system.scm:
        908:2 10 (gnu-build #:source _ #:outputs _ #:inputs _ #:phases . #)
    In ice-9/boot-9.scm:
      1752:10  9 (with-exception-handler _ _ #:unwind? _ # _)
    In srfi/srfi-1.scm:
        634:9  8 (for-each #<procedure 7ffff77d0b80 at guix/build/gnu-b…> …)
    In ice-9/boot-9.scm:
      1752:10  7 (with-exception-handler _ _ #:unwind? _ # _)
    In guix/build/gnu-build-system.scm:
       929:23  6 (_)
    In ice-9/eval.scm:
       173:39  5 (_ #(#(#<directory (guile-user) 7ffff77f7c80>) (# # …)))
       182:19  4 (proc #(#(#<directory (guile-user) 7ffff77f7c80>) (# …)))
       142:16  3 (compile-top-call #<directory (guile-user) 7ffff77f7c80> …)
    In unknown file:
               2 (%resolve-variable (7 . a) #<directory (guile-user) 7ff…>)
    In ice-9/boot-9.scm:
      1685:16  1 (raise-exception _ #:continuable? _)
      1685:16  0 (raise-exception _ #:continuable? _)
    
    ice-9/boot-9.scm:1685:16: In procedure raise-exception:
    Unbound variable: a

Would anyone have any idea what is wrong and how can I correctly call function
returning multiple values in a phase (call-with-values is bit... unwieldy)?

Thank you,
Tomas Volf

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]