unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Philip McGrath <philip@philipmcgrath.com>
Cc: 55030@debbugs.gnu.org
Subject: [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer.
Date: Sun, 01 May 2022 22:35:29 +0200	[thread overview]
Message-ID: <874k292dpq.fsf_-_@gnu.org> (raw)
In-Reply-To: <20220419233214.275789-3-philip@philipmcgrath.com> (Philip McGrath's message of "Tue, 19 Apr 2022 19:31:47 -0400")

Philip McGrath <philip@philipmcgrath.com> skribis:

> * gnu/packages/patches/elm-offline-package-registry.scm: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/elm.scm (elm): Use it.
> * guix/build-system/elm.scm, guix/build/elm-build-system.scm,
> guix/import/elm.scm, guix/scripts/import/elm.scm: New files.
> * guix/scripts/import.scm (importers): Add "elm".

I think the custom would be to add the importer in a separate commit; if
you can do that, that’s great.

Could you add an entry for the importer under “Invoking guix import”,
and one for the build system under “Build Systems” in guix.texi?  You
can follow existing entries as a template.

It would be nice to have tests for the importer.  One way to do that is
like ‘tests/cpan.scm’, which spawns an HTTP server that mimics the real
registry.

> +;; COMMENTARY:

Nitpick: You can make that literally “;;; Commentary:”.   That’s what
(ice-9 documentation) expects.

> +;; CODE:

Likewise: “;;; Code:”.

> +(define elm-package-registry
> +  ;; It is much nicer to fetch this small (< 40 KB gzipped)
> +  ;; file once than to do many HTTP requests.
> +  (mlambda ()
> +    "Fetch the Elm package registry, represented as a vhash mapping package
> +names to lists of available versions, sorted from latest to oldest."
> +    (let ((url "https://package.elm-lang.org/all-packages"))
> +      (cond
> +       ((json-fetch url)
> +        => (lambda (alist)
> +             (fold (lambda (entry vh)
> +                     (match entry
> +                       ((name . vec)
> +                        (vhash-cons name
> +                                    (sort (vector->list vec) version>?)
> +                                    vh))))
> +                   vlist-null
> +                   alist)))
> +       (else
> +        (raise (formatted-message
> +                (G_ "error downloading Elm package registry from ~a")
> +                url)))))))
> +
> +(define (make-elm-package-sexp name version)
> +  "Return two values: the `package' s-expression for the Elm package with the
> +given NAME and VERSION, and a list of Elm packages it depends on."
> +  (define-values (checkout _commit _relation)
> +    ;; Elm requires that packages use this very specific format
> +    (update-cached-checkout (string-append "https://github.com/" name)
> +                            #:ref `(tag . ,version)))
> +  (define info
> +    (call-with-input-file (string-append checkout "/elm.json")
> +      json->scm))
> +  (define (get-deps key)
> +    (cond
> +     ((assoc-ref info key)
> +      => (cut map car <>))
> +     (else
> +      '())))

The way the importer fiddles with alists isn’t pretty IMO.  :-)

How about using ‘define-json-mapping’ (also from Guile-JSON) to “map”
JSON data structures to records?  See how pypi.scm and others do it.
The resulting code should be clearer.

Also, instead of or in addition to memoizing ‘elm-package-registry’,
would it make sense to use ‘http-fetch/cached’ to fetch that file?

Nitpick: Guile has multiple-value truncation, so you can write:

  (define checkout
    (update-cached-checkout …))

I haven’t looked into much detail at the build system, but I’m sure you
know what you’re doing.  :-)

Ludo’.




  reply	other threads:[~2022-05-01 20:36 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 23:27 [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Philip McGrath
2022-04-19 23:31 ` [bug#55030] [PATCH 01/30] gnu: elm-compiler: Update to 0.19.1 Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 02/30] gnu: elm: Rename package to match the command Philip McGrath
2022-05-01 20:22     ` [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Ludovic Courtès
2022-05-01 21:27       ` Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 03/30] guix: Add elm-build-system and 'guix import elm' Philip McGrath
2022-05-01 20:35     ` Ludovic Courtès [this message]
2022-05-01 22:03       ` [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 04/30] gnu: Add elm-core and elm-json Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 05/30] build-system/elm: Add implicit Elm inputs Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 06/30] gnu: Add elm-virtual-dom Philip McGrath
2022-05-01 20:37     ` [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Ludovic Courtès
2022-05-01 22:17       ` Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 07/30] gnu: Add elm-html Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 08/30] gnu: Add elm-svg Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 09/30] gnu: Add elm-time Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 10/30] gnu: Add elm-url Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 11/30] gnu: Add elm-browser Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 12/30] gnu: Add elm-bytes Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 13/30] gnu: Add elm-file Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 14/30] gnu: Add elm-http Philip McGrath
2022-04-19 23:31   ` [bug#55030] [PATCH 15/30] gnu: Add elm-parser Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 16/30] gnu: Add elm-project-metadata-utils Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 17/30] gnu: Add elm-explorations-markdown Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 18/30] gnu: elm: Support 'elm reactor' Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 19/30] gnu: Add elm-todomvc Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 20/30] gnu: Add elm-debois-elm-dom Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 21/30] gnu: Add elm-random Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 22/30] gnu: Add elm-explorations-test Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 23/30] gnu: Add elm-danhandrea-elm-date-format Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 24/30] gnu: Add elm-danhandrea-elm-time-extra Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 25/30] gnu: Add elm-justinmimbs-date Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 26/30] gnu: Add elm-justinmimbs-time-extra Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 27/30] gnu: Add elm-myrho-elm-round Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 28/30] gnu: Add elm-ryannhg-date-format Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 29/30] gnu: Add elm-terezka-intervals Philip McGrath
2022-04-19 23:32   ` [bug#55030] [PATCH 30/30] gnu: Add elm-terezka-elm-charts Philip McGrath
2022-05-01 20:22 ` [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Ludovic Courtès
2022-05-01 20:41   ` Ludovic Courtès
2022-05-01 22:22     ` Philip McGrath
2022-05-01 21:26   ` Philip McGrath
2022-05-08 21:34     ` Ludovic Courtès
2022-05-18 18:10 ` [bug#55030] [PATCH v2 00/34] " Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 01/34] gnu: elm-compiler: Update to 0.19.1 Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 02/34] gnu: elm: Rename package to match the command Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 03/34] guix: Add elm-build-system Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 04/34] gnu: Add elm-core and elm-json Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 05/34] build-system/elm: Add implicit Elm inputs Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 06/34] http-client: Accept '#:headers' in 'http-fetched/cached' Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 07/34] http-client: 'http-fetch/cached' converts strings to URIs Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 08/34] import: json: Accept '#:http-fetch' in 'json-fetch' Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 09/34] import: Add Elm importer Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 10/34] gnu: Add elm-virtual-dom Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 11/34] gnu: Add elm-html Philip McGrath
2022-05-18 18:10   ` [bug#55030] [PATCH v2 12/34] gnu: Add elm-svg Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 13/34] gnu: Add elm-time Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 14/34] gnu: Add elm-url Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 15/34] gnu: Add elm-browser Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 16/34] gnu: Add elm-bytes Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 17/34] gnu: Add elm-file Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 18/34] gnu: Add elm-http Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 19/34] gnu: Add elm-parser Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 20/34] gnu: Add elm-project-metadata-utils Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 21/34] gnu: Add elm-explorations-markdown Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 22/34] gnu: elm: Support 'elm reactor' Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 23/34] gnu: Add elm-todomvc Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 24/34] gnu: Add elm-debois-elm-dom Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 25/34] gnu: Add elm-random Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 26/34] gnu: Add elm-explorations-test Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 27/34] gnu: Add elm-danhandrea-elm-date-format Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 28/34] gnu: Add elm-danhandrea-elm-time-extra Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 29/34] gnu: Add elm-justinmimbs-date Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 30/34] gnu: Add elm-justinmimbs-time-extra Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 31/34] gnu: Add elm-myrho-elm-round Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 32/34] gnu: Add elm-ryannhg-date-format Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 33/34] gnu: Add elm-terezka-intervals Philip McGrath
2022-05-18 18:11   ` [bug#55030] [PATCH v2 34/34] gnu: Add elm-terezka-elm-charts Philip McGrath
2022-05-21 23:45   ` bug#55030: [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874k292dpq.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=55030@debbugs.gnu.org \
    --cc=philip@philipmcgrath.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).