unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: Andrew Tropin <andrew@trop.in>
Cc: ludo@gnu.org, 71111@debbugs.gnu.org
Subject: [bug#71111] [PATCH 0/1] services: home: Use pairs instead of lists.
Date: Wed, 22 May 2024 17:33:57 -0400	[thread overview]
Message-ID: <87cypdwmyi.fsf@freakingpenguin.com> (raw)
In-Reply-To: <cover.1716372146.git.andrew@trop.in> (Andrew Tropin's message of "Wed, 22 May 2024 14:02:26 +0400")

Andrew Tropin <andrew@trop.in> writes:

> After rewriting from car/cdr to match-lambda in v2 of this patch:
> https://yhetil.org/guix-patches/3394b0b51f6a5a608ebcfb7a63fdc34e52fe928e.1711046203.git.richard@freakingpenguin.com/
>
> the format changed from pairs to lists, I didn't noticed this nuance
> during review because the documentation still says that service should
> be configured and extended with pairs.  Also, pairs are more
> apropriate data type here.  And this match-lambda rewrite will break
> downstream RDE user's setups after migrating to upstreamed version of
> service.
>
> That's why I propose to go back to pairs.
>

I'm not opposed to going back to cons cell pairs. I didn't put too much
thought in a "list of two elements" vs. "cons cell" besides the match
statement being easier to handle with a list.

Would this patch have unintended side effects? I thought the . in match
conditions had a different behavior.

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (match '(1 2 3 4)
                       ((a . b) b))
$5 = (2 3 4)
scheme@(guile-user)> (match '(1 2)
                       ((a . b) b))
$6 = (2)
scheme@(guile-user)> (match '(1 . 2)
                       ((a . b) b))
$7 = 2
--8<---------------cut here---------------end--------------->8---

So changing to this would allow for a home-service entry like the
following to match:

--8<---------------cut here---------------start------------->8---
(simple-service 'my-extra-home home-service-type
                `(("bob" "bill" "bertha" "billyanne" ,my-extra-home ,my-home-2)))
--8<---------------cut here---------------end--------------->8---

From my testing, this /will/ error (yay), but not as soon as the match
would with the current code. Instead of being caught before being passed
to the daemon, it seems to be caught while lowering the invalid
file-append object.

Personally I would prefer to catch as many errors as possible before
beginning to pass code off to the daemon where possible. Generally
speaking it feels like pre-daemon errors are easier to mentally parse.

In fairness, the current code also isn't trying particularly hard to
check that "user" is a string and "he" is a home-environment or printing
a fancy error message.

Perhaps this would work?

--8<---------------cut here---------------start------------->8---
(define-module (gnu services guix)
  ...
  #:use-module (gnu home))
...
(define (guix-home-shepherd-service config)
  (map (match-lambda
         (((? string? user) . (? home-environment? he))
          (shepherd-service
           ...
           ))
         (e (error "Invalid value for guix-home-shepherd-service: " e)))
       config))
--8<---------------cut here---------------end--------------->8---

Maybe I'm just being silly. 🙂

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.




  parent reply	other threads:[~2024-05-22 21:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 10:02 [bug#71111] [PATCH 0/1] services: home: Use pairs instead of lists Andrew Tropin via Guix-patches via
2024-05-22 10:02 ` [bug#71112] [PATCH 1/1] " Andrew Tropin via Guix-patches via
2024-05-22 11:06 ` [bug#71111] " Andrew Tropin via Guix-patches via
2024-05-22 21:33 ` Richard Sent [this message]
2024-05-23  5:45   ` [bug#71111] [PATCH 0/1] " Andrew Tropin via Guix-patches via
2024-05-23  3:38 ` Zheng Junjie
2024-05-23  5:43   ` Andrew Tropin via Guix-patches via
2024-05-23 16:02     ` Maxim Cournoyer
2024-05-23  5:53 ` [bug#71111] [PATCH v2 " Andrew Tropin via Guix-patches via
2024-05-23  5:53 ` [bug#71111] [PATCH v2 1/1] " Andrew Tropin via Guix-patches via
2024-05-23  9:16   ` Ludovic Courtès
2024-05-23 13:06     ` Andrew Tropin via Guix-patches via
2024-06-02  9:50 ` [bug#71111] [PATCH 0/1] " Andrew Tropin via Guix-patches via
2024-06-02 10:15   ` Ludovic Courtès
2024-06-02 10:37     ` Efraim Flashner
2024-06-02 11:12       ` Andrew Tropin via Guix-patches via
2024-06-02 10:57     ` Andrew Tropin via Guix-patches via

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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87cypdwmyi.fsf@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=71111@debbugs.gnu.org \
    --cc=andrew@trop.in \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).