all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 3/7] import cran: description->package: Also return package dependencies.
Date: Mon, 29 Aug 2016 17:20:14 +0200	[thread overview]
Message-ID: <87h9a31u1d.fsf@gnu.org> (raw)
In-Reply-To: <idjfuqj6w4v.fsf@bimsb-sys02.mdc-berlin.net> (Ricardo Wurmus's message of "Fri, 5 Aug 2016 18:03:28 +0200")

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> writes:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:
>>>
>>>> * guix/import/cran.scm (description->package): Return package
>>>>   dependencies in addition to generated package expression.
>>>
>>> What would you think of making it return a SRFI-41 stream of packages
>>> instead?  Or maybe two values: the package asked for, and the stream
>>> containing its dependencies.  That would hide the package lookup
>>> machinery.
>>
>> That’s a very good idea!  I’ll play around with this and submit a new
>> patch.
>
> I’ve been playing with this for a while and although it looks prettier
> to a user it has some disadvantages to use streams here.  The first is
> that it becomes more difficult to avoid duplicate work.  The second is
> that we can no longer easily generate an order of package expressions
> from leaf nodes to the root.
>
> Consider this case where “plotly” should be imported.  The new inputs
> look like this:
>
>  plotly  : (ggplot2 digest)
>  ggplot2 : (digest mass)
>  digest  : ()
>  mass    : ()
>
> The generated stream may look like this:
>
>   (plotly ggplot2 digest mass digest)
>
> This happens because we only know about the next set of inputs upon
> evaluation of the stream elements.  Of course there are ways to fix
> this, but they involve extending or wrapping “cran->guix-package” to
> make sure that we keep track of top-level dependencies as we traverse
> the list of dependencies recursively.
>
> Maybe I’m doing this wrong?
>
>
> I rewrote description->package to essentially do this:
>
>     (stream-cons the-package-expression
>      (stream-concat
>       (let ((unpackaged (unpackaged-dependencies
>                          propagate guix-name)))
>         (stream-map (cran->guix-package name repository)
>                     (list->stream unpackaged)))))
>
> I.e. the first element of the stream is the imported package expression;
> the tail is a concatenation of streams of packages with their
> dependencies just like this one.  Here’s the stream before
> concatenation:
>
>   (plotly (ggplot2 (digest ()) (mass ()))
>           (digest ()))
>
> To render this in the correct order we’d have to turn this tree inside
> out.  Maybe this isn’t so well-suited to a representation as a stream
> after all.  To turn it inside out we have to evaluate the whole tree
> anyway.
>
> What do you think?  Is it worth expressing this as a stream?  If so, do
> you have any recommendations on how to approach this?
>
> Or would it be okay to let “description->package” return two values: a
> package expression and a list of unpackaged package names, which can
> then be processed by a separate procedure?  (That’s what I submitted
> earlier.)

I think you should go ahead with what you proposed if the other option
sounds like a headache.  Sorry for blocking you for this long!

In theory it would be possible to do something like:

  (define (description->package repo meta)
    (stream-cons `(package …)
                 (stream-unfold (lambda (state)
                                  (description->package
                                   repo
                                   (first-dependency state)))
                                (lambda (state)
                                  (done? state))
                                (lambda (state)
                                  (next-dependency state))
                                (make-state propagate (setq)))))

… where the state is roughly a pair containing the list of next
dependencies and the set of already visited dependencies (to avoid
duplicates).

But again, this is probably easier said than done, so no problem with
keeping the initial option.

Thanks!

Ludo’.

  reply	other threads:[~2016-08-29 15:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 15:40 [PATCH] Add recursive CRAN importer Ricardo Wurmus
2016-05-23 15:40 ` [PATCH 1/7] import cran: Remove more invalid characters from package names Ricardo Wurmus
2016-05-30  8:48   ` Ludovic Courtès
2016-06-14 15:02     ` Ricardo Wurmus
2016-05-23 15:40 ` [PATCH 2/7] import cran: Move guix-name to top-level Ricardo Wurmus
2016-05-30  8:49   ` Ludovic Courtès
2016-05-23 15:40 ` [PATCH 3/7] import cran: description->package: Also return package dependencies Ricardo Wurmus
2016-05-30  8:51   ` Ludovic Courtès
2016-06-14 15:49     ` Ricardo Wurmus
2016-08-05 16:03       ` Ricardo Wurmus
2016-08-29 15:20         ` Ludovic Courtès [this message]
2016-08-31 10:39           ` Ricardo Wurmus
2016-09-01 11:50             ` Ludovic Courtès
2016-05-23 15:40 ` [PATCH 4/7] import cran: Ignore default R packages Ricardo Wurmus
2016-05-30  8:52   ` Ludovic Courtès
2016-05-23 15:40 ` [PATCH 5/7] import cran: Add recursive importer Ricardo Wurmus
2016-05-23 15:40 ` [PATCH 6/7] import cran: Add "recursive" option Ricardo Wurmus
2016-05-30  8:55   ` Ludovic Courtès
2016-06-14 15:30     ` Ricardo Wurmus
2016-05-23 15:40 ` [PATCH 7/7] guix import: Print list of expressions Ricardo Wurmus
2016-05-30  8:56   ` Ludovic Courtès

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=87h9a31u1d.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=ricardo.wurmus@mdc-berlin.de \
    /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.