From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWsO-0006vB-3F for guix-patches@gnu.org; Thu, 28 Sep 2017 07:21:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWsI-0001bx-UW for guix-patches@gnu.org; Thu, 28 Sep 2017 07:21:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:55529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxWsI-0001bp-RV for guix-patches@gnu.org; Thu, 28 Sep 2017 07:21:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dxWsI-0000di-Kl for guix-patches@gnu.org; Thu, 28 Sep 2017 07:21:02 -0400 Subject: bug#28251: [PATCH 1/3] packages: Add package->code. Resent-To: guix-patches@gnu.org Resent-Message-ID: References: <20170827155820.28812-1-rekado@elephly.net> <20170827160046.29049-1-rekado@elephly.net> <87ziae4dn4.fsf@gnu.org> From: Ricardo Wurmus In-reply-to: <87ziae4dn4.fsf@gnu.org> Date: Thu, 28 Sep 2017 13:19:21 +0200 Message-ID: <1425051478.20370.1506597564740.JavaMail.sas@[172.25.246.172]> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 28251-done@debbugs.gnu.org Ludovic Court=C3=A8s writes: > Ricardo Wurmus skribis: > >> * guix/packages.scm (package->code): New procedure. > > We=E2=80=99ll need tests for this. :-) I=E2=80=99ve added some simple tests to tests/print.scm and import-utils.sc= m. > I would move it to (guix import utils) or a new (guix import print) > module or similar (which will also allow us to use =E2=80=98factorize-uri= =E2=80=99). In > my mind, eventually all importers will produce a object > directly, and so this will be a core part of the import machinery. > Since it=E2=80=99s not a crucial component, I would prefer to have it out= of > (guix packages) though. Okay, done. >> +;; FIXME: the quasiquoted arguments field may contain embedded package >> +;; objects, e.g. in #:disallowed-references; they will just be printed = with >> +;; their usual # representation, not as variable names. > > Not sure how to solve that; maybe we can ignore for now. That=E2=80=99s why I originally experimented with overriding the printer. = For the purposes of a JSON importer, however, this really isn=E2=80=99t importa= nt. >> +(define (package->code package) >> + "Return an S-expression representing the source code that produces PA= CKAGE >> +when evaluated." > > Like you wrote, it would be nice to also return a spec of modules in > scope, like: > > ((gnu packages r) > ((guix licenses) #:prefix license:)) > > WDYT? I=E2=80=99ll leave this as a later improvement, but yes: I=E2=80=99ll add t= his at some point. > I think we should compare values with =E2=80=98eq?=E2=80=99 (usually we= =E2=80=99re concerned > with pointer identity of records), and also use =E2=80=98module-for-each= =E2=80=99 + > =E2=80=98let/ec=E2=80=99 to avoid building a list for nothing That=E2=80=99s good! > Nitpick: I=E2=80=99d rename all the =E2=80=98print-*=E2=80=99 procedures = to =E2=80=98*->code=E2=80=99. Done. I=E2=80=99ve implemented the other suggested changes and added some documentation. I=E2=80=99ll push it to master in a few minutes. Thanks for the comments! -- Ricardo GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC https://elephly.net