From: ludo@gnu.org (Ludovic Courtès)
To: Federico Beffa <beffa@ieee.org>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: hackage importer
Date: Tue, 09 Jun 2015 09:38:05 +0200 [thread overview]
Message-ID: <87vbex49ia.fsf@gnu.org> (raw)
In-Reply-To: <CAKrPhPOo0zhs+CXxcifP_KsKyGGuQDWs=C=WQ8xpJHcFT1HaGA@mail.gmail.com> (Federico Beffa's message of "Fri, 5 Jun 2015 17:19:34 +0200")
Federico Beffa <beffa@ieee.org> skribis:
> On Fri, Jun 5, 2015 at 9:30 AM, Ludovic Courtès <ludo@gnu.org> 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’t be a
problem with returning monadic values (of course it won’t bind them for
you, but that’s 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
>> ‘make-cabal-parser’?
>
> 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 “special variables” (and I’m not familiar with
CL), but the concept is fairly common: It’s dynamic scoping, which is
the default in elisp, sometimes called “fluids”, sometimes “parameters.”
> From 8a28ed0f3c3077ce12d4924c59e317c52a68a77e Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Sun, 26 Apr 2015 11:22:29 +0200
> Subject: [PATCH] import: hackage: Refactor parsing code and add new options.
>
> * 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 '--stdin'
> 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’.
PS: Commit 751630c adds n-ary >>= for your pleasure. ;-)
next prev parent reply other threads:[~2015-06-09 7:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 17:59 hackage importer Federico Beffa
2015-03-15 14:38 ` Ludovic Courtès
2015-03-15 22:29 ` Federico Beffa
2015-03-22 20:12 ` Federico Beffa
2015-03-26 13:09 ` Ludovic Courtès
2015-03-28 8:53 ` Federico Beffa
2015-03-29 13:58 ` Ludovic Courtès
2015-03-29 16:55 ` Federico Beffa
2015-03-31 13:33 ` Ludovic Courtès
2015-04-03 13:01 ` Federico Beffa
2015-04-05 18:24 ` Ludovic Courtès
2015-04-26 11:38 ` Federico Beffa
2015-05-02 12:48 ` Ludovic Courtès
2015-06-01 15:20 ` Federico Beffa
2015-06-05 7:30 ` Ludovic Courtès
2015-06-05 15:19 ` Federico Beffa
2015-06-09 7:38 ` Ludovic Courtès [this message]
2015-06-09 8:38 ` Federico Beffa
-- strict thread matches above, loose matches on Subject: below --
2015-04-26 11:52 Federico Beffa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbex49ia.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=beffa@ieee.org \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.