From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmad4-0001uz-OF for guix-patches@gnu.org; Tue, 29 Aug 2017 03:08:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmad0-0006RA-Rx for guix-patches@gnu.org; Tue, 29 Aug 2017 03:08:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:51387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmad0-0006Qv-OC for guix-patches@gnu.org; Tue, 29 Aug 2017 03:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dmad0-0003Iv-GC for guix-patches@gnu.org; Tue, 29 Aug 2017 03:08:02 -0400 Subject: [bug#28274] [PATCH] gnu: Add fold-packages-in-modules. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmacS-0001tJ-Hj for guix-patches@gnu.org; Tue, 29 Aug 2017 03:07:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmacP-00066o-Cz for guix-patches@gnu.org; Tue, 29 Aug 2017 03:07:28 -0400 Received: from li622-129.members.linode.com ([212.71.249.129]:39461 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmacP-00066L-7I for guix-patches@gnu.org; Tue, 29 Aug 2017 03:07:25 -0400 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id AECCF13D261 for ; Tue, 29 Aug 2017 08:07:23 +0100 (BST) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 45ffff0a for ; Tue, 29 Aug 2017 07:07:23 +0000 (UTC) From: Christopher Baines Date: Tue, 29 Aug 2017 08:07:23 +0100 Message-Id: <20170829070723.21727-1-mail@cbaines.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 28274@debbugs.gnu.org Add a more flexible variant of the fold-packages procedure, that takes a list of the modules to work with. The existing fold-packages procedure then calls fold-packages-in-modules with the result of the all-modules procedure. I wrote this when looking at how to get the packages in a specific set of modules, to create jobs for cuirass. * gnu/packages.scm (fold-packages-in-modules): New procedure. (fold-packages): Change to use fold-packages-in-modules. --- gnu/packages.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index 562906178..3f0ff56b8 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -47,6 +47,7 @@ %bootstrap-binaries-path %package-module-path + fold-packages-in-modules fold-packages find-packages-by-name @@ -144,13 +145,21 @@ for system '~a'") "Call (PROC PACKAGE RESULT) for each available package, using INIT as the initial value of RESULT. It is guaranteed to never traverse the same package twice." + (fold-packages-in-modules (all-modules (%package-module-path)) + proc + init)) + +(define (fold-packages-in-modules modules proc init) + "Call (PROC PACKAGE RESULT) for each available package within any of the +modules in MODULES, using INIT as the initial value of RESULT. It is +guaranteed to never traverse the same package twice." (fold-module-public-variables (lambda (object result) (if (and (package? object) (not (hidden-package? object))) (proc object result) result)) init - (all-modules (%package-module-path)))) + modules)) (define find-packages-by-name (let ((packages (delay -- 2.14.1