From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: hackage importer Date: Tue, 09 Jun 2015 09:38:05 +0200 Message-ID: <87vbex49ia.fsf@gnu.org> References: <87k2yiqqaw.fsf@gnu.org> <871tkbdhwc.fsf@gnu.org> <871tk7ykfj.fsf@gnu.org> <87zj6t9tq5.fsf@gnu.org> <87pp6j6t85.fsf@gnu.org> <87sia6pq6y.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:4830:134:3::10]:36378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2E6u-0006Gw-3Y for guix-devel@gnu.org; Tue, 09 Jun 2015 03:38:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2E6p-0003Qm-W0 for guix-devel@gnu.org; Tue, 09 Jun 2015 03:38:12 -0400 In-Reply-To: (Federico Beffa's message of "Fri, 5 Jun 2015 17:19:34 +0200") 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.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Federico Beffa Cc: Guix-devel Federico Beffa skribis: > On Fri, Jun 5, 2015 at 9:30 AM, Ludovic Court=C3=A8s wrote: [...] >>> +(define (make-stack) >>> + "Creates a simple stack closure. Actions on the generated stack are >>> +requested by calling it with one of the following symbols as the first >>> +argument: 'empty?, 'push!, 'top, 'pop! and 'clear!. The action 'push!= is the >>> +only one requiring a second argument corresponding to the object to be= added >>> +to the stack." >>> + (let ((stack '())) >>> + (lambda (msg . args) >>> + (cond ((eqv? msg 'empty?) (null? stack)) >>> + ((eqv? msg 'push!) (set! stack (cons (first args) stack))) >>> + ((eqv? msg 'top) (if (null? stack) '() (first stack))) >>> + ((eqv? msg 'pop!) (match stack >>> + ((e r ...) (set! stack (cdr stack)) e) >>> + (_ #f))) >>> + ((eqv? msg 'clear!) (set! stack '())) >>> + (else #f))))) >> >> Fair enough. :-) I wonder what happens exactly when trying to return >> monadic values in the parser. > > Given that the parser repeatedly calls the tunk generated by > 'make-lexer' without passing any state or knowing anything about to > which monad it may belong to, I thought that it would not work. But, > as you see, I'm new to Scheme, new to monads, and new to Lisp in > general. I think the rules can return any kind of value, so there shouldn=E2=80=99t = be a problem with returning monadic values (of course it won=E2=80=99t bind them= for you, but that=E2=80=99s not a problem.) Anyway, an exercise for later. ;-) >>> +;; Stack to track the structure of nested blocks >>> +(define context-stack (make-stack)) >> >> What about making it either a SRFI-39 parameter, or a parameter to >> =E2=80=98make-cabal-parser=E2=80=99? > > I made it a parameter. Thanks for suggesting it! It made me realize > what they are really used for :-) > Do you think it is correct to say that they serve the purpose of > special variables in Lisp? (I'm looking a little bit into Common Lisp > as well.) Not sure what you mean by =E2=80=9Cspecial variables=E2=80=9D (and I=E2=80= =99m not familiar with CL), but the concept is fairly common: It=E2=80=99s dynamic scoping, which = is the default in elisp, sometimes called =E2=80=9Cfluids=E2=80=9D, sometimes = =E2=80=9Cparameters.=E2=80=9D > From 8a28ed0f3c3077ce12d4924c59e317c52a68a77e Mon Sep 17 00:00:00 2001 > From: Federico Beffa > Date: Sun, 26 Apr 2015 11:22:29 +0200 > Subject: [PATCH] import: hackage: Refactor parsing code and add new optio= ns. > > * guix/import/cabal.scm: New file. > * guix/import/hackage.scm: Update to use the new Cabal parsing module. > * tests/hackage.scm: Update tests. > * guix/scripts/import/hackage.scm: Add new '--cabal-environment' and '--s= tdin' > options. > * doc/guix.texi: ... and document them. > * Makefile.am (MODULES): Add 'guix/import/cabal.scm', > 'guix/import/hackage.scm' and 'guix/scripts/import/hackage.scm'. > (SCM_TESTS): Add 'tests/hackage.scm'. OK to commit, thank you! (I had not realized the hackage.scm files were missing from the Makefile until now.) Thanks, Ludo=E2=80=99. PS: Commit 751630c adds n-ary >>=3D for your pleasure. ;-)