unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
To: guile-user@gnu.org
Subject: Re: Lenses in Guile?
Date: Tue, 18 Feb 2020 15:04:10 +0100	[thread overview]
Message-ID: <87eeusng9x.fsf@gmail.com> (raw)
In-Reply-To: <e712767a-7ef5-1f94-f82d-94eec6a9cf32@posteo.de>

Heya,

Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> 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 <ludo@gnu.org> wrote:
>>
>>> Hi!
>>>
>>> Ricardo Wurmus <rekado@elephly.net> 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	other threads:[~2020-02-18 14:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-16 14:56 Happy birthday, Guile! Ludovic Courtès
2020-02-16 16:20 ` Linus Björnstam
2020-02-16 18:36 ` Arun Isaac
2020-02-16 21:08   ` sirgazil
2020-02-16 19:14 ` Roel Janssen
2020-02-16 19:30   ` Ricardo Wurmus
2020-02-17  9:16     ` Ludovic Courtès
2020-02-18 13:38       ` Christopher Lam
2020-02-18 13:44         ` Lenses in Guile? Zelphir Kaltstahl
2020-02-18 14:04           ` Alex Sassmannshausen [this message]
2020-02-19 14:27             ` Zelphir Kaltstahl
2020-02-23 17:00             ` Ludovic Courtès
2020-02-16 21:13 ` Happy birthday, Guile! Mike Gran
2020-02-16 21:34   ` sirgazil
2020-02-16 21:54 ` Ricardo Wurmus
2020-02-16 22:14 ` Jeremy Korwin-Zmijowski
2020-02-16 23:51 ` potluck; " Arne Babenhauserheide
2020-02-17  0:10 ` Happy birthday, Guile! - grid printing Zelphir Kaltstahl
2020-02-17  8:01   ` Linus Björnstam
2020-02-17 14:58     ` Zelphir Kaltstahl
2020-02-17 16:21       ` Linus Björnstam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eeusng9x.fsf@gmail.com \
    --to=alex.sassmannshausen@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).