guile-user
[Top][All Lists]
Advanced

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

Re: Lenses in Guile?


From: Zelphir Kaltstahl
Subject: Re: Lenses in Guile?
Date: Wed, 19 Feb 2020 15:27:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Icedove/60.9.0

Hi Alex!

Thanks for that!

On 18.02.20 15:04, Alex Sassmannshausen wrote:
> Heya,
>
> Zelphir Kaltstahl <address@hidden> writes:
>
>> Hi!
>>
>> This reminds me of something: Is there something like
>> https://docs.racket-lang.org/lens/index.html for Guile? Or perhaps an
>> easy to understand tutorial on implementing it?
> Check out https://gitlab.com/a-sassmannshausen/guile-lens
>
> It's an implementation I did for fun a while ago.  Can't remember how
> faithfully it implements lenses as compared with racket's…
>
> Best wishes,
>
> Alex
>
>> Regards,
>> Zelphir
>>
>> On 2/18/20 2:38 PM, Christopher Lam wrote:
>>> A bit late, and perhaps not as sophisticated as some bigger modules here.
>>>
>>> Two functions defined as follows: nested-alist-set! nested-alist-get at
>>> https://github.com/Gnucash/gnucash/blob/1f83cfaf64d1cd3c8862b427dd043154f780a772/gnucash/report/html-chart.scm#L37
>>>
>>> Consider a nested alist describing unix file system
>>> (define lst
>>>  (list
>>>   (cons 'usr (list
>>>               (cons 'bin "binary files")
>>>               (cons 'games "g4m3s")
>>>               (cons 'include (list
>>>                               (cons 'guile (list
>>>                                             (cons '2.2 "old")))
>>>                               (cons 'linux "da best")))))))
>>>
>>> We can access a leaf node via (nested-alist-get lst '(usr include linux))
>>> --> "da best", and set a leaf node via (nested-alist-set! lst '(usr include
>>> python) "boo"). This is probably easy to seasoned schemers, but still a
>>> nice pair of functions to use in modifying nested alists before conversion
>>> into json.
>>>
>>> On Mon, 17 Feb 2020 at 09:16, Ludovic Courtès <address@hidden> wrote:
>>>
>>>> Hi!
>>>>
>>>> Ricardo Wurmus <address@hidden> skribis:
>>>>
>>>>> What do you think about adding these things to
>>>>> https://notabug.org/cwebber/guile-webutils/ ?  This was once intended to
>>>>> be a collection of useful tools that come in handy when writing web
>>>>> applications.
>>>> I didn’t know about guile-webutils but consolidating Web tools in this
>>>> package sounds like a great idea!
>>>>
>>>> Ludo’.
>>>>
>>>>
>



reply via email to

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