From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: Edouard Klein <edk@beaver-labs.com>, guix-devel@gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>, "Josselin Poiret" <dev@jpoiret.xyz>
Subject: Re: Syntactic Diabetes (was Re: A friendlier API for operating-system declarations)
Date: Fri, 24 Nov 2023 23:50:49 +0100 [thread overview]
Message-ID: <52c2337b277721108e5e7cdd6ea32e37e3c20628.camel@gmail.com> (raw)
In-Reply-To: <877cm6reum.fsf@rdklein.fr>
Am Freitag, dem 24.11.2023 um 22:43 +0100 schrieb Edouard Klein:
> Dear Guixers,
>
> Here is a quick status update on my proposition to expose composable
> functions to change operating-system declarations.
>
> Thank you all for the feedback you gave me :) It's very nice to not
> be talking in the void.
>
> After Liliana opined that these functions should not put too much
> burden on the maintainers, a position with which I wholeheartedly
> agree, here is what I came up with:
>
> https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/functional-services.scm
>
> (file copied at the end of this email to make the list self-content
> instead of relying on external services)
>
> That's a macro-writing macro called "define-os-macros-for" that, for
> any service (for example nginx), defines five forms. They all
> evaluate to a modified os:
>
> (.nginx os) ;; Add nginx in its default configuration
> (.nginx os toto titi tutu... ) ;; Add nginx, with toto... given as
> arguments to nginx-configuration
> (+nginx os toto titi tutu...) ;; Extend an existing nginx service,
> giving
> toto... as arguments to simple-service
> (~nginx os toto...) ;; Edit an existing nginx service, passing
> toto... as
> arguments to modify-service
> (-nginx os) ;; Removes nginx
>
> You can see all of them used in:
> https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/system.scm?ref_type=heads
>
> e.g. the mkdir-p function is a (+activation ...),
> all web server functions use (+nginx...),
> mumble is (.mumble... ),
> os/git uses (~openssh... ).
>
> I've use (-foo) forms while testing, but not in production. The
> others are currently running in prod on guix-hosting.com and the-
> dam.org.
The naming is a little confusing and imho not clearly helpful. For
example, why (.nginx os) instead of the triple
(service+ OS SERVICE [CONF])
(service- OS SERVICE)
(modify-service OS SERVICE UPDATE)
Of course, you could also define triples (add-SERVICE OS [CONF]),
(remove-SERVICE OS) and (modify-SERVICE OS UPDATE), which would fall in
line with the macro approach, but keep names a little more readable.
(If you want to use your names, you can rename them in #:use-modules).
> -----------------functional-services.scm----------------
> (define-module (beaver functional-services)
> #:use-module (gnu system)
> #:export (*-append))
>
> (define (syntax->string s)
> "Shorthand to convert a piece of syntax to a string"
> (symbol->string (syntax->datum s)))
Or (compose symbol->string syntax->datum).
> (define (*->string s)
> "Convert into a string any symbol-like type we may encounter in a
> macro"
> (cond
> [(string? s) s]
> [(symbol? s) (symbol->string s)]
> [else (syntax->string s)])) ;; assume syntax
There should not be a need to define this. Try to use exact types.
> (define* (*-append #:rest args)
> "Return a symbol which is a concatenation of the given symbol-like
> args"
> (string->symbol (apply string-append (map *->string args))))
As above.
> (define-syntax define-os-macros-for
> ;; This macro, called like e.g. (define-os-macros-for foo) will
> define four
> ;; forms, .foo, +foo, ~foo and -foo
> ;;
> ;; These forms take an operating-system as their first argument,
> and
> ;; evaluate to an operating-system, which allows one to compose
> them
> ;; (e.g. (foo (bar os))).
> (lambda (x)
> (syntax-case x ()
> [(_ foo)
> (with-syntax
> ([dot-foo (datum->syntax x (*-append "." #'foo))]
> [plus-foo (datum->syntax x (*-append "+" #'foo))]
> [tilde-foo (datum->syntax x (*-append "~" #'foo))]
> [minus-foo (datum->syntax x (*-append "-" #'foo))]
> [foo-service-type (datum->syntax x (*-append #'foo "-
> service-type"))]
> [foo-configuration (datum->syntax x (*-append #'foo "-
> configuration"))])
You're repeating datum->syntax here a bit too much for my liking.
This patch is also missing the most important part of beaverlabs to
make this work: the -> threading macro.
Cheers
next prev parent reply other threads:[~2023-11-24 22:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 8:06 A friendlier API for operating-system declarations Edouard Klein
2023-03-23 18:48 ` Josselin Poiret
2023-03-23 20:23 ` Edouard Klein
2023-03-23 21:05 ` Liliana Marie Prikler
2023-04-13 9:42 ` Ludovic Courtès
2023-05-18 14:37 ` Edouard Klein
2023-11-24 21:43 ` Syntactic Diabetes (was Re: A friendlier API for operating-system declarations) Edouard Klein
2023-11-24 22:50 ` Liliana Marie Prikler [this message]
2023-11-25 20:14 ` Attila Lendvai
2023-11-26 5:36 ` Michal Atlas
2023-11-26 16:49 ` Edouard Klein
2023-11-26 18:32 ` Liliana Marie Prikler
2023-11-26 20:46 ` Edouard Klein
2023-11-27 21:09 ` Liliana Marie Prikler
2023-11-29 20:12 ` Attila Lendvai
2023-11-29 23:39 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2023-11-30 11:16 ` Attila Lendvai
2023-12-01 18:18 ` Michal Atlas
2024-02-01 13:29 ` Introducing Guix "Features"! (Was: Syntactic Diabetes) Felix Lechner via Development of GNU Guix and the GNU System distribution.
2024-02-01 19:43 ` Liliana Marie Prikler
2024-02-01 20:30 ` Attila Lendvai
2024-02-01 20:46 ` Liliana Marie Prikler
2024-02-02 20:11 ` Attila Lendvai
2024-02-01 21:02 ` Ricardo Wurmus
2024-02-02 19:36 ` Attila Lendvai
2024-02-02 20:21 ` Vagrant Cascadian
2024-02-02 21:25 ` Attila Lendvai
2024-02-02 0:03 ` Introducing Guix "Features"! Carlo Zancanaro
2024-02-18 15:07 ` Introducing Guix "Features"! (Was: Syntactic Diabetes) Edouard Klein
2023-12-09 10:12 ` Syntactic Diabetes (was Re: A friendlier API for operating-system declarations) Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52c2337b277721108e5e7cdd6ea32e37e3c20628.camel@gmail.com \
--to=liliana.prikler@gmail.com \
--cc=dev@jpoiret.xyz \
--cc=edk@beaver-labs.com \
--cc=guix-devel@gnu.org \
--cc=ludo@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.