GNU bug report logs -
#28274
[PATCH] gnu: Add fold-packages-in-modules.
Previous Next
Reported by: Christopher Baines <mail <at> cbaines.net>
Date: Tue, 29 Aug 2017 07:08:02 UTC
Severity: normal
Tags: patch
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Christopher Baines <mail <at> cbaines.net> skribis:
> 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.
[...]
> +(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))
Instead of introducing a new procedure, what about simply:
[Message part 2 (text/x-patch, inline)]
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)))
-(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))
(define find-packages-by-name
(let ((packages (delay
[Message part 3 (text/plain, inline)]
?
Ludo’.
This bug report was last modified 7 years and 348 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.