guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#30657] [PATCH] services: messaging: Prosody config supports file-li


From: Ludovic Courtès
Subject: [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects.
Date: Sat, 03 Mar 2018 15:37:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hello,

Clément Lassieur <address@hidden> 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’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]