unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Attila Lendvai <attila@lendvai.name>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: using srfi-189 in (gnu services configuration)
Date: Mon, 28 Mar 2022 14:35:12 +0000	[thread overview]
Message-ID: <nadc3JKbVU4b88xTdf6SuC36DVRYebOGYM_UswCgCNMCX3I0amhDdQg3jykWz2rWcYlXi6Bml3bqgOkrXh5W5f6rgUMXL1ud6VzFJdC_Dx8=@lendvai.name> (raw)

this is a follow up to: using an SRFI that is not available in Guile

https://lists.gnu.org/archive/html/guix-devel/2022-01/msg00249.html

let me summarize the discussion, and with that my argument why i'd
like to use srfi-189 in the configuration code:

- sometimes we need to be able to unambiguously distinguish whether a
  config field value has been specified by the user or not.

  the reason is that in some situations setting a config value by the
  user is actually an error; e.g. when field A's value is derived from
  field B's value, but only sometimes, depending on the actual value
  of B.

  in the current setup, simply specifying a default value would make
  it impossible to distinguish, because by the time the code of the
  service is executed, the default value is already written into the
  field.

- the current code uses the symbol 'DISABLED as a special field value
  to signify that the field has not been set (i.e. what Nothing would
  mean if we used srfi-189). it is rather confusing, because many
  config fields are boolean fields, where 'DISABLED sounds like a
  valid off value. it is also prone for clashes with user specified
  values.

- the current codebase also uses 'UNDEFINED as yet another special
  marker. once i understood, but unfortunately, i have forgotten what
  for since then... looks like only as a marker in the macro for the
  situation when no default value form has been specified for a
  field's definition.

- using symbols as markers for special values is a bad idea, because
  the user may specify a field type to be SYMBOL?, which wouldn't
  error when the value is 'DISABLED.

- we can't use Guile's *UNSPECIFIED* for this, because the underlying
  record implementation of Guile uses it for pretty much the same
  thing, and it errors whenever this value is encountered in a
  record's field.

- i see only one way to implement this in the current setup that may
  be doable: use DEFINE-RECORD* (already a loss of many features of
  CONFIGURATION), use thunked fields, and squeeze the logic into the
  default thunk of every field separately.

  at least in my case, it would force a rather unnatural shape on the
  code. understanding the code would be only possible if the reader
  has a proper understanding of thunked fields and what is executed
  when -- which is arguably a harder requirement than grasping Maybe
  and Nothing.

- srfi-189's Maybe and Nothing may come useful in other parts of the
  Guix codebase.

the Maybe and Nothing types/abstranctions implement a solution exactly
for this problem: the ability to detect and deal with the/a special
Nothing value.

the first stage of this adventure, namely adding guile-srfi-189 to the
packages, has been merged.

now, the second stage is going to be a non-trivial task for me,
therefore before i venture into incorporating the use srfi-189 into
the configuration codebase, and before we can see what the actual
implementation looks like, i'd like to ask the maintainers to speak up
if either:

 1) they have been convinced that this may actually turn out
    well, or

 2) if they still have strong feelings against this venture, and would
    probably oppose the use of sfri-189, regardless of the qualities
    of the resulting patch.

any feedback is appreciated,

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Learning without thinking is useless. Thinking without learning is dangerous.”
	— Confucius (551–479 BC), 'The Analects'



             reply	other threads:[~2022-03-28 14:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 14:35 Attila Lendvai [this message]
2022-03-28 15:54 ` using srfi-189 in (gnu services configuration) Maxime Devos
2022-03-30 12:32   ` Attila Lendvai

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='nadc3JKbVU4b88xTdf6SuC36DVRYebOGYM_UswCgCNMCX3I0amhDdQg3jykWz2rWcYlXi6Bml3bqgOkrXh5W5f6rgUMXL1ud6VzFJdC_Dx8=@lendvai.name' \
    --to=attila@lendvai.name \
    --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 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).