From unknown Sun Jun 22 11:34:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#67489 <67489@debbugs.gnu.org> To: bug#67489 <67489@debbugs.gnu.org> Subject: Status: [PATCH] monad-repl: Add REPL commands to inspect package arguments. Reply-To: bug#67489 <67489@debbugs.gnu.org> Date: Sun, 22 Jun 2025 18:34:46 +0000 retitle 67489 [PATCH] monad-repl: Add REPL commands to inspect package argu= ments. reassign 67489 guix-patches submitter 67489 Ludovic Court=C3=A8s severity 67489 normal tag 67489 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 12:20:23 2023 Received: (at submit) by debbugs.gnu.org; 27 Nov 2023 17:20:23 +0000 Received: from localhost ([127.0.0.1]:44693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7fHS-00060t-J9 for submit@debbugs.gnu.org; Mon, 27 Nov 2023 12:20:23 -0500 Received: from lists.gnu.org ([2001:470:142::17]:48982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7fHQ-00060Z-9i for submit@debbugs.gnu.org; Mon, 27 Nov 2023 12:20:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7fHB-0006RY-6U for guix-patches@gnu.org; Mon, 27 Nov 2023 12:20:05 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7fH8-0006qC-NR; Mon, 27 Nov 2023 12:20:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=MCtmqLvTGiCKgptuMwOHGQ6cp49gXT7uflbBblEspIs=; b=dq+DbQgMjPHpRq GWwBQZ+UeF6GGTzcmXAhrupR8lZDRIhjRd9qUembdvjM3OucAxWJO6r3CFZOLbs8jJYmy0CJU9wMY +WFFJqQxozsgweWg/HkgAcR59bqPwgJ2MOH+nbyo7QMyMIlp18I8tlNhEGrkXxl219+heAo2TQUQZ HsXBCI284gHJyg1uH3gWn6GsOn+jtken86LWTsKjyDWVu2AKhPVXbhHj2rR8bk5ozFUsm6sqxMhmF 4aCR3oFA0tn7C6QdjDr4mxXW0AzogedIoGq6ogECw/PLgSQZcpQKLt4jUkJlhT8kmWnEO6DwQZ0sV Ds1dQ5Kn7+Q+TmSr7htQ==; From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH] monad-repl: Add REPL commands to inspect package arguments. Date: Mon, 27 Nov 2023 18:19:43 +0100 Message-ID: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) From: Ludovic Courtès * guix/monad-repl.scm (keyword-argument-value, package-argument-command): New procedures. (phases, configure-flags, make-flags): New REPL commands. * doc/guix.texi (package Reference): Link to “Using Guix Interactively”. (Defining Package Variants): Add “Tips” quotation. (Build Phases): Add “Tip” quotation. (Using Guix Interactively): Document the new REPL commands. Change-Id: I7049c1d8aa9241e07d7c921aa396e578a1b4ef16 --- doc/guix.texi | 61 +++++++++++++++++++++++++++++++++++++ guix/monad-repl.scm | 74 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 131 insertions(+), 4 deletions(-) Hello! Someone recently suggested we should have better debugging facilities for packagers, in particular when dealing with package variants, inheritance, and so on, which make it harder to understand what’s going on. This change partially addresses that problem: new REPL commands let you inspect the code of #:phases, #:configure-flags, and #:make-flags. --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,use(guix) scheme@(guix-user)> ,use(gnu packages mpi) scheme@(guix-user)> ,use(gnu packages guile) scheme@(guix-user)> ,phases guile-3.0 $1 = (modify-phases (modify-phases %standard-phases (add-before 'configure 'pre-configure (lambda* (#:key inputs #:allow-other-keys) (let ((bash (assoc-ref inputs "bash"))) (substitute* "module/ice-9/popen.scm" (("/bin/sh") (string-append bash "/bin/bash"))) #t)))) (add-before 'check 'disable-stack-overflow-test (lambda _ (substitute* "test-suite/standalone/test-stack-overflow" (("!#") "!#\n(exit 77)\n"))))) scheme@(guix-user)> ,configure-flags openmpi $2 = `("--enable-mpi-ext=affinity" "--with-sge" "--enable-memchecker" "--with-valgrind" "--with-hwloc=external" "--with-libevent" "--enable-mpirun-prefix-by-default" "--enable-openib-control-hdr-padding" "--enable-openib-dynamic-sl" "--enable-openib-udcm" "--enable-openib-rdmacm" "--enable-openib-rdmacm-ibaddr" "--with-pmix=internal" ,(string-append "--with-pmi=" "/gnu/store/h3vmqdgfnfqyk84vc1p3z57dqhrccx7b-slurm-23.02.6")) --8<---------------cut here---------------end--------------->8--- Thoughts? Ludo’. diff --git a/doc/guix.texi b/doc/guix.texi index 1fd2e21608..7dde9b727b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7975,6 +7975,10 @@ package Reference @code{#:phases}. The @code{#:phases} keyword in particular lets you modify the set of build phases for your package (@pxref{Build Phases}). +The REPL has dedicated commands to interactively inspect values of some +of these arguments, as a convenient debugging aid (@pxref{Using Guix +Interactively}). + @quotation Compatibility Note Until version 1.3.0, the @code{arguments} field would typically use @code{quote} (@code{'}) or @code{quasiquote} (@code{`}) and no @@ -8774,6 +8778,23 @@ Defining Package Variants applied to implicit inputs as well. @end deffn +@quotation Tips +Understanding what a variant really looks like can be difficult as one +starts combining the tools shown above. There are several ways to +inspect a package before attempting to build it that can prove handy: + +@itemize +@item +You can inspect the package interactively at the REPL, for instance to +view its inputs, the code of its build phases, or its configure flags +(@pxref{Using Guix Interactively}). + +@item +When rewriting dependencies, @command{guix graph} can often help +visualize the changes that are made (@pxref{Invoking guix graph}). +@end itemize +@end quotation + @node Writing Manifests @section Writing Manifests @@ -10585,6 +10606,11 @@ Build Phases the helpers used by this phase, and for more examples of @code{modify-phases}. +@quotation Tip +You can inspect the code associated with a package's @code{#:phases} +argument interactively, at the REPL (@pxref{Using Guix Interactively}). +@end quotation + @cindex code staging @cindex staging, of code Keep in mind that build phases are code evaluated at the time the @@ -12763,6 +12789,30 @@ Using Guix Interactively $5 = ("." ".." "egrep" "fgrep" "grep") @end example +As a packager, you may be willing to inspect the build phases or flags +of a given package; this is particularly useful when relying a lot on +inheritance to define package variants (@pxref{Defining Package +Variants}) or when package arguments are a result of some computation, +both of which can make it harder to foresee what ends up in the package +arguments. Additional commands let you inspect those package arguments: + +@example +scheme@@(guix-user)> ,phases grep +$1 = (modify-phases %standard-phases + (add-after 'install 'fix-egrep-and-fgrep + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin"))) + (substitute* (list (string-append bin "/egrep") + (string-append bin "/fgrep")) + (("^exec grep") + (string-append "exec " bin "/grep"))))))) +scheme@@(guix-user)> ,configure-flags findutils +$2 = (list "--localstatedir=/var") +scheme@@(guix-user)> ,make-flags binutils +$3 = '("MAKEINFO=true") +@end example + At a lower-level, a useful command is @code{lower}: it takes a file-like object and ``lowers'' it into a derivation (@pxref{Derivations}) or a store file: @@ -12794,6 +12844,17 @@ Using Guix Interactively shows build events only, and higher levels print build logs. @end deffn +@deffn {REPL command} phases @var{package} +@deffnx {REPL command} configure-flags @var{package} +@deffnx {REPL command} make-flags @var{package} +These REPL commands return the value of one element of the +@code{arguments} field of @var{package} (@pxref{package Reference}): the +first one show the staged code associated with @code{#:phases} +(@pxref{Build Phases}), the second shows the code for +@code{#:configure-flags}, and @code{,make-flags} returns the code for +@code{#:make-flags}. +@end deffn + @deffn {REPL command} run-in-store @var{exp} Run @var{exp}, a monadic expression, through the store monad. @xref{The Store Monad}, for more information. diff --git a/guix/monad-repl.scm b/guix/monad-repl.scm index 8a6053edd5..d6b39112b7 100644 --- a/guix/monad-repl.scm +++ b/guix/monad-repl.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2022 Ludovic Courtès +;;; Copyright © 2014-2016, 2022-2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,13 +21,15 @@ (define-module (guix monad-repl) #:use-module (guix monads) #:use-module (guix utils) #:use-module (guix packages) + #:autoload (guix build-system) (bag) #:use-module (guix status) - #:autoload (guix gexp) (lower-object) + #:autoload (guix gexp) (gexp gexp? lower-gexp lowered-gexp-sexp lower-object) #:use-module ((guix derivations) #:select (derivation? derivation->output-paths built-derivations)) + #:autoload (guix read-print) (pretty-print-with-comments) #:use-module (ice-9 match) - #:use-module (ice-9 pretty-print) + #:autoload (ice-9 pretty-print) (pretty-print) #:use-module (system repl repl) #:use-module (system repl common) #:use-module (system repl command) @@ -138,4 +140,68 @@ (define-meta-command ((enter-store-monad guix) repl) (repl-option-set! new 'interp #t) (run-repl new)))) -;;; monad-repl.scm ends here + +;;; +;;; Viewing package arguments. +;;; + +(define (keyword-argument-value args keyword default) + "Return the value associated with KEYWORD in ARGS, a keyword/value sequence, +or DEFAULT if KEYWORD is missing from ARGS." + (let loop ((args args)) + (match args + (() + default) + ((kw value rest ...) + (if (eq? kw keyword) + value + (loop rest)))))) + +(define (package-argument-command repl form keyword default) + "Implement a command that display KEYWORD, a keyword such as #:phases, in +the arguments of the package FORM evaluates to. Return DEFAULT is KEYWORD is +missing from those arguments." + (match (repl-eval repl form) + ((? package? package) + (let* ((bag* (bag + (inherit (package->bag package)) + (build (lambda* (name inputs #:rest args) + (with-monad %store-monad + (return (keyword-argument-value args keyword + default)))))))) + (define phases + (parameterize ((%graft? #f)) + (with-store store + (set-build-options store + #:print-build-trace #t + #:print-extended-build-trace? #t + #:multiplexed-build-output? #t) + (run-with-store store + (mlet %store-monad ((exp (bag->derivation bag*))) + (if (gexp? exp) + (mlet %store-monad ((gexp (lower-gexp exp))) + (return (lowered-gexp-sexp gexp))) + (return exp))))))) + + (run-hook before-print-hook phases) + (let ((column (port-column (current-output-port)))) + (pretty-print-with-comments (current-output-port) phases + #:indent column) + (newline (current-output-port))))) + (_ + (format #t ";; ERROR: This command only accepts package records.~%")))) + +(define-meta-command ((phases guix) repl (form)) + "phases +Return the build phases of the package defined by FORM." + (package-argument-command repl form #:phases #~%standard-phases)) + +(define-meta-command ((configure-flags guix) repl (form)) + "configure-flags +Return the configure flags of the package defined by FORM." + (package-argument-command repl form #:configure-flags #~'())) + +(define-meta-command ((make-flags guix) repl (form)) + "make-flags +Return the make flags of the package defined by FORM." + (package-argument-command repl form #:make-flags #~'())) base-commit: f3173bb901c0eee6c71d066cffab115d27052fc1 -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 28 10:43:09 2023 Received: (at 67489) by debbugs.gnu.org; 28 Nov 2023 15:43:09 +0000 Received: from localhost ([127.0.0.1]:47450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80Ev-0001Zx-8K for submit@debbugs.gnu.org; Tue, 28 Nov 2023 10:43:09 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:38255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80Ep-0001Yx-SL for 67489@debbugs.gnu.org; Tue, 28 Nov 2023 10:43:07 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b3febbce3so4031825e9.1 for <67489@debbugs.gnu.org>; Tue, 28 Nov 2023 07:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701186171; x=1701790971; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=saJE5VVliHJ1hPtIIx8r3WsNRttuKDFvbUq2AsI8d3I=; b=TrhTusqZPr6OtcOKklm8StqDRk3+4C6L59iukpMmmUjX/TIo1vg16urazAHRWNJr35 aSwEVwPydLdzMYgSfb7fQJW8LS3qy/KWAwpNX7NUuO6OHmBzv5Szoj+7Bn8hiI1bDN27 412cyVod8CuEgMfqE1QXD0Tly2BQb4pyPJ9BLjaXsy3rtujpRV7muFg7nxM8QlvFoYi6 sVURALLDfq/6tx4SRvdPZ1cSay/0b8vwvfvyxp+N539rssOeEz2PYKIaArhJeAagisJt 24T3VhX4LbPTZp4Vn3b6abhFvXhyR8C9bc75sUU8xI+6/jTlLXGlYfcPHOiZxGol4NJA 35Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701186171; x=1701790971; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=saJE5VVliHJ1hPtIIx8r3WsNRttuKDFvbUq2AsI8d3I=; b=LPMT8quz7C9YfEtNe8dvjrqJwwU3/goQ9KCm5Ker+ppgxsPrnDawIt55sPv4nhrDhn KnRftB808IlJ/Q0sTNrUJqXn33a67GmQh+p0xFHW6QARNdGyL3SyfGAEMI0KXInrQ7D4 b+2AR2P0Xa111XNHCcYppiJhauvk7X4bZei3GPc29KffcmnBw9KTAbndiUoVO2YCkQ+q 59y0KeGdWY/9O6nm5DVimVdoZG2qFoAr+4Yfd2fTQObvVCWlDFptQAPq+DPEbQ8GcJcL GQ52in19T2vFdncpiyH1YnzKH9y8eCJglurv4+/kl3LlJFsYTy9Q760BLQfU1No9qs7A YXvw== X-Gm-Message-State: AOJu0YyMvpC2SN8sPLmY8sKJKYB9aJFX0Y8DyyT5poZJh4ihoBWkFrkw 2Ns7pCE2u328l+fCnEiiOz8= X-Google-Smtp-Source: AGHT+IFvAAZS9zl93DEILSgvtTz8NxM8TJeVoZg9XRDI1RINHoJYHPORhbMNjg1iPnxwZpTQXenAUg== X-Received: by 2002:adf:fccb:0:b0:332:fb6a:6206 with SMTP id f11-20020adffccb000000b00332fb6a6206mr5204300wrs.2.1701186170618; Tue, 28 Nov 2023 07:42:50 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id v5-20020a5d6105000000b0032f7fab0712sm15245883wrt.52.2023.11.28.07.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:42:50 -0800 (PST) From: Simon Tournier To: Ludovic =?utf-8?Q?Court=C3=A8s?= , 67489@debbugs.gnu.org Subject: Re: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments. In-Reply-To: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> References: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> Date: Tue, 28 Nov 2023 11:49:39 +0100 Message-ID: <87a5qycfuk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, TLDR: All LGTM. :-) Minor comments. Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zimon.toutoune[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:333 listed in] [list.dnswl.org] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 67489 Cc: Josselin Poiret , Mathieu Othacehe , Ludovic =?utf-8?Q?Court=C3=A8s?= , Tobias Geerinckx-Rice , Ricardo Wurmus , Ludovic =?utf-8?Q?Court=C3=A8s?= , Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) Hi, TLDR: All LGTM. :-) Minor comments. On Mon, 27 Nov 2023 at 18:19, Ludovic Court=C3=A8s wrote: > Someone recently suggested we should have better debugging facilities > for packagers, in particular when dealing with package variants, > inheritance, and so on, which make it harder to understand what=E2=80=99s > going on. >From a quick test: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,phases cava $1 =3D (modify-phases %standard-phases (replace 'bootstrap (lambda _ (setenv "HOME" (getcwd)) (invoke "sh" "autogen.sh"))) (add-before 'build 'make-cava-ldflags (lambda _ (mkdir-p (string-append ((@ (guile) getenv) "out") "/lib")))) (add-after 'install 'data (lambda _ (for-each (lambda (file) (install-file file (string-append ((@ (guile) getenv) "out") "/share/doc/examples"))) (find-files "example_files"))))) scheme@(guix-user)> ,configure-flags cava $2 =3D (list (string-append "PREFIX=3D" ((@ (guile) getenv) "out")) (string-append "FONT_DIR=3D" ((@ (guile) getenv) "out") "/share/consolefonts")) --8<---------------cut here---------------end--------------->8--- Cool! Very helpful. Much better than, something like: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,pp (cdr (memq #:phases (package-arguments cava))) $3 =3D (# "/lib")))) (add-after (quote install) (quote data) (lambd= a _ (for-each (lambda (file) (install-file file (string-append # "/share/doc/examples"))) (find-files "example_files"))))) gnu/packag= es/audio.scm:5161:11 7f7258403a50>) --8<---------------cut here---------------end--------------->8--- Without drifting, why not the meta-command ,arguments? For example, the package could also have other specific keywords that maybe I would like to inspect from the REPL. For example, some packages have their own keywords as #:julia-package-name. Well, package-arguments partially does the job: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,pp (package-arguments julia-uris) $5 =3D (#:julia-package-name "URIs" #:julia-package-uuid "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" #:phases #) --8<---------------cut here---------------end--------------->8--- Other said, it could be nice to: 1. pretty-print package-arguments by default, 2. and compile the G-expressions. Hence ,arguments. :-) > +As a packager, you may be willing to inspect the build phases or flags > +of a given package; this is particularly useful when relying a lot on > +inheritance to define package variants (@pxref{Defining Package > +Variants}) or when package arguments are a result of some computation, > +both of which can make it harder to foresee what ends up in the package > +arguments. Additional commands let you inspect those package arguments: > + > +@example > +scheme@@(guix-user)> ,phases grep > +$1 =3D (modify-phases %standard-phases > + (add-after 'install 'fix-egrep-and-fgrep > + (lambda* (#:key outputs #:allow-other-keys) > + (let* ((out (assoc-ref outputs "out")) > + (bin (string-append out "/bin"))) > + (substitute* (list (string-append bin "/egrep") > + (string-append bin "/fgrep")) > + (("^exec grep") > + (string-append "exec " bin "/grep"))))))) > +scheme@@(guix-user)> ,configure-flags findutils > +$2 =3D (list "--localstatedir=3D/var") > +scheme@@(guix-user)> ,make-flags binutils > +$3 =3D '("MAKEINFO=3Dtrue") > +@end example > + Here all is clear. What can be confusing is the expansion of #$output as ((@ (guile) getenv) "out"). Maybe it could be worth to document this under G-expression section. Or provide a similar example using G-expression under the section G-expression. Well, that=E2=80=99s unrelated to this patch and could be done separately. = :-) > ;;; GNU Guix --- Functional package management for GNU > -;;; Copyright =C2=A9 2014, 2015, 2016, 2022 Ludovic Court=C3=A8s > +;;; Copyright =C2=A9 2014-2016, 2022-2023 Ludovic Court=C3=A8s > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -21,13 +21,15 @@ (define-module (guix monad-repl) > #:use-module (guix monads) > #:use-module (guix utils) > #:use-module (guix packages) > + #:autoload (guix build-system) (bag) > #:use-module (guix status) > - #:autoload (guix gexp) (lower-object) > + #:autoload (guix gexp) (gexp gexp? lower-gexp lowered-gexp-sexp lowe= r-object) > #:use-module ((guix derivations) > #:select (derivation? > derivation->output-paths built-derivations)) > + #:autoload (guix read-print) (pretty-print-with-comments) > #:use-module (ice-9 match) > - #:use-module (ice-9 pretty-print) > + #:autoload (ice-9 pretty-print) (pretty-print) Out of curiosity, what is the advantage for #:autoload versus #:use-module + #:select? > +(define (keyword-argument-value args keyword default) > + "Return the value associated with KEYWORD in ARGS, a keyword/value seq= uence, > +or DEFAULT if KEYWORD is missing from ARGS." > + (let loop ((args args)) > + (match args > + (() > + default) > + ((kw value rest ...) > + (if (eq? kw keyword) > + value > + (loop rest)))))) ( Aside. Each time, I am surprised that common helpers are not Guile builtins, here for extracting keyword value. It would help Guile to provide such builtin, by default or via some ice-9 module. My 2 cents. ;-) ) Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 28 11:21:02 2023 Received: (at 67489) by debbugs.gnu.org; 28 Nov 2023 16:21:03 +0000 Received: from localhost ([127.0.0.1]:47504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80pa-0002fW-8C for submit@debbugs.gnu.org; Tue, 28 Nov 2023 11:21:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r80pX-0002ez-DH for 67489@debbugs.gnu.org; Tue, 28 Nov 2023 11:21:00 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r80pJ-0004UO-JG; Tue, 28 Nov 2023 11:20:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=WK0pKoz+z7WVw5L/8hOqocghKhSFMaxWeDv8VWhuY24=; b=bYzWBk21uRQyjEKGiK2v c14A5RSKQw0BfrBuzuTUKtBjKh0XA/CNnwSwhB1Qdpsn6HzifOcPs2swsQ2OuRwhIljEYFAs2I16c eKuFWnQk9r0DgQBAJsXOc7RiEv9hX2mucRCOjCUmuMPH+hyLn5pq1EqUZwIVHR6LZM/4K+OrFb1i5 zzsNTPKAWH4Mvu7b/U04IiTEu5FdYBcUjB3zb9TSP3kxsxtMBVUTspRkd+RIGlRCz/62mFdNCN2pD sv70W4ctta9ZuhJVgmdzA5xncmmGmTWefS1D+kPldWrXKKLZKkLC/nLNOYCoSNmH5K0OSHO9AKBPj IZEia+1oo07mwg==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Simon Tournier Subject: Re: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments. In-Reply-To: <87a5qycfuk.fsf@gmail.com> (Simon Tournier's message of "Tue, 28 Nov 2023 11:49:39 +0100") References: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> <87a5qycfuk.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Octidi 8 Frimaire an 232 de la =?utf-8?Q?R=C3=A9volu?= =?utf-8?Q?tion=2C?= jour du Miel X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 28 Nov 2023 17:20:42 +0100 Message-ID: <871qc9svc5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67489 Cc: Josselin Poiret , 67489@debbugs.gnu.org, Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello! Simon Tournier skribis: > TLDR: All LGTM. :-) Thanks. :-) > scheme@(guix-user)> ,pp (cdr (memq #:phases (package-arguments cava))) > $3 =3D (# "/lib")))) (add-after (quote install) (quote data) (lam= bda _ (for-each (lambda (file) (install-file file (string-append # "/share/doc/examples"))) (find-files "example_files"))))) gnu/pack= ages/audio.scm:5161:11 7f7258403a50>) > > > Without drifting, why not the meta-command ,arguments?=20 One can already do =E2=80=9C,pp (package-arguments package)=E2=80=9D, so I = wanted to have something short and to-the-point that would improve on that. In particular, we know by convention that certain arguments can be interpreted as code (gexps or sexps) so we can process them do display them in a nice way (lowering gexps, applying the pretty printer). We cannot necessarily do that for other arguments where there=E2=80=99s no established convention. These REPL commands are really tailored for packagers. > Here all is clear. What can be confusing is the expansion of #$output > as ((@ (guile) getenv) "out"). Maybe it could be worth to document this > under G-expression section. Or provide a similar example using > G-expression under the section G-expression. > > Well, that=E2=80=99s unrelated to this patch and could be done separately= . :-) Yeah, we could/should document the implementation of #$output. > Out of curiosity, what is the advantage for #:autoload versus > #:use-module + #:select? #:autoload allows modules to be loaded lazily, the first time one of the selected symbols is used. It=E2=80=99s a way to reduce startup time (equiv= alent to Emacs autoloads). >> +(define (keyword-argument-value args keyword default) >> + "Return the value associated with KEYWORD in ARGS, a keyword/value se= quence, >> +or DEFAULT if KEYWORD is missing from ARGS." >> + (let loop ((args args)) >> + (match args >> + (() >> + default) >> + ((kw value rest ...) >> + (if (eq? kw keyword) >> + value >> + (loop rest)))))) > > ( Aside. Each time, I am surprised that common helpers are not > Guile builtins, here for extracting keyword value. It would help > Guile to provide such builtin, by default or via some ice-9 > module. Yeah, I was disappointed too. :-) (ice-9 optargs) has helpers that weren=E2=80=99t a good match. Thanks for your feedback! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 28 11:39:52 2023 Received: (at 67489) by debbugs.gnu.org; 28 Nov 2023 16:39:52 +0000 Received: from localhost ([127.0.0.1]:47528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r817n-0003Mc-LD for submit@debbugs.gnu.org; Tue, 28 Nov 2023 11:39:51 -0500 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]:39071) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r817k-0003MA-5B for 67489@debbugs.gnu.org; Tue, 28 Nov 2023 11:39:50 -0500 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-58db15c68f3so31417eaf.0 for <67489@debbugs.gnu.org>; Tue, 28 Nov 2023 08:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701189575; x=1701794375; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DRxh88HGAUT7YaDaA09sO9TZkDKpzu2UgNy7KaSX614=; b=T/2A675vCNVGnOtnU/kXTYgeSCDrwpRlzsK22/HXzEWD1I0Lvy3l58oSl/f4v5ftFd H78Qs5a+sADSI+ZiNhMeL22UW9HV97DL3Z4MSYzZjQ8+Tv/o3yrvKjxJb7On9axBU70g DXlWKRocIjZ/9uo8Q+Osvb3j1bffdOvWv66Sd2cNS73yRcpx+F8GSmTy+27O5+GfiX31 NZehMI5vmcgo6ZQYRaigoUDWaCIKALuGo15aO5PG5w2BK8OB80xRxoVs+j3FupBPo/iF OFqvPWUSuSErcvp6KawIDYkoxUAgGcYXY1s6jCjhmfLBov1v7LZ6UTmGsJh+IGcAJ/4G Czeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189575; x=1701794375; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DRxh88HGAUT7YaDaA09sO9TZkDKpzu2UgNy7KaSX614=; b=sWu5+KEvUYtOP+1jntYEexnGNi1wz80D5rxGQ2LLcdIWLPC4FtXOgAn0ACfHQHTGVD XbgHtJqdmReYvKLywEsdmFsazi+PZx0gXcWPFUsUiG+J5l5uKeT5c8YSdcnofA+BkXFC rwSNWEhvbjS+o4Df8+EvC6BrCj5UXXrZgIoyH8/iAqWaT04Ls1nYtjGry1/Xuugy5Kzo fgykt++TFUlLCoYu8bjGghafUIFK26TmEN/kqLB1eNnnzo9eWAmEMS8mbkzxNXcTrVnC OopjNJ8fQe2TLzJnIDcvGsAijaQ23iUylW5/wc4qTJ/7i0vyGTA9y/9gAhKs83t+Qcww GO7Q== X-Gm-Message-State: AOJu0YzZsjl92CUfBFbtOnZ6SRDnWvnNnVGoJSTlfVn0vOms4pZgv4kw cY0fSCl4mMD5Sf5yaSBI35lubUqQfwe/VDL7hYs= X-Google-Smtp-Source: AGHT+IFJcZ0GD5eJKAdpiJzCkauBCZA9EEDVcI2TCsuapIAWn6S27W2AaaGrsTbbaAebzZM69CDV0SvzoCqpPr1qhsI= X-Received: by 2002:a05:6820:1e17:b0:58d:6870:68b9 with SMTP id dh23-20020a0568201e1700b0058d687068b9mr12282019oob.1.1701189575329; Tue, 28 Nov 2023 08:39:35 -0800 (PST) MIME-Version: 1.0 References: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> <87a5qycfuk.fsf@gmail.com> <871qc9svc5.fsf@gnu.org> In-Reply-To: <871qc9svc5.fsf@gnu.org> From: Simon Tournier Date: Tue, 28 Nov 2023 17:39:23 +0100 Message-ID: Subject: Re: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments. To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67489 Cc: Josselin Poiret , 67489@debbugs.gnu.org, Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Re, On Tue, 28 Nov 2023 at 17:20, Ludovic Court=C3=A8s wrote: > > Without drifting, why not the meta-command ,arguments? > > One can already do =E2=80=9C,pp (package-arguments package)=E2=80=9D, so = I wanted to > have something short and to-the-point that would improve on that. > > In particular, we know by convention that certain arguments can be > interpreted as code (gexps or sexps) so we can process them do display > them in a nice way (lowering gexps, applying the pretty printer). We > cannot necessarily do that for other arguments where there=E2=80=99s no > established convention. Unrelated to this patch series, maybe an opportunity for establishing some of these conventions, no? BTW, because this potential meta ,arguments targets package developer, I would find nice to apply what it is done with ,phases to 'package-arguments'. As I showed in my previous message, =E2=80=9C,pp (package-arguments package)=E2=80=9D is not really practical. Well, anyway= ... let as a exercise for the curious reader. ;-) Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 04 16:51:40 2023 Received: (at 67489-done) by debbugs.gnu.org; 4 Dec 2023 21:51:40 +0000 Received: from localhost ([127.0.0.1]:35948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAGqq-0006T1-0g for submit@debbugs.gnu.org; Mon, 04 Dec 2023 16:51:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAGqo-0006Sp-K6 for 67489-done@debbugs.gnu.org; Mon, 04 Dec 2023 16:51:39 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rAGqY-0007kv-6q; Mon, 04 Dec 2023 16:51:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=UVTjYdGxRj9JeXuOiLDypfI9aD0rZmthUpKHXXUJWG0=; b=o0NJxBF3vq0zGhpESNtk 4thMwHfawJyfpiOQL3C7To88EOpeuFZzfwWfJ9CLZG1bjBGMN9V0g2Nd8Fi7ZQ5CZEYbYUDeEwceT myAt10w5qTQWRUaxo6MfU42iaZTDNuBZ2TglHe5A1ByKY5HYx+M9aK7ls5HJOUYSsVlHB8eMrt34K k4zoeahzE5M4FauyqwgQvtaiZjrwT/3swc82llq3UcW8+AxhULCx4/QB53MQhNph25494P5wObNv9 FE17HpdVNiOL65IdCjj+kB8HD13oS9D2gItbkTbzcVKumnPeyFaIOdcvRdOkLVZ5Ue5Lpl5LRckBC Fhet5Lb+qXe/9w==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Simon Tournier Subject: Re: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments. In-Reply-To: <87a5qycfuk.fsf@gmail.com> (Simon Tournier's message of "Tue, 28 Nov 2023 11:49:39 +0100") References: <46b62be786928db845547a02f54d16b2635727f9.1701105272.git.ludo@gnu.org> <87a5qycfuk.fsf@gmail.com> Date: Mon, 04 Dec 2023 22:51:18 +0100 Message-ID: <87wmttljqh.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67489-done Cc: Josselin Poiret , Mathieu Othacehe , Tobias Geerinckx-Rice , 67489-done@debbugs.gnu.org, Ricardo Wurmus , Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Simon Tournier skribis: > TLDR: All LGTM. :-) Pushed as 3178b1a442c2f2eeeec1ff73bb852d2837b8aa3d! Ludo=E2=80=99. From unknown Sun Jun 22 11:34:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 02 Jan 2024 12:24:16 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator