From debbugs-submit-bounces@debbugs.gnu.org Wed May 18 14:12:03 2022 Received: (at 55030) by debbugs.gnu.org; 18 May 2022 18:12:03 +0000 Received: from localhost ([127.0.0.1]:33466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9S-0006Ga-CY for submit@debbugs.gnu.org; Wed, 18 May 2022 14:12:03 -0400 Received: from mail-ua1-f43.google.com ([209.85.222.43]:44729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9Q-0006G2-Db for 55030@debbugs.gnu.org; Wed, 18 May 2022 14:12:01 -0400 Received: by mail-ua1-f43.google.com with SMTP id f13so1126741uax.11 for <55030@debbugs.gnu.org>; Wed, 18 May 2022 11:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VZ5KiVXTpQ91/A3OpXqSqY0BKZJz7GNFRsVHBT4anMA=; b=bkRrqfZu/Et+NfqkMBaRHe5azPmsA9ZQzXInGe8xbKZvNl7F7KpcVgc0sr0M+7V6OQ 0/we6YlPeM6qL/CxxswNvTTCKdJz0c6/PVQZ37rN7Q2qXNONpjNq85NRw/eDaZkNxPTA HuVm6Db6nrH6iAlngccwocE3TMliIgC5qs34sn/xhWYGclFA5VMbd6S6tHLyMxyNxaB0 hOEIxJNQQMUWeimNUdigtei8gUWqKo1rI7IfuSpbVUKrb1ThJ1WnHVqzQjGcu8xV+Wy2 t4MlRwDWuTQCe+jY45T5uYvq9AKfSvMzzVFS3PGXRVGqh4nYRalubDNwOY2fjuoIWCg/ OzeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VZ5KiVXTpQ91/A3OpXqSqY0BKZJz7GNFRsVHBT4anMA=; b=mRbMN5DcQDaVvpmRi0FHzJOc0FIm3ZJLF7bXp3pu4wQaKNbG+ISyVr4pYMSM8vmROc 8TNoOCXMSEtVp15BzKT0FgLA0vEr1JmamceQhVxOVHhfGRa/6xWjdB2/E/aVx090+nh5 ePab7fKd2WFmw0OwC081PZZM+WlHciWvaz9dfSquKKp5ouuy3ERBdUBGrq4dFRdVu/E0 uA8XOyQJqRR3v6jbbdl36TMqVQh8dCj/Xgb8h1aXJvLhERxH822IfZ9bIRf1PMaTlo9x 9AYX8f+ey0/CTZ72T1mirO/t64euvFVLURcO3T7WN8eSlkucIBWMGrOM8+gcLxp5a1Ty +ciA== X-Gm-Message-State: AOAM531eZdn2P4T6fUaF76Rpv8XFF164e0+Q11RQcU4ZGmo2PH+bo4vL 2NB3yzOZcGnhLl1vyLJhPBRGDbQRT4ujWOHW X-Google-Smtp-Source: ABdhPJwDGEHf+ODzmfGDtexnJtaJSw1eP2KLSzf8KjpKyrtflx6XAJ/GY8LwOEIsgkxJAs+lP2qEHA== X-Received: by 2002:ab0:72d5:0:b0:368:aad4:5ef8 with SMTP id g21-20020ab072d5000000b00368aad45ef8mr560858uap.27.1652897514356; Wed, 18 May 2022 11:11:54 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id b3-20020a05610222e300b00335bc2b4042sm254885vsh.28.2022.05.18.11.11.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 11:11:54 -0700 (PDT) From: Philip McGrath To: 55030@debbugs.gnu.org Subject: [PATCH v2 00/34] gnu: elm: Update to 0.19.1. Add build system & importer. Date: Wed, 18 May 2022 14:10:47 -0400 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220419232736.272970-1-philip@philipmcgrath.com> References: <20220419232736.272970-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: 55030 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Philip McGrath X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) Hi, Here is v2! A few notes before the patches: On 5/1/22 18:17, Philip McGrath wrote: > Hi, > > On 5/1/22 16:37, Ludovic Courtès wrote: >> Philip McGrath skribis: >> >>> + (package >>> + (name "elm-virtual-dom") >> >> [...] >> >>> + (properties '((upstream-name . "elm/virtual-dom"))))) >> >> Could/should the importer infer the upstream name from the Guix name by >> default? >> >> That way, we’d only need to specify that property where the automatic >> Guix->upstream name mapping wouldn’t work. > > It could, but the heuristics seemed a bit brittle. To pick a few examples: > > 1. elm-virtual-dom -> "elm/virtual-dom" > 2. elm-explorations-markdown -> "elm-explorations/markdown" > 2. elm-terezka-intervals -> "terezka/intervals" > > We could add a special case for the "elm-explorations/*" namespace, but > at least one of the others would need an explicit property. I *think* > most of the packages in the "elm/*" namespace are single-element (e.g. > "elm/html"), so maybe we could require the property for e.g. > "elm/virtual-dom" and "elm/project-metadata-utils" ... > I think I've come up with an approach to inferring upstream names that handles most cases (everything in this series but "elm/virtual-dom" and "elm/project-metadata-utils") while also not adding so much magic that the behavior would be unpredictable. I've put the functions going in both directions in `(guix build-system elm)` rather than `(guix import elm)` (which seemed somewhat more common) because `elm-package-origin` needs `elm->package-name`, and it seemed better overall to define the Elm-to-Guix and Guix-to-Elm conversions in the same place. On 5/1/22 18:03, Philip McGrath wrote: > Hi, > > On 5/1/22 16:35, Ludovic Courtès wrote: >> 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. >> > > I will give it a try! I haven't written any Texinfo before. > I've added documentation there, and also a section on naming conventions in contributing.texi. I'm not sure all of my Texinfo is idiomatic (well, I didn't find equivalents for all of the Scribble cross-reference functions I'm used to), but it does build and work ok. >> 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. >> > > I'll take a look at that. > I've added a number of tests. They seem to be producing more "PASS" lines than other tests, though. It seems like nested `test-group`s may be handled differently than I'm used to from RackUnit and (less so) Racket's `srfi/64` implementation, but I'm not sure what the idiomatic way to structure them would be, if this isn't it. >>> +;; COMMENTARY: >> >> Nitpick: You can make that literally “;;; Commentary:”. That’s what >> (ice-9 documentation) expects. >> >>> +;; CODE: >> >> Likewise: “;;; Code:”. >> > > Will do. > Ironically, I couldn't find any documentation for `(ice-9 documentation)` other than the comments in the source file, but I hope I've done this properly now. >> >> 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. >> > > I had tried that first, but there were some problems: IIRC, there might > have been an issue with potentially-absent fields defaulting to > *unspecified*, some alist manipulation was needed anyway for fields that > use JSON objects as key--value maps, and, with a view toward being able > to process `{"type":"application"}` files some day, there didn't seem to > be enough ability to adapt parsing based on the value for the key. I > found this code less confusing. But I can try again if it seems important! > Most of the problems I'd run into were because I'd gotten the wrong idea from the grammar of 'define-json-mapping`, and `define-json-mapping` didn't check its implicit requirements: I've reported the details and potential improvements at . The remaining, unescapable alist manipulation is for cases when JSON objects are used as key--value maps, rather than records with some finite set of potential keys. >> Also, instead of or in addition to memoizing ‘elm-package-registry’, >> would it make sense to use ‘http-fetch/cached’ to fetch that file? >> > > I'll take a look! > Using `http-fetch/cached` without duplicating `json-fetch` required a few additional patches: - [PATCH v2 06/34] http-client: Accept '#:headers' in 'http-fetched/cached'. - [PATCH v2 07/34] http-client: 'http-fetch/cached' converts strings to URIs. - [PATCH v2 08/34] import: json: Accept '#:http-fetch' in 'json-fetch'. They seemed small enough, and IIUC they don't affect any build-side code or trigger rebuilds, but OTOH the actuall JSON being fetched is quite small, so it wouldn't be a problem to drop them if there are any problems. One other difference is that `elm-virtual-dom` had an upstream release since the first version of this patch series, so that package is now at 1.0.3. -Philip Philip McGrath (34): gnu: elm-compiler: Update to 0.19.1. gnu: elm: Rename package to match the command. guix: Add elm-build-system. gnu: Add elm-core and elm-json. build-system/elm: Add implicit Elm inputs. http-client: Accept '#:headers' in 'http-fetched/cached'. http-client: 'http-fetch/cached' converts strings to URIs. import: json: Accept '#:http-fetch' in 'json-fetch'. import: Add Elm importer. gnu: Add elm-virtual-dom. gnu: Add elm-html. gnu: Add elm-svg. gnu: Add elm-time. gnu: Add elm-url. gnu: Add elm-browser. gnu: Add elm-bytes. gnu: Add elm-file. gnu: Add elm-http. gnu: Add elm-parser. gnu: Add elm-project-metadata-utils. gnu: Add elm-explorations-markdown. gnu: elm: Support 'elm reactor'. gnu: Add elm-todomvc. gnu: Add elm-debois-elm-dom. gnu: Add elm-random. gnu: Add elm-explorations-test. gnu: Add elm-danhandrea-elm-date-format. gnu: Add elm-danhandrea-elm-time-extra. gnu: Add elm-justinmimbs-date. gnu: Add elm-justinmimbs-time-extra. gnu: Add elm-myrho-elm-round. gnu: Add elm-ryannhg-date-format. gnu: Add elm-terezka-intervals. gnu: Add elm-terezka-elm-charts. Makefile.am | 5 + doc/contributing.texi | 82 ++ doc/guix.texi | 80 ++ gnu/local.mk | 4 +- gnu/packages/elm.scm | 749 +++++++++++++++++- .../elm-compiler-disable-reactor.patch | 71 -- .../patches/elm-compiler-fix-map-key.patch | 38 - .../elm-offline-package-registry.patch | 71 ++ .../patches/elm-reactor-static-files.patch | 251 ++++++ guix/build-system/elm.scm | 206 +++++ guix/build/elm-build-system.scm | 380 +++++++++ guix/http-client.scm | 24 +- guix/import/elm.scm | 210 +++++ guix/import/json.scm | 9 +- guix/scripts/import.scm | 3 +- guix/scripts/import/elm.scm | 107 +++ tests/elm.scm | 268 +++++++ 17 files changed, 2414 insertions(+), 144 deletions(-) delete mode 100644 gnu/packages/patches/elm-compiler-disable-reactor.patch delete mode 100644 gnu/packages/patches/elm-compiler-fix-map-key.patch create mode 100644 gnu/packages/patches/elm-offline-package-registry.patch create mode 100644 gnu/packages/patches/elm-reactor-static-files.patch create mode 100644 guix/build-system/elm.scm create mode 100644 guix/build/elm-build-system.scm create mode 100644 guix/import/elm.scm create mode 100644 guix/scripts/import/elm.scm create mode 100644 tests/elm.scm base-commit: 665dd8211cb5c7556f0fb83944d33215accf957a -- 2.32.0