From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:53419) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVib-0005lc-Fd for guix-patches@gnu.org; Thu, 13 Jun 2019 15:49:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbVap-0006Ag-An for guix-patches@gnu.org; Thu, 13 Jun 2019 15:41:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbVap-0006AX-78 for guix-patches@gnu.org; Thu, 13 Jun 2019 15:41:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hbVap-0005ZE-2w for guix-patches@gnu.org; Thu, 13 Jun 2019 15:41:03 -0400 Subject: [bug#36048] [PATCH] guix: import: hackage: handle hackage revisions Resent-Message-ID: Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) From: Robert Vollmert In-Reply-To: <87lfy59x2x.fsf@ngyro.com> Date: Thu, 13 Jun 2019 21:40:15 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <635BD0E2-BADE-4385-8A4C-A3AE36A392BC@vllmrt.net> References: <20190601223636.74362-1-rob@vllmrt.net> <87sgse43sc.fsf@ngyro.com> <87lfy59x2x.fsf@ngyro.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Timothy Sample Cc: 36048@debbugs.gnu.org > On 13. Jun 2019, at 20:09, Timothy Sample wrote: >=20 > Hi Robert, >=20 > Robert Vollmert writes: >=20 >> Hi Timothy, >>=20 >> thanks for the detailed feedback, this is very helpful! >=20 > You=E2=80=99re welcome! >=20 >> I=E2=80=99ve sent an updated patch addressing some of the concerns, = but have >> some questions regarding others. (I just realized that the = documentation >> updates probably anticipate multiple return values.) >=20 > Yes. >=20 >>> On 13. Jun 2019, at 04:28, Timothy Sample wrote: >>>> + (let-values (((port get-hash) (open-sha256-input-port port))) >>=20 >>>> + (cons >>>> + (read-cabal (canonical-newline-port port)) >>>> + (bytevector->nix-base32-string (get-hash))))) >>=20 >> [=E2=80=A6] >>=20 >>> Also, I think returning multiple values would be more natural here >>> (i.e., replace =E2=80=9Ccons=E2=80=9D with =E2=80=9Cvalues=E2=80=9D). >>=20 >> I tried building it that way to begin with, but I=E2=80=99m having = issues >> making it work (nicely, or maybe at all). I think it comes down to >> later functions optionally failing with a single #f-value. Judging >> by the lack of infrastructure, I imagine functions that return = different >> numbers of values are not idiomatic scheme. Should this be changed to >> return two values (#f #f) on failure? Or to raise an exception and >> handle it higher up when we want to ignore a failure? >>=20 >> Currently, implementing this with values/let-values results in me >> doing more or less a combination of let-values and match, at which >> point it seems that any potential benefits of using multiple values >> as opposed to a pair/list are lost. (There=E2=80=99s no match-values = form is >> there?) >=20 > I=E2=80=99m not sure I understand the problem. Here=E2=80=99s what I = had in mind: >=20 > diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm > index 2853037797..9ba3c4b58e 100644 > --- a/guix/import/hackage.scm > +++ b/guix/import/hackage.scm > @@ -120,8 +120,8 @@ version is returned." > (define (read-cabal-and-hash port) > "Read a cabal file and its base32 hash from a port." > (let-values (((port get-hash) (open-sha256-input-port port))) > - (cons (read-cabal (canonical-newline-port port)) > - (bytevector->nix-base32-string (get-hash))))) > + (values (read-cabal (canonical-newline-port port)) > + (bytevector->nix-base32-string (get-hash))))) >=20 > (define (hackage-fetch-and-hash name-version) > "Return the Cabal file and hash for the package NAME-VERSION, or #f = on > @@ -129,7 +129,7 @@ failure. If the version part is omitted from the = package name, then return > the latest version." > (guard (c ((and (http-get-error? c) > (=3D 404 (http-get-error-code c))) > - #f)) ;"expected" if package is = unknown > + (values #f #f))) ;"expected" if package is = unknown This is the point: I tried to keep returning a single #f to signal = failure. I sent an updated patch, let me know if I missed something. Thanks! Robert