From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnhxr-0007F4-JM for guix-patches@gnu.org; Fri, 01 Sep 2017 05:10:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnhxi-0004Mw-6u for guix-patches@gnu.org; Fri, 01 Sep 2017 05:10:11 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:58619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnhxi-0004Mn-4j for guix-patches@gnu.org; Fri, 01 Sep 2017 05:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dnhxh-00050I-V1 for guix-patches@gnu.org; Fri, 01 Sep 2017 05:10:01 -0400 Subject: bug#28274: [PATCH] gnu: Add fold-packages-in-modules. Resent-To: guix-patches@gnu.org Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20170829070723.21727-1-mail@cbaines.net> <87r2vrrhzc.fsf@gnu.org> <20170831224433.07d6cea7@cbaines.net> Date: Fri, 01 Sep 2017 11:08:56 +0200 In-Reply-To: <20170831224433.07d6cea7@cbaines.net> (Christopher Baines's message of "Thu, 31 Aug 2017 22:44:33 +0100") Message-ID: <878thy7plj.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Christopher Baines Cc: 28274-done@debbugs.gnu.org Christopher Baines skribis: > On Thu, 31 Aug 2017 15:20:55 +0200 > ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > >> Instead of introducing a new procedure, what about simply: >>=20 >>=20 >> diff --git a/gnu/packages.scm b/gnu/packages.scm >> index 562906178..b4ac6661c 100644 >> --- a/gnu/packages.scm >> +++ b/gnu/packages.scm >> @@ -140,17 +140,19 @@ for system '~a'") >> directory)) >> %load-path))) >>=20=20 >> -(define (fold-packages proc init) >> - "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." >> +(define* (fold-packages proc init >> + #:optional >> + (modules (all-modules >> (%package-module-path)))) >> + "Call (PROC PACKAGE RESULT) for each available package defined in >> one of +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)) >>=20=20 >> (define find-packages-by-name >> (let ((packages (delay >>=20 >>=20 >> ? > > This looks great. Are you set to push it up, or shall I? Pushed, thanks! Ludo'.