Alex Kost <alez...@gmail.com> skribis:

> Ludovic Courtès (2016-01-23 20:08 +0300) wrote:
>
>> Alex Kost <alez...@gmail.com> skribis:
>>
>>> * guix/licenses.scm (%licenses): New variable.
>>
>> For the purposes of this patch set, I think we’d rather avoid that, and
>> instead do something like:
>>
>>     (module-map (lambda (sym var)
>>                   (variable-ref var))
>>                 (resolve-interface '(guix licenses)))
>>
>> WDYT?
>
> Oh, great, I didn't know about 'module-map', thanks!  But since there
> are also things like 'license?' or 'license-uri' in this module, we need
> to ignore objects which are not licenses.  Would it be ok to do it like
> this:
>
>   (hash-fold (lambda (sym var res)
>                (let ((object (variable-ref var)))
>                  (if (license? object)
>                      (cons object res)
>                      res)))
>              '()
>              (module-obarray (resolve-interface '(guix licenses))))
>
> or is there a more idiomatic way?

Good point.  I’d rather write it as:

  (filter license? (module-map …))

(‘module-obarray’ is an implementation detail that may not be here
forever.)

Ludo’.

Reply via email to