unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How to use receive in a phase?
@ 2023-10-29  1:24 Tomas Volf
  0 siblings, 0 replies; only message in thread
From: Tomas Volf @ 2023-10-29  1:24 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-29  1:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-29  1:24 How to use receive in a phase? Tomas Volf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).