From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id YAmlCvPt82FZyQAAgWs5BA (envelope-from ) for ; Fri, 28 Jan 2022 14:21:55 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id KHXsB/Pt82E3twAA9RJhRA (envelope-from ) for ; Fri, 28 Jan 2022 14:21:55 +0100 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 BB7693D5E9 for ; Fri, 28 Jan 2022 14:21:50 +0100 (CET) Received: from localhost ([::1]:52256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDRCH-0007B0-Dh for larch@yhetil.org; Fri, 28 Jan 2022 08:21:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDR3s-0003YL-AI for help-guix@gnu.org; Fri, 28 Jan 2022 08:13:08 -0500 Received: from smtprelay06.ispgateway.de ([80.67.31.103]:52316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDR3o-0008Pz-K4 for help-guix@gnu.org; Fri, 28 Jan 2022 08:13:07 -0500 Received: from [92.195.33.239] (helo=milk) by smtprelay06.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nDR3E-0006hE-SQ; Fri, 28 Jan 2022 14:12:29 +0100 From: Simon Streit To: help-guix@gnu.org Subject: Is the example about the serialiser in the manual correct? Was: Help on writing config serialiser References: Gcc: nnfolder+archive:sent.2022-01 Date: Fri, 28 Jan 2022 14:13:01 +0100 In-Reply-To: (Simon Streit's message of "Mon, 24 Jan 2022 17:13:09 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Df-Sender: bGlzdHNAbmV0cGFuaWMub3Jn Received-SPF: none client-ip=80.67.31.103; envelope-from=simon@netpanic.org; helo=smtprelay06.ispgateway.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643376110; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bELNkzgf0GipVTgf+SDFo3Rw8e6kWNmseCNjwucehBU=; b=Q0SamI9NKHNxVL1XuRgF174RZ6sY4L5mDZRJBc0PonEl7+F1v9sGwU3FhEXkOjStHi7Uwe C9YlsWpwtwmXe/SbgNtfPbAQCnaxFFQlLR+yZcLhTv8WySm5DjsUPbhwMM6CTJ+2ViYSmS CYVrqSQrQEhUwhCTE545VAGb+kuG1raYLdHLisD2y5B2rKHDr5jDf/ua+e0tLj6tg+wg17 jiaj3xNfWxNqsHKrTs97HidSsNqPJejBb/d+tU6S2+C3y5GaZ5fpa0dcZE/rUYlHkfnUWQ 2RI9bc1ZmSimPp1iQRlSGollMzNugChhkB5dX5/5jApt5V/6tP4tSp8uMeMT4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643376110; a=rsa-sha256; cv=none; b=LZPWvHKTv1O2yPE1ewaLuv1a1cxZU/HVXT4HVYxxuP1hNtjBpf+zkUHeYMAOl3c+wwJ36o PTZ2G3MptkMubR5uG/MQOq3M2fx+Ic/oP5lUQW4+5D0W8MRsCJCS+CCsu38JddB4rcIFzr TTNyykeVhJ2Od04Y2XryQ24nKlxi47jVhOo/D7aHxMYGckxNolRqlh2bnRetFeHimNjxTy JuSJjaOIgmULhrsfrzIeCxhI5m+JBYNrz6WpEHpC1ZiReDciWzMWObnMsRPNNGlBpz1KpB /ZftTzd44pwI79vYBhmtTNLnfJTxgoZEYAw5Z+xZGQ6o/p7wUVECwkCv/elk7g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: BB7693D5E9 X-Spam-Score: -3.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: BB+elwmHQfRr Hello, I gave up, and thought of starting from scratch. But my initial attempt failed right from the beginning. I'm not so sure now if the example provided in the manual is usable in its current state. The following is a (slightly) unedited copy from the manual: --8<---------------cut here---------------start------------->8--- (use-modules (gnu services) (guix gexp) (gnu services configuration) (srfi srfi-26) (srfi srfi-1)) ;; Turn field names, which are Scheme symbols into strings (define (uglify-field-name field-name) (let ((str (symbol->string field-name))) ;; field? -> is-field (if (string-suffix? "?" str) (string-append "is-" (string-drop-right str 1)) str))) (define (serialize-string field-name value) #~(string-append #$(uglify-field-name field-name) " =3D " #$value "\n")) (define (serialize-integer field-name value) (serialize-string field-name (number->string value))) (define (serialize-boolean field-name value) (serialize-string field-name (if value "true" "false"))) (define (serialize-contact-name field-name value) #~(string-append "\n[" #$value "]\n")) (define (list-of-contact-configurations? lst) (every contact-configuration? lst)) (define (serialize-list-of-contact-configurations field-name value) #~(string-append #$@(map (cut serialize-configuration <> contact-configuration-fields) value))) (define (serialize-contacts-list-configuration configuration) (mixed-text-file "contactrc" #~(string-append "[Owner]\n" #$(serialize-configuration configuration contacts-list-configuration-fields)))) (define-maybe integer) (define-maybe string) (define-configuration contact-configuration (name (string) "The name of the contact." serialize-contact-name) (phone-number (maybe-integer 'disabled) "The person's phone number.") (email (maybe-string 'disabled) "The person's email address.") (married? (boolean) "Whether the person is married.")) (define-configuration contacts-list-configuration (name (string) "The name of the owner of this contact list.") (email (string) "The owner's email address.") (contacts (list-of-contact-configurations '()) "A list of @code{contact-configuation} records which contain information about all your contacts.")) ;; A contacts list configuration could then be created like this: (define my-contacts (contacts-list-configuration (name "Alice") (email "alice@example.org") (contacts (list (contact-configuration (name "Bob") (phone-number 1234) (email "bob@gnu.org") (married? #f)) (contact-configuration (name "Charlie") (phone-number 0000) (married? #t)))))) --8<---------------cut here---------------end--------------->8--- Evaluating it with will result: --8<---------------cut here---------------start------------->8--- ~ $ guile example.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/ss2/example.scm ;;; compiled /home/ss2/.cache/guile/ccache/3.0-LE-8-4.5/home/ss2/example.sc= m.go Backtrace: In ice-9/boot-9.scm: 1752:10 9 (with-exception-handler _ _ #:unwind? _ # _) In unknown file: 8 (apply-smob/0 #) In ice-9/boot-9.scm: 724:2 7 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 6 (_ #(#(#))) In ice-9/boot-9.scm: 2835:4 5 (save-module-excursion _) 4380:12 4 (_) In /home/ss2/example.scm: 75:2 3 (_) In srfi/srfi-1.scm: 634:9 2 (for-each # =E2=80=A6) In gnu/services/configuration.scm: 121:24 1 (_ #< name: contacts type: list-of=E2=80= =A6>) In srfi/srfi-1.scm: 241:2 0 (every _ _ . _) srfi/srfi-1.scm:241:2: In procedure every: In procedure every: Wrong type argument: # --8<---------------cut here---------------end--------------->8--- Maybe something is wrong?=20 Kind regards Simon