guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add


From: Timothy Sample
Subject: [bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp.
Date: Sun, 28 Nov 2021 14:27:56 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi Philip,

Philip McGrath <philip@philipmcgrath.com> writes:

> -  (define (resolve-dependencies package-meta meta-key)
> -    (fold (lambda (key+value acc)
> -            (match key+value
> -              ('@ acc)
> -              ((key . value) (acons key (hash-ref index key value) acc))))
> +  (define (resolve-dependencies meta-alist meta-key)
> +    (match (assoc-ref meta-alist meta-key)
> +      (#f
> +       '())
> +      (('@ . orig-deps)
> +       (fold (match-lambda*
> +               (('@ acc)
> +                acc)
> +                (((key . value) acc)
> +                 (if (member key absent-dependencies)
> +                     acc
> +                     (acons key (hash-ref index key value) acc))))
>            '()
> -          (or (assoc-ref package-meta meta-key) '())))
> +          orig-deps))))

There’s a lot of refactoring going here in addition to change at hand.
To me, it needlessly obscures the actual change (which is just the check
for membership in 'absent-dependencies', AFAICS).

>    (with-atomic-file-replacement "package.json"
>      (lambda (in out)
> -      (let ((package-meta (read-json in)))
> -        (assoc-set! package-meta "dependencies"
> -                    (append
> -                     '(@)
> -                     (resolve-dependencies package-meta "dependencies")
> -                     (resolve-dependencies package-meta "peerDependencies")))
> -        (assoc-set! package-meta "devDependencies"
> -                    (append
> -                     '(@)
> -                     (resolve-dependencies package-meta "devDependencies")))
> +      ;; It is unsafe to rely on 'assoc-set!' to update an
> +      ;; existing assosciation list variable:
> +      ;; see 'info "(guile)Adding or Setting Alist Entries"'.

Good catch!

> +      (let* ((package-meta (read-json in))
> +             (alist (match package-meta
> +                      ((@ . alist) alist)))

Why do we have to unwrap (and then re-wrap later on) the alist?  It
would be nice to explain that in the changelog.  Maybe it’s just me, but
I can’t figure it out!  :)

Thanks!


-- Tim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]