From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: use-modules in gexps Date: Wed, 05 Feb 2020 16:18:12 +0100 Message-ID: <87d0atqczv.fsf@elephly.net> References: <87r1zcspip.fsf@elephly.net> <87tv45nmkk.fsf@gnu.org> 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]:39317) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izMRl-0008Vu-Vh for guix-devel@gnu.org; Wed, 05 Feb 2020 10:18:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izMRj-0005ei-Vh for guix-devel@gnu.org; Wed, 05 Feb 2020 10:18:33 -0500 In-reply-to: <87tv45nmkk.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane-mx.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: Guix-devel Ludovic Court=C3=A8s writes: >> I wondered if perhaps we could add a G-expression compiler for module >> imports, so that instead of >> >> (with-imported-modules (source-module-closure '((my module))) >> #~(begin >> (use-modules (my module)) >> =E2=80=A6)) >> >> we would do >> >> #~(begin >> #$(use-modules (my module)) >> =E2=80=A6) >> >> which would have the effect of adding (my module) =E2=80=94 or the module >> closure =E2=80=93 to the list of modules needed by the current G-express= ion. > > I think the syntax should be different because #$/ungexp has a different > meaning. However, that would leave open the question of how to select > the subset of the module=E2=80=99s closure you want to import, etc. > >> Can a G-expression compiler help accumulate state (e.g. by making >> G-expressions values in the state monad) or can it only be compiled down >> to a value at the current location? > > The latter. What state would you want to accumulate? When I wrote =E2=80=9Cstate=E2=80=9D I had the list of modules encountered = in mind, so that it would be possible to collect all marked instances of =E2=80=9Cuse-module=E2=80=9D and hoist them to the top, in effect doing aut= omatically what is achieved manually by using =E2=80=9Cwith-imported-modules=E2=80=9D = with a list of modules. -- Ricardo