From: Attila Lendvai <attila@lendvai.name>
To: Maxime Devos <maximedevos@telenet.be>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: using srfi-189 in (gnu services configuration)
Date: Wed, 30 Mar 2022 12:32:06 +0000 [thread overview]
Message-ID: <Zz4vqHO4203ku3Zq7o0QQhEP2IW4DQBSiDHZnfnk4jnTiI697eZ2fHlx-3x8tDJKRk36m-ZGTWPYWjidQlphUsS3FSINN-poXeZnGH3U840=@lendvai.name> (raw)
In-Reply-To: <daf95b84a27412da8308b974af0709d1bd2c0470.camel@telenet.be>
> > - the current code uses the symbol 'DISABLED
>
> It's a bit of a distraction to the discusses issue, but in Guile
> Scheme, symbols are case-sensitive, so (not (eq? 'disabled 'DISABLED)).
to clarify: i'm using uppercase here only to discriminate scheme
symbols from a free-flowing english text. it's common practice in the
CL world, but i've also seen it in the Guix docstrings.
> This does not appear to be true, at least for (srfi srfi-9) records:
>
> the following code can put unspecified in Guile records without any
> errors:
>
> (use-modules (srfi srfi-9))
> (define-record-type <foobar>
> (make-foobar foo) foo? (foo foobar-foo))
> (pk 'foobar (make-foobar unspecified))
> ;;; (foobar #<<foobar> foo: #<unspecified>>)
my apologies for stating something with confidence that is not true!
i have vivid memory of having tried to use *unspecified*, and getting
errors from record accessors, but i cannot reproduce it now. maybe i
did something with UNDEFINED?, but i don't even see now how to get
hold of that value.
anyway, i'll try to patch up (gnu services configuration) to use
*unspecified* instead of 'DISABLED, and i'll report back with the end
result it it's worthy of that.
> Anyway, even if unspecified causes problems, this can be resolved by
> introducing a new constant like unspecified or the symbol 'disabled',
> but without the potential confusion with a symbol. E.g.:
>
> (define-values (unset-configuration-value unset-configuration-value?)
> (let ()
> (define-record-type <unset-configuration-value>
> (make-unset-configuration-value) unset-configuration-value?
> unset-configuration-value?)
> (values (make-unset-configuration-value)
> unset-configuration-value?)))
it's not really relevant now, but this is pretty much what srfi-189
does, but as a documented standard.
> srfi-189 is also an option, but it seems to me that Haskell-style
> Maybe/Just/None that would require lots of wrapping and unwrapping
> which seems a bit tedious to me -- doable and definitely an option, but
> potentially tedious.
i'm afraid about that, too, but i cannot say before i start
implementing it.
and i think the config code will be equally littered with (if
(unspecified? ...) ...) forms, as opposed to (maybe-ref ...) forms
when using srfi-189.
> Additionally, for your Swarm example, would something like the
> following work:
this is an excellent idea! (namely, to capture the settings of various
swarms into instances, and then predefine the two well-known swarms)
i'll implement this first, and only move on to the config stuff
afterwards.
thanks again Maxime,
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“He alone is great and happy who fills his own station of independence, and has neither to command nor to obey.”
— Johann Wolfgang von Goethe (1749–1832), 'With the Iron Hand' (1773), Act I
prev parent reply other threads:[~2022-03-30 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 14:35 using srfi-189 in (gnu services configuration) Attila Lendvai
2022-03-28 15:54 ` Maxime Devos
2022-03-30 12:32 ` Attila Lendvai [this message]
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='Zz4vqHO4203ku3Zq7o0QQhEP2IW4DQBSiDHZnfnk4jnTiI697eZ2fHlx-3x8tDJKRk36m-ZGTWPYWjidQlphUsS3FSINN-poXeZnGH3U840=@lendvai.name' \
--to=attila@lendvai.name \
--cc=guix-devel@gnu.org \
--cc=maximedevos@telenet.be \
/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).