guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outreachy - Guix Data Service: questions about improving the data fo


From: Christopher Baines
Subject: Re: Outreachy - Guix Data Service: questions about improving the data for derivation comparisons.
Date: Mon, 26 Apr 2021 22:21:50 +0100
User-agent: mu4e 1.4.15; emacs 27.1

Luciana Lima Brito <lubrito@posteo.net> writes:

> On Mon, 26 Apr 2021 09:15:37 +0100
> Christopher Baines <mail@cbaines.net> wrote:
>
>> So, one advantage of alists over lists is that the code is probably
>> less brittle when adding elements say, since code parsing the list
>> will probably break with a new element, but this is probably less
>> likely to happen with an alist.
>>
>> However, this will happen with an alist if match is used to pick
>> elements out. I'd suggest using assq-ref or similar to pluck elements
>> out.
>
> Ok, I changed that on the html.scm.

Great :)

Rather than writing:

  (match-lambda
    ((alist ...)

I'd just use

  (lambda (alist)

as I think that's equivalent right?

>> I'd consider these options first probably:
>>
>>  - Could the data coming from derivation-differences-data have vectors
>>    where appropriate already? The HTML code would probably need to be
>>    adjusted, but I think that's fine.
>
> I tried this for days but with no success. Maybe the only way would be
> to tweak group-to-alist, but it touches many places, and I didn't want
> to mess with it.

Maybe add another procedure that combines group-to-alist but generates
an alist with vectors as the values? (group-to-alist/vector maybe).

>>  - Could this be written in a form like:
>>
>>    ,@(map (lambda (name)
>>            ...)
>>           '(outputs inputs sources arguments))
>
> This only make sense to me inside render-json (because of the ,@), but I
> think the code would be less clean and "arguments" would appear in a
> different order. What I did was bind the result of a function similar
> to this in the let.

I think using let is OK, but I think just unpacking data-groups as
you've called it directly in to the alist is fine (so ,@data-groups),
rather than picking out the elements. JSON objects are unordered, so the
ordering isn't something that really matters.

If you do go down this route though, I'd probably add a comment saying
what things are being added to the outer most alist, just to make the
code quicker to read.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]