unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: "Clément Lassieur" <clement@lassieur.org>
Cc: 30657@debbugs.gnu.org
Subject: [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects.
Date: Sat, 03 Mar 2018 15:37:49 +0100	[thread overview]
Message-ID: <87bmg5b4xu.fsf@gnu.org> (raw)
In-Reply-To: <20180303013308.12929-1-clement@lassieur.org> ("Clément Lassieur"'s message of "Sat, 3 Mar 2018 02:33:08 +0100")

Hello,

Clément Lassieur <clement@lassieur.org> skribis:

> * doc/guix.texi (Messaging Services): Update accordingly.
> * gnu/services/configuration.scm (serialize-configuration,
> serialize-maybe-stem, serialize-package): Return strings or string-valued
> gexps (these procedures were only used for their side-effects).
> (file-like?): New exported procedure.
> * gnu/services/messaging.scm (serialize-field, serialize-field-list,
> enclose-quotes, serialize-raw-content, serialize-ssl-configuration,
> serialize-virtualhost-configuration-list,
> serialize-int-component-configuration-list,
> serialize-ext-component-configuration-list,
> serialize-virtualhost-configuration, serialize-int-component-configuration,
> serialize-ext-component-configuration, serialize-prosody-configuration):
> Return strings or string-valued gexps and stop printing.
> (prosody-activation): Use SERIALIZE-PROSODY-CONFIGURATION's return value with
> MIXED-TEXT-FILE instead of using its output with PLAIN-FILE.
> (serialize-non-negative-integer, serialize-non-negative-integer-list): Convert
> numbers to strings.
> (file-object?, serialize-file-object, file-object-list?,
> serialize-file-object-list): New procedures.
> (ssl-configuration)[capath, cafile], (prosody-configuration)[plugin-paths,
> groups-file]: Replace FILE-NAME with FILE-OBJECT.

[...]

> +  #~(string-append
> +     #$@(map (lambda (field)
> +               ((configuration-field-serializer field)
> +                (configuration-field-name field)
> +                ((configuration-field-getter field) config)))
> +             fields)))

Awesome, I find it clearer.  :-)

> +(define (file-like? val)
> +  (and (struct? val) ((@@ (guix gexp) lookup-compiler) val)))

I’m not fond of the idea of using @@ in real code.  :-)

Could you move ‘file-like?’ to (guix gexp), with a docstring, and with
‘->bool’ to avoid exposing internal details:

  (define (file-like? value)
    (and (struct? value) (->bool (lookup-compiler value))))

?

> +(define (file-object? val)
> +  (or (file-like? val) (file-name? val)))

Do we need this predicate?  After all, all we can say is that a file
name is necessarily a string (or a string-valued gexp), but a string is
not necessarily a file name (IOW there’s no disjoint type for file
names.)

I suppose the configuration mechanism needs it though, right?  In that
context it’s probably OK.

Apart from this the patch LGTM, thank you!

Ludo’.

  parent reply	other threads:[~2018-03-03 14:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 22:25 [bug#30657] Add support for file-like objects to the Prosody configuration Clément Lassieur
2018-02-28 22:28 ` [bug#30657] [PATCH 1/4] services: utils: Add 'push-tokens' and 'with-tokens-to-list' Clément Lassieur
2018-02-28 22:28   ` [bug#30657] [PATCH 2/4] gexp: Add 'file-like?' Clément Lassieur
2018-03-02 16:51     ` Ludovic Courtès
2018-03-03  1:44       ` Clément Lassieur
2018-03-03 14:38         ` Ludovic Courtès
2018-02-28 22:28   ` [bug#30657] [PATCH 3/4] services: utils: move 'flatten' from (gnu services web) Clément Lassieur
2018-02-28 22:28   ` [bug#30657] [PATCH 4/4] services: messaging: Prosody config supports file-like objects Clément Lassieur
2018-03-02 17:00 ` [bug#30657] Add support for file-like objects to the Prosody configuration Ludovic Courtès
2018-03-03  1:33   ` [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects Clément Lassieur
2018-03-03 11:43     ` Clément Lassieur
2018-03-03 14:27       ` Ludovic Courtès
2018-03-03 14:37     ` Ludovic Courtès [this message]
2018-03-03 17:38       ` bug#30657: " Clément Lassieur
2018-03-03  1:40   ` [bug#30657] Add support for file-like objects to the Prosody configuration Clément Lassieur

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=87bmg5b4xu.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=30657@debbugs.gnu.org \
    --cc=clement@lassieur.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).