GNU bug report logs -
#28251
[PATCH 0/3] Add generic JSON importer
Previous Next
Reported by: Ricardo Wurmus <rekado <at> elephly.net>
Date: Sun, 27 Aug 2017 15:59:01 UTC
Severity: normal
Tags: patch
Done: Ricardo Wurmus <rekado <at> elephly.net>
Bug is archived. No further changes may be made.
Full log
Message #34 received at 28251-done <at> debbugs.gnu.org (full text, mbox):
Ludovic Courtès <ludo <at> gnu.org> writes:
> Ricardo Wurmus <rekado <at> elephly.net> skribis:
>
>> * guix/packages.scm (package->code): New procedure.
>
> We’ll need tests for this. :-)
I’ve added some simple tests to tests/print.scm and import-utils.scm.
> I would move it to (guix import utils) or a new (guix import print)
> module or similar (which will also allow us to use ‘factorize-uri’). In
> my mind, eventually all importers will produce a <package> object
> directly, and so this will be a core part of the import machinery.
> Since it’s not a crucial component, I would prefer to have it out of
> (guix packages) though.
Okay, done.
>> +;; FIXME: the quasiquoted arguments field may contain embedded package
>> +;; objects, e.g. in #:disallowed-references; they will just be printed with
>> +;; their usual #<package ...> representation, not as variable names.
>
> Not sure how to solve that; maybe we can ignore for now.
That’s why I originally experimented with overriding the printer. For
the purposes of a JSON importer, however, this really isn’t important.
>> +(define (package->code package)
>> + "Return an S-expression representing the source code that produces PACKAGE
>> +when evaluated."
>
> Like you wrote, it would be nice to also return a spec of modules in
> scope, like:
>
> ((gnu packages r)
> ((guix licenses) #:prefix license:))
>
> WDYT?
I’ll leave this as a later improvement, but yes: I’ll add this at some
point.
> I think we should compare values with ‘eq?’ (usually we’re concerned
> with pointer identity of records), and also use ‘module-for-each’ +
> ‘let/ec’ to avoid building a list for nothing
That’s good!
> Nitpick: I’d rename all the ‘print-*’ procedures to ‘*->code’.
Done.
I’ve implemented the other suggested changes and added some
documentation. I’ll push it to master in a few minutes.
Thanks for the comments!
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
This bug report was last modified 7 years and 298 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.