summaryrefslogtreecommitdiff
path: root/guix/records.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/records.scm')
-rw-r--r--guix/records.scm16
1 files changed, 13 insertions, 3 deletions
diff --git a/guix/records.scm b/guix/records.scm
index 57664df5a6..8dc733b8ff 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -198,9 +198,19 @@ thunked fields."
#'((field options ...)
...))))))))))
-(define (alist->record alist make keys)
- "Apply MAKE to the values associated with KEYS in ALIST."
- (let ((args (map (cut assoc-ref alist <>) keys)))
+(define* (alist->record alist make keys
+ #:optional (multiple-value-keys '()))
+ "Apply MAKE to the values associated with KEYS in ALIST. Items in KEYS that
+are also in MULTIPLE-VALUE-KEYS are considered to occur possibly multiple
+times in ALIST, and thus their value is a list."
+ (let ((args (map (lambda (key)
+ (if (member key multiple-value-keys)
+ (filter-map (match-lambda
+ ((k . v)
+ (and (equal? k key) v)))
+ alist)
+ (assoc-ref alist key)))
+ keys)))
(apply make args)))
(define (object->fields object fields port)