Subject: [bug#61420] [PATCH 08/31] import: hackage: Use upstream-name property.

From: zimoun <[email-masked]>
Date: Wed, 15 Feb 2023 11:48:00 +0100

Hi,

On Sat, 11 Feb 2023 at 11:08, Lars-Dominik Braun <[email-masked]> wrote:
> * guix/import/hackage.scm (guix-package->hackage-name): Removed.
> (latest-release): Use package-upstream-name* instead.
> * guix/import/stackage.scm (latest-lts-release): Ditto.
> (stackage-lts-package?): Ditto.

> -(define guix-package->hackage-name
> -  (let ((uri-rx (make-regexp "(https?://hackage.haskell.org|mirror://hackage)/package/([^/]+)/.*"))
> -        (name-rx (make-regexp "(.*)-[0-9\\.]+")))
> -    (lambda (package)
> -      "Given a Guix package name, return the corresponding Hackage name."
> -      (let* ((source-url (and=> (package-source package) origin-uri))
> -             (name (match:substring (regexp-exec uri-rx source-url) 2)))
> -        (match (regexp-exec name-rx name)
> -          (#f name)
> -          (m (match:substring m 1)))))))

Why not just do a drop-in replacement of the implement of
’guix-package->hackage-name’ by the implementation of
’package-upstream-name*’?

Other said, avoid to introduce a new procedure and remove another; and
instead just replace the implementation of the old by the new.

> -  (let* ((hackage-name (guix-package->hackage-name package))
> +  (let* ((hackage-name (package-upstream-name* package))

It would avoid all these kind of replacement, no?

Cheers,
simon