From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ALNhGLZfIWV+FAEAauVa8A:P1 (envelope-from ) for ; Sat, 07 Oct 2023 15:40:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ALNhGLZfIWV+FAEAauVa8A (envelope-from ) for ; Sat, 07 Oct 2023 15:40:06 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C5E8553308 for ; Sat, 7 Oct 2023 15:40:05 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1696686006; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=oFHuBNhWqpxnM1fHtlcTUFyL0WpbuucdlhVADu8Xi1E=; b=ftS5RtRDlpIV7zpKfQsspA6j4IRfFTHbPg08hDmaL1ra7YVDVJ/gGmIDxsX6qYZkNOYjJx IQaTtha84jZmmsCFyFqzMuSQEe6QUlN5c6isv8eUDYCh4q3mN7pZoAx4A3YvLPKNhA3VS0 KQXCGQ+wRxmI0qPcEG6GVdutchDxAIxUtA7gvLiF/Y0KKf1YswDf4ayx07QwY6OhpAvxUJ 4D/qymRdigE9o1HvJ/gPaQ4nlX4DM9pICTpWzqErqDbzM1C0Tc+/YiL3EWa8+xXHpWS6M+ klDuCv9WUav4A+hpr3iGPuqgw0iUGZR1adV7h476OYyy9R1LRYEf8E9TU5iEzg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696686006; a=rsa-sha256; cv=none; b=ilvKjSSVeHTH8SxyrdjwtmIDZiArEZZpOcxwNAwq20qAe7Ab0Iiyi+4PxPiF4PolN+pJv5 nix0i0kCtAIsKoXAaIHvtbE+Y+0+b4KNWx4ygShskaxP6htKPgShKR6vQKkjkSfiSbnvX8 x7Tz9ZbkbaefXyuz5jEwnHN5J1ausrwnojh7PjY0PX/lVc0cqwxgMrpfn5do4b4T4vUs5w hnCwVjLd9AISLdZfd//rRi2b2C6GL8rVvcelWQ+sQJ2AlgQhua+nMrbQ3X8Nl/qsGsatlk TqWCr6BN1VUt3slQa281jwjo7lPrBrPm35euwvIJn6ADwathMrWHv4C1u7c6YQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qp7X4-0000RZ-EX; Sat, 07 Oct 2023 09:39:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qp7Wx-0000Qc-Cb for guix-patches@gnu.org; Sat, 07 Oct 2023 09:39:43 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qp7Wx-0001Hc-4S for guix-patches@gnu.org; Sat, 07 Oct 2023 09:39:43 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qp7XG-0000Gs-D9 for guix-patches@gnu.org; Sat, 07 Oct 2023 09:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63985] [PATCH v3 02/11] services: configuration: Use transducers within serialize-configuration. (was : bug#63985: [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration) Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 07 Oct 2023 13:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63985 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 63985@debbugs.gnu.org Received: via spool by 63985-submit@debbugs.gnu.org id=B63985.16966859931016 (code B ref 63985); Sat, 07 Oct 2023 13:40:02 +0000 Received: (at 63985) by debbugs.gnu.org; 7 Oct 2023 13:39:53 +0000 Received: from localhost ([127.0.0.1]:53562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp7X7-0000GI-Bd for submit@debbugs.gnu.org; Sat, 07 Oct 2023 09:39:53 -0400 Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:53216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp7X4-0000G9-AY for 63985@debbugs.gnu.org; Sat, 07 Oct 2023 09:39:51 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 38DAF20D51; Sat, 7 Oct 2023 15:39:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 7376680095; Sat, 7 Oct 2023 15:39:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jKHR79AZy66O; Sat, 7 Oct 2023 15:39:21 +0200 (CEST) Received: from [192.168.1.116] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id A7D338005B; Sat, 7 Oct 2023 15:39:21 +0200 (CEST) Message-ID: <32c0bfc7-c8ec-4470-a557-57046f817f07@makinata.eu> Date: Sat, 7 Oct 2023 14:39:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US References: <871qed3pi3.fsf_-_@gmail.com> From: Bruno Victal In-Reply-To: <871qed3pi3.fsf_-_@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.18 X-Spam-Score: -6.18 X-Migadu-Queue-Id: C5E8553308 X-Migadu-Scanner: mx2.migadu.com X-TUID: 3hU05zTvl2jy On 2023-10-02 18:25, Maxim Cournoyer wrote: > Bruno Victal writes: >> diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm >> index 23ccb8d403..56b7772f58 100644 >> --- a/gnu/services/telephony.scm >> +++ b/gnu/services/telephony.scm >> @@ -204,22 +205,20 @@ (define (jami-account->alist jami-account-object) >> ('rendezvous-point? "Account.rendezVous") >> ('peer-discovery? "Account.peerDiscovery") >> ('bootstrap-hostnames "Account.hostname") >> - ('name-server-uri "RingNS.uri") >> - (_ #f))) >> + ('name-server-uri "RingNS.uri"))) >> >> - (filter-map (lambda (field) >> - (and-let* ((name (field-name->account-detail >> + (define jami-account-transducer >> + (compose (tremove empty-serializer?) >> + (tfilter-maybe-value jami-account-object) >> + (tmap (lambda (field) >> + (let* ((name (field-name->account-detail >> (configuration-field-name field))) >> - (value ((configuration-field-serializer field) >> - name ((configuration-field-getter field) >> - jami-account-object))) >> - ;; The define-maybe default serializer produces an >> - ;; empty string for unspecified values. >> - (value* (if (string-null? value) >> - #f >> - value))) >> - (cons name value*))) >> - jami-account-fields)) >> + (value ((configuration-field-serializer field) >> + name ((configuration-field-getter field) >> + jami-account-object)))) >> + (cons name value)))))) >> + >> + (list-transduce jami-account-transducer rcons jami-account-fields)) > > Could you please state in a comment under "(define > jami-account-transducer" why the base transducer doesn't suffice? It > isn't obvious to me from a casual inspection. I guess it's because > base-transducer is not recursive? Should it be? This is because you're changing the field names of the JAMI-ACCOUNT record type through `field-name->account-detail'. Conventional serializers are (serializer (field-name value)) procedures and this is how `base-transducer' calls them. Here you want to do something of the sort (serializer (translate-field-name name) value) so a custom transducer was written to account for this detour. I wonder if we could simply this with some functional programming as discussed in [1] instead. >> (test-equal "symbol maybe value serialization, unspecified" >> "" >> - (gexp->approximate-sexp >> + (eval-gexp >> (serialize-configuration (config-with-maybe-symbol) >> config-with-maybe-symbol-fields))) > > That's nice, though I don't understand why gexp->approximate needs to be > turned into eval-gexp? Using `gexp->approximate-sexp' alone doesn't result in a evaluation of the serialization process so eval-gexp has to be used in order to actually perform this test. [1]: Message-ID: <673081be-14c1-4864-9bd1-1cbc908823a6@makinata.eu> Link: -- Furthermore, I consider that nonfree software must be eradicated. Cheers, Bruno.