From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxim Cournoyer Subject: bug#24450: [PATCHv2] Re: pypi importer outputs strange character series in optional dependency case. Date: Sun, 16 Jun 2019 23:29:58 +0900 Message-ID: <87o92x1u3d.fsf@gmail.com> References: <87imtb33tp.fsf@gmail.com> <87imtb9ujz.fsf@mdc-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:36980) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcWBU-0006et-T9 for bug-guix@gnu.org; Sun, 16 Jun 2019 10:31:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcWBS-0003xS-VW for bug-guix@gnu.org; Sun, 16 Jun 2019 10:31:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hcWBR-0003wW-SG for bug-guix@gnu.org; Sun, 16 Jun 2019 10:31:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hcWBR-0000Tn-OM for bug-guix@gnu.org; Sun, 16 Jun 2019 10:31:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87imtb9ujz.fsf@mdc-berlin.de> (Ricardo Wurmus's message of "Wed, 12 Jun 2019 08:39:12 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ricardo Wurmus Cc: 24450@debbugs.gnu.org Hey Ricardo :-) Ricardo Wurmus writes: > Hi Maxim, > >>>> (call-with-input-file requires.txt >>>> (lambda (port) >>>> - (let loop ((result '())) >>>> + (let loop ((required-deps '()) >>>> + (test-deps '()) >>>> + (inside-test-section? #f) >>>> + (optional? #f)) >>>> (let ((line (read-line port))) >>>> - ;; Stop when a section is encountered, as sections contains= optional >>>> - ;; (extra) requirements. Non-optional requirements must ap= pear >>>> - ;; before any section is defined. >>>> - (if (or (eof-object? line) (section-header? line)) >>>> + (if (eof-object? line) >>>> ;; Duplicates can occur, since the same requirement can= be >>>> ;; listed multiple times with different conditional mar= kers, e.g. >>>> ;; pytest >=3D 3 ; python_version >=3D "3.3" >>>> ;; pytest < 3 ; python_version < "3.3" >>>> - (reverse (delete-duplicates result)) >>>> + (map (compose reverse delete-duplicates) >>>> + (list required-deps test-deps)) >>> >>> Looks like a list of lists to me. =E2=80=9Cdelete-duplicates=E2=80=9D = now won=E2=80=99t delete >>> a name that is in both =E2=80=9Crequired-deps=E2=80=9D as well as in = =E2=80=9Ctest-deps=E2=80=9D. Is >>> this acceptable? >> >> It is acceptable, as this corner case cannot exist given the current >> code (a requirement can exist in either required-deps or test-deps, but >> never in both). It also doesn't make sense that a run time requirement >> would also be listed as a test requirement, so that corner case is not >> likely to exist in the future either. > > I mentioned it because I believe I=E2=80=99ve seen this in the past where= the > importer would return some of the same inputs as both regular inputs and > test dependencies. OK! >>> Personally, I=E2=80=99m not a fan of using data structures for returning >>> multiple values, because we can simply return multiple values. >> >> I thought the Guile supported multiple values return value would be >> great here as well, but I've found that for this specific case here, a >> list of lists worked better, since the two lists contain requirements to >> be processed the same, which "map" can readily do (i.e. less ceremony is >> required). > > =E2=80=9Cmap=E2=80=9D can also operate on more than one list at a time: > > (call-with-values > (lambda () > (values (list 1 2 3) > (list 9 8 7))) > (lambda (a b) (map + a b))) > > =3D> (10 10 10) That's what I meant by "requires more ceremony". I can simply apply "map" to the return value of the function and get what I need, rather than having to use "values" in the callee, then "call-with-values" in the caller and establish a binding for each list. =20=20 > Of course, it would be simpler to just use a single list of tagged > items. Do you feel strongly about it? I don't; I'm open to try to use a tagged list if you feel this is worth it. Maxim