guile-user
[Top][All Lists]
Advanced

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

Re: Guix records


From: Olivier Dion
Subject: Re: Guix records
Date: Tue, 09 Feb 2021 19:28:32 -0500

On Tue, 09 Feb 2021, Aleix Conchillo Flaqué <aconchillo@gmail.com> wrote:
> Hi Olivier,
>
> Unfortunately I don't have an answer, and actually I didn't even know this
> existed, but I'd love to see a library for it. I added something similar
> (in terms of syntax) to guile-json (define-json-type) and I'm happy to see
> that it seems I was not doing something very stupid. For this specific
> record it would be something like:
>
> (define-json-type <employee>
>   (age)
>   (name)
>   (profession))
>
> Which will define a constructor and getters (no setters). However, to
> create a new record you have to use the constructor (which is not very
> convenient) or use an alist and then use (scm->employee). But it would be
> great if one could do:

Is (scm->employee) something (define-json-type) offers?  Just having
that would be great.  I would be more tolerant to have guile-json as a
dependency, since it's most likely lighter than Guix, probably already
installed on the user system and it might me useful for users that are
allergic to parentheses for configuration.

>
> (employee->json
>    (employee
>       (age  30)
>       (name "Foo")
>       (profession "Teacher")))
>
> instead of:
>
> (employee->json
>    (scm->employee
>       '((age . 30)
>         (name . "Foo")
>         (profession . "Teacher"))))
>
> It would be fantastic to combine (guix records) and guile-json somehow, but
> I'm not sure how.

If guile-json' license is compatible with Guix' license, I don't see any
problem with taking the code from Guix and adapting it for guile-json.

>
> Sorry I couldn't provide any useful insight.
>
> Best,
>
> Aleix
>
> On Fri, Feb 5, 2021 at 9:24 AM Olivier Dion via General Guile related
> discussions <guile-user@gnu.org> wrote:
>
>> Hello,
>>
>> In the module (guix records), there's some very nice syntax rule
>> `define-record-type*` that allows very powerfull declarative style of
>> records.  For example:
>> ----------------------------------------------------------------------
>> (employee
>>   (age  30)
>>   (name "Foo")
>>   (profession "Teacher"))
>> ----------------------------------------------------------------------
>>
>> I would like to use this feature in my software.  However, I don't want
>> to have Guix as a dependency only for that.  For now, I've copied the
>> content of (guix records) into (my-software records).  But this put
>> burden of maitenance into my hands.
>>
>> Thus, I'm looking for an alternative, perhaps there's a Guile library
>> (other than Guix' module) or a SRFI that offers similar feature?
>>
>> --
>> Olivier Dion
>> PolyMtl
>>
>>
-- 
Olivier Dion
PolyMtl



reply via email to

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