From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IHeyOB7/xWN9NgAAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 02:51:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QIHtNx7/xWNkFwAAG6o9tA (envelope-from ) for ; Tue, 17 Jan 2023 02:51:26 +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 30FA03F004 for ; Tue, 17 Jan 2023 02:51:02 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHb7Y-0000u8-Ju; Mon, 16 Jan 2023 20:50:40 -0500 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 1pHb7X-0000tv-Mg for guix-devel@gnu.org; Mon, 16 Jan 2023 20:50:39 -0500 Received: from mx1.riseup.net ([198.252.153.129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHb7V-0004im-UI for guix-devel@gnu.org; Mon, 16 Jan 2023 20:50:39 -0500 Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4NwsKX48YXzDqjV for ; Tue, 17 Jan 2023 01:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1673920235; bh=SbuuqegIrfnKiL0xLpXbD0aTv5WbLH/ggClmq/QpAEA=; h=From:To:Subject:Date:From; b=WKzwdlx4Fcpu8WVGNwKpKHWt0GIxHdav0JtlC5fIfI9E4vc17H/JG2E805CSsHsJT BrEJJ8IIxorCzrWKzjzigA1ycMfTEjy5Rw51IS/f2lbLc/nqrQI7ke8C3pnGfBw53f a+rkWHSRubA05uvpMIK4dm9Z639pyghanZSlGTas= X-Riseup-User-ID: B603D021E1CE15C5F2D8553A9373EFBB0DD6352A2EE0EDFC5D426A84EDCB8FC3 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4NwsKW66Fjz5vY8 for ; Tue, 17 Jan 2023 01:50:23 +0000 (UTC) From: Csepp To: guix-devel Subject: threading macro instead of modify* macros Date: Tue, 17 Jan 2023 01:22:17 +0000 Message-ID: <868ri22alp.fsf@riseup.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=198.252.153.129; envelope-from=raingloom@riseup.net; helo=mx1.riseup.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=riseup.net header.s=squak header.b=WKzwdlx4; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=riseup.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673920263; a=rsa-sha256; cv=none; b=HRYx7AMPdZBs4JLvk8fgCn/n3ixklbc2RSpP4Anor4NQy6Xl6u71UW7w/0/NeJaskbtB7g WwNOaw/1AeprMhE/X7Ut9Ghiqbh3fMmksjYgvfg0IA4tPdyPDsqW6DGKuL3TmV1plSe9Cj 5Pv2zNVfyQc1z5azcHGhU7nPIM2ofEqbcyVPOxxm/hnhdX/SOsLEzmuJiXrHOn5m0FKroG tj7rG4VPTt4gk6mKllKffIobzALV0rGFaZqrw3SOzEUALrsvAqpiPm+kEtBS1+kq6/qMMG d80hi2YkQtGIup0Z2ICtLfUd62dyha+xjKZjzDkHD9TPhhEsiNzpaljPAmsM9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673920263; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VuBL3cXbrjAkVPzWbiy77SPgBtwq7inOwHNTHsP0+6Q=; b=UEzu9d/zjfwC0Q3CQT3NH8/DNLurHl03gBKzv00bSui2joTGFtxAaPiAnozMCEbu1NG1Q/ 5neYNfACg04VyKXaaSplVcL2EqhgvJWcqDDRqHqNM7Vpl4Hovr8NjPqySqN4rEyX+x8hXA IER6oNTWStO1VJ3zXkt+Dkm51eU+b+QYLALHE/WWYqyPLIijrE2b8x1HSWM9/d4DbgR1w0 KlzUCHyAn6OVJaarzXGhCR8wrKDgq3sOrlkYszebjHbHrZRdhNs4CqyEi2a8oHDhgGn3a2 pomJp6sEs4N6OYYNlFxHYxfpLcN/hV/HC5Jd/rE/tpEOX2H+6q3Ss7ZcboZwnw== X-Migadu-Queue-Id: 30FA03F004 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=riseup.net header.s=squak header.b=WKzwdlx4; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=riseup.net X-Migadu-Spam-Score: -9.95 X-Spam-Score: -9.95 X-TUID: kYkLaHfdNuIT Here is what I'm trying to do: I have a package that inherits from the ocaml package. Because of Various Reasons (tm) I am using substitute-keyword-arguments and modify-phases and I need to duplicate the shebang patching phase after multiple phases. What I wanted to do was write a helper function like: (duplicate-after 'conf-2 'patch-sh 'patch-sh-again) Then I realized I'd have to patch modify-phases to add this to its grammar. Then came the realizations that in Haskell this would instead be a composition of curried applications, that's the thing that the cut macro emulates in Scheme. So, (modify-phases foo (add-after 'a 'b f) (delete 'c)) is really: ``` (compose (cut add-after <> 'a 'b f) (cut delete <> 'c)) ``` And from having used Fennel a bit I know that it copied a very nice syntactic feature from Clojure, called the threading macros, which implements this exact idiom without having to write cut everywhere. Guix currently has at least a few modify-whatever and substitute-whatever macros that all hardcode a few operations. Couldn't they be made much cleaner and more general by using a solid library of data manipulation functions and threading macros? The phases list could be treated like the actual data type it is, an ordered key-value mapping. ps.: On that note, Guile has generics, why doesn't any code use it? When I have to write things like string