From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SIZ7H/YDb2IBMAEAbAwnHQ (envelope-from ) for ; Mon, 02 May 2022 00:04:38 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cE+KH/YDb2JyoAAAauVa8A (envelope-from ) for ; Mon, 02 May 2022 00:04:38 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E72D012D6E for ; Mon, 2 May 2022 00:04:37 +0200 (CEST) Received: from localhost ([::1]:33654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlHgC-0001a8-LR for larch@yhetil.org; Sun, 01 May 2022 18:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlHff-0001Pw-2r for guix-patches@gnu.org; Sun, 01 May 2022 18:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlHfe-0004Jj-J8 for guix-patches@gnu.org; Sun, 01 May 2022 18:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlHfe-0007HU-Fa for guix-patches@gnu.org; Sun, 01 May 2022 18:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55030] [PATCH 00/30] gnu: elm: Update to 0.19.1. Add build system & importer. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 01 May 2022 22:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55030 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 55030@debbugs.gnu.org Received: via spool by 55030-submit@debbugs.gnu.org id=B55030.165144259127908 (code B ref 55030); Sun, 01 May 2022 22:04:02 +0000 Received: (at 55030) by debbugs.gnu.org; 1 May 2022 22:03:11 +0000 Received: from localhost ([127.0.0.1]:34412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlHep-0007G4-FV for submit@debbugs.gnu.org; Sun, 01 May 2022 18:03:11 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:50729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlHen-0007Fl-HV for 55030@debbugs.gnu.org; Sun, 01 May 2022 18:03:10 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4B0605C0042; Sun, 1 May 2022 18:03:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 01 May 2022 18:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1651442584; x=1651528984; bh=kw5OlER3cX EFPrl5DCWLfsMzPkfBXOsYAyI6YM6ItKQ=; b=XautkdnjFbjyRFc5T6I6uYT0gK VPW9G7tzxPZ8twzCQdpYRUGZc0noNTyDSG4olcNyx6lVnY3e+BcHL2YopY39Ey2e LVcYBQ7p+P9wmmYEw41eTgoWTWLMxOOnAxAQy1ykeWwSf+aJgaJRSi7F1v6IrMpy rVnSh+II86Ih4hLKmd8Meo4u2gzd2jWfA5ytfpnzAXcMkZc+njwvTCwiGFZjsZrR QWSDAR0lWHU+IaC6/AKGfMunsqsBT+V7yFS7jzXo5XplV1EXfzKBm7BD9XG4St1U I5OZEfdkZ7VivZ/FEvOQwARwSIETSFDlqDIm+Vebi/4T0Npg0duysX8hq2zQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1651442584; x=1651528984; bh=kw5OlER3cXEFP rl5DCWLfsMzPkfBXOsYAyI6YM6ItKQ=; b=fRM3lSzSRulqmuhw4hsvyFIPV0oiB +dMFMVwMIx0wuLIp15lx4RT3En4Py93HeAcL66VqYZUFtgjlA2/IX4uebwRCe2cC qwR9ZRxPCkjoITsmO7RWndNlR3Ei7VZ8+QmdkdNiEQVlhk1kxUmCxb8YcgJGHyOY EC6Sz3tgLJN5cGCFTuuJkI3HlGYbIg0NWvREH5kE/r41TnEqWNlmApHoOptZFoS1 t0LjA569300SgIPNRrOCMBubLMRacFQ2C8CM6BhyOBs3KtuVSPg59YR/YOiDO1Uj FJI30w9o+sTgZQWDW03Qy2SK8FThQ3olHjuetz8nRzE4YBRxoa7UY/I4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeggddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomheprfhhihhl ihhpucfotgfirhgrthhhuceophhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrdgtoh hmqeenucggtffrrghtthgvrhhnpeehueekvdfgtdejhfeifffhfefhheejtddvvdetkeev ffehvdetkeeggfefleejueenucffohhmrghinhepvghlmhdqlhgrnhhgrdhorhhgpdhgih hthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehphhhilhhiphesphhhihhlihhpmhgtghhrrghthhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 1 May 2022 18:03:03 -0400 (EDT) Message-ID: <1cf62d38-77f7-b50c-6137-a345a255826c@philipmcgrath.com> Date: Sun, 1 May 2022 18:03:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US References: <20220419232736.272970-1-philip@philipmcgrath.com> <20220419233214.275789-1-philip@philipmcgrath.com> <20220419233214.275789-3-philip@philipmcgrath.com> <874k292dpq.fsf_-_@gnu.org> From: Philip McGrath In-Reply-To: <874k292dpq.fsf_-_@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651442678; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=kw5OlER3cXEFPrl5DCWLfsMzPkfBXOsYAyI6YM6ItKQ=; b=rtbmkf6Bro2PVGPzYwdIrQFpqL2n21rXxXzZsvWCYbllrGU38WbsJMxazgdapbzQK8tDWC oPhoLUmW7Ap9oI2eivtjpxk2LiLCXbyv8nWPBw6Pcr2BEpt/BYl74H2PQAnkrGoI/8MnSd XpsRpmaNz5bJrUhKwt/KZn8msRPLMi/I85Pzl9EFCaA3PWhqd4tMbGHckC9bPEBXI6grih LqbaFMWaIWqKA7GvVkarQi/3ZKwjk6F438ljxoBs8dJZsbs+OE+EH6NpRJNRZ9qhvGtJws E4HYJ2YdXz7RV/+39zd7BMM/qJFqZDIT6vka8E7wFXSA01qgRJwXpRMx/UMQ0A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651442678; a=rsa-sha256; cv=none; b=Yt4SZMi/7ciwlMmOiwp2JsLER9IAcKeR0TDo7oLNZ65Tet0hqwSUMzu5/Q5UAAaeAGvu0E htvWhgWP26CMQdpzPTQtMSMji6H7PDPcBALXnD/5WqlO4Xk7ErKUvhddMnfRKgY4Yx/f+3 RpCHSSt0lpZtw2sOzPcGLcMGUE0rzmvrx0AxalIlDKEU8IZjXj8vy+C5IWmvEgXggh+QLM tACdhlRAJKCiY13geekeCw0tAPHpBYgnIB9tBor4dV3X+upswzWArNYPdItnCf+S2JC+h6 3epPhMgmKiH6s+u6zscYdiny89eBxbAL/DwC+Lj07OFlqC7Q6mk+6f8SGUdwjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm1 header.b=Xautkdnj; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm1 header.b=fRM3lSzS; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.91 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm1 header.b=Xautkdnj; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm1 header.b=fRM3lSzS; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E72D012D6E X-Spam-Score: 0.91 X-Migadu-Scanner: scn1.migadu.com X-TUID: UV2WsCG2Uidu Hi, On 5/1/22 16:35, Ludovic Courtès wrote: > Philip McGrath 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. > I certainly can split it that way. I did it like this because I actually wrote the importer before the build system. > 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. > 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. >> +;; COMMENTARY: > > Nitpick: You can make that literally “;;; Commentary:”. That’s what > (ice-9 documentation) expects. > >> +;; CODE: > > Likewise: “;;; Code:”. > Will do. >> +(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. > 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! > 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! > Nitpick: Guile has multiple-value truncation, so you can write: > > (define checkout > (update-cached-checkout …)) > I saw that some places in Guix relied on that already, but I also saw that `info guile values` says that: > The effect of passing no > value or more than one value to continuations that were not created > by ‘call-with-values’ is unspecified. ... so I wasn't sure what to do. -Philip