From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id +BOUI1FtIWXgAgEA9RJhRA:P1 (envelope-from ) for ; Sat, 07 Oct 2023 16:38:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id +BOUI1FtIWXgAgEA9RJhRA (envelope-from ) for ; Sat, 07 Oct 2023 16:38:09 +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 59C4A45889 for ; Sat, 7 Oct 2023 16:38:09 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Lqdtt28G; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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=1696689489; 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: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: dkim-signature; bh=N3qnoxe85rctbwxSMXr3HLbBbMIgOx3MeQwhRaXx58M=; b=V3eciu6c6+F74OpOKfJiQ6xyk+VhNO/sQCKjWR1nhUc8kDXfH8FbwuOEhd/1qxoiv9Vp3F bdPw9CskfdJxpRdtyby+A9R3UymZpPLdZLVCeCLemDIDzDip9oFiO+IucElVHJZdvqTQwX 0Kcj7nrbANabRSjXwpk/VgKt1zZ89lOMMB5hrcAXJCrXn5O/PffaL0EnrDlol2oMrqOVWb ktQsNXe0o2bnn0xnsjGxk28KpR+VCOmbcy+MhY009gtIYbg6glWfcDL1avX/wtsFYXigmo yVn8cPWuzCip6eIHZvX1cN11przpHlV1XXjQXOQID4i7SezWm5EueePrOj6bmQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696689489; a=rsa-sha256; cv=none; b=XI4ypEgM6PX5wW0VvG3Ki26j4aHl5aemlYNwI9eWID4DZeqA0z07Z86OrZIXc03/RP53wg P6SCN8YegDCPG3gDW78fV2yqnNeVftvK2ChFUEHeaTU2eNKIISV1FtP1vSVHlGvfSx2JQX ERWb3W/og+ZdGkQUEt3sSaIYGvkNZ/LL4EQUiYMkX2KXj5hXMwyY7RmiU2xUscOy9XZZyW heu/uBRMPXcnZc3gtrNqEdeHjVk6sxV7vEEqaHx3dsLbFnHCZLf0QGh3LNZbdPdPMOOzQJ gCc2E9W0mA7yNEnYuTZNu1IlsfVLPpNEzp4tboufDdfZrp4Gh3xk6RJj8vvQZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Lqdtt28G; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qp8R6-0006vw-Lu; Sat, 07 Oct 2023 10:37:44 -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 1qp8R5-0006vm-6X for guix-patches@gnu.org; Sat, 07 Oct 2023 10:37: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 1qp8R4-0003uF-UY for guix-patches@gnu.org; Sat, 07 Oct 2023 10:37:42 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qp8RO-0005PU-1G for guix-patches@gnu.org; Sat, 07 Oct 2023 10:38: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: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 07 Oct 2023 14:38: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: Bruno Victal Cc: 63985@debbugs.gnu.org Received: via spool by 63985-submit@debbugs.gnu.org id=B63985.169668945420749 (code B ref 63985); Sat, 07 Oct 2023 14:38:02 +0000 Received: (at 63985) by debbugs.gnu.org; 7 Oct 2023 14:37:34 +0000 Received: from localhost ([127.0.0.1]:55614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp8Qv-0005Oa-Fd for submit@debbugs.gnu.org; Sat, 07 Oct 2023 10:37:33 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]:44398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp8Qt-0005OL-KR for 63985@debbugs.gnu.org; Sat, 07 Oct 2023 10:37:32 -0400 Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-65afba4cfadso17560006d6.1 for <63985@debbugs.gnu.org>; Sat, 07 Oct 2023 07:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696689426; x=1697294226; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=N3qnoxe85rctbwxSMXr3HLbBbMIgOx3MeQwhRaXx58M=; b=Lqdtt28GBU5cH/5QUr0LLMGJktKKRqdPwFXtoIP6b7c5RRFzPS1ErnTnhRZ7T4YPAS e7xyXykwW5pxH8Mg0Z+gHsE0RiM+RKwCOg/27J8eb7IaT5wCCyz59IBK5RluwTl2yR1I MEzrxOBZ6tnSpW4/JgAa5ISY+cb9DMXX4VrJzLoYZHp3Fl/Ep7uvw5ezClU+4OxUue8Q yjXh541jTluBunMDGoM+y4e35KYE7fBdGgQaZ5EEhTLh1c/6RcxyruQA+D0909tgxcZa xCj81FywZd7f4n+nB+kOVoLZVA3mFscIzmy4Y+pwqyz5n5UOdBu6hysTzltM8JlkT0fY dp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696689426; x=1697294226; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=N3qnoxe85rctbwxSMXr3HLbBbMIgOx3MeQwhRaXx58M=; b=Ix+Z5XHYhFNmFiye5MyCTSoVdblCM82PlQNb6cFoEJXyH3NwMz/74EVAR4BuY/tqeA EtNVPifBjUTNdPnUo39Y/HA3TSA/X86wy7mS1EOXK/Ts3uSFFoXQcIGjQLbZseRqXTak vibWpuPCO9kanvNJE63bnY/D4GK5j6KkhfmfnuID0Ojs8rTCDENIH4b/BEBNq7Wxg0uQ sVXOukINvuzimrgc7Gv+sif4v/WYebOf6xB8vnnYYuvKcTtJQeFRxKQqkjF+Y+jzxKCS w6pdhlC0391IkAYfMdImwUaJRNxC3GbslIYpE6zLzHEja3WWuOIEN282FSnyCFxIQ96C Vmpg== X-Gm-Message-State: AOJu0YyAF8gLpekoslzeS1JRuDvpahaHOVGfk1wlw/7ntSMTThs/vLht fqghDB2pVpXw2OkwO1s7sj0v+4ZVlPc= X-Google-Smtp-Source: AGHT+IEn0A98PXxi6aHT3Qhh0p80W2AOi1Dl/qEDc1hYoGVdfwSwHdeLMGrlEQ4IGFnHi15BSOgTmg== X-Received: by 2002:a05:6214:1912:b0:656:27a9:8063 with SMTP id er18-20020a056214191200b0065627a98063mr10529806qvb.33.1696689426276; Sat, 07 Oct 2023 07:37:06 -0700 (PDT) Received: from hurd (dsl-158-21.b2b2c.ca. [66.158.158.21]) by smtp.gmail.com with ESMTPSA id w17-20020a0cdf91000000b0063d162a8b8bsm2261727qvl.19.2023.10.07.07.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 07:37:05 -0700 (PDT) From: Maxim Cournoyer In-Reply-To: <32c0bfc7-c8ec-4470-a557-57046f817f07@makinata.eu> (Bruno Victal's message of "Sat, 7 Oct 2023 14:39:17 +0100") References: <871qed3pi3.fsf_-_@gmail.com> <32c0bfc7-c8ec-4470-a557-57046f817f07@makinata.eu> Date: Sat, 07 Oct 2023 10:37:04 -0400 Message-ID: <8734ymjy7j.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -5.12 X-Spam-Score: -5.12 X-Migadu-Queue-Id: 59C4A45889 X-TUID: BMO3jetRu2pq Hello, Bruno Victal writes: > 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. Great, thanks for the explanations! -- Thanks, Maxim