GNU bug report logs - #70923
[PATCH 00/13] Add (guix import utils) procedures.

Previous Next

Package: guix-patches;

Reported by: Herman Rimm <herman <at> rimm.ee>

Date: Mon, 13 May 2024 20:00:02 UTC

Severity: normal

Tags: patch

Full log


Message #104 received at 70923 <at> debbugs.gnu.org (full text, mbox):

From: Herman Rimm <herman <at> rimm.ee>
To: 70923 <at> debbugs.gnu.org
Subject: [PATCH v3 08/11] import: cran: Use 'maybe-list-field' procedure.
Date: Tue, 24 Sep 2024 22:13:14 +0200
* guix/import/cran.scm (format-inputs): Delete procedure.
(maybe-inputs): Use 'maybe-list-field' procedure.

Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
 guix/import/cran.scm | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 6ae00cae96..bdac059053 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2022 Hartmut Goebel <h.goebel <at> crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman <at> rimm.ee>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -85,21 +86,6 @@ (define-module (guix import cran)
 (define %input-style
   (make-parameter 'variable)) ; or 'specification
 
-(define (format-inputs inputs)
-  "Generate a sorted list of package inputs from a list of upstream inputs."
-  (map (lambda (input)
-         (case (%input-style)
-           ((specification)
-            `(specification->package ,(upstream-input-downstream-name input)))
-           (else
-            ((compose string->symbol
-                       upstream-input-downstream-name)
-             input))))
-       (sort inputs
-             (lambda (a b)
-               (string-ci<? (upstream-input-name a)
-                            (upstream-input-name b))))))
-
 (define (string->licenses license-string license-prefix)
   (let ((licenses
          (map string-trim-both
@@ -188,11 +174,21 @@ (define (description->alist description)
 (define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
   "Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
 package definition."
-  (match package-inputs
-    (()
-     '())
-    ((package-inputs ...)
-     `((,input-type (list ,@(format-inputs package-inputs)))))))
+  (define (format-input input)
+    (case (%input-style)
+      ((specification)
+       `(specification->package ,(upstream-input-downstream-name input)))
+      (else
+       ((compose string->symbol
+                  upstream-input-downstream-name)
+        input))))
+
+  (define (upstream-input-name<? i1 i2)
+    (string-ci<? (upstream-input-name i1)
+                 (upstream-input-name i2)))
+
+  (maybe-list-field input-type
+    (map format-input (sort package-inputs upstream-input-name<?))))
 
 (define %cran-url "https://cloud.r-project.org/web/packages/")
 (define %cran-canonical-url "https://cran.r-project.org/package=")
-- 
2.45.2





This bug report was last modified 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.