From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id eKtfGAT7ZmcVbwAAe85BDQ:P1 (envelope-from ) for ; Sat, 21 Dec 2024 17:29:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id eKtfGAT7ZmcVbwAAe85BDQ (envelope-from ) for ; Sat, 21 Dec 2024 18:29:40 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=ZXrEkrz8; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=DH+pAVrZ; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734802180; h=from:from:sender:sender:reply-to: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:dkim-signature; bh=XBnWVgPt+dXrwelp+ecr17pGs1zoO5nRvpNKyO4JC0o=; b=Epr+EcwcpY2lLcuZbSkRZyZtuXlYHx5wgqaxW6+cdABJrJvyx8yx2BJJgvVXI1NBVsLQYJ cFTLJyeAa3kaQV4uokALysbqsLjWFf10rbvA/8jIx9WnwoeaQUE0R34AkOzgyhBjSCkoGp 7r4rjtCpj9dwC2BUOQKtYojTY71jirOpHivYPlXU/uUv76MqSP0mHANs/NcWKFpYYkFD2U RE+eYqzTdKvH4ZeQLLitlTLkO2uMYgTz6Tq1kgivpO9lwKo9VBzfB9oxi5ZwWzwDzTDGLx odAV5Lw1EODLOIixsJNODrmuw91hO9ecs35guQ5QE+kINPYuSZNIEhhgv/n27g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=ZXrEkrz8; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=DH+pAVrZ; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734802180; a=rsa-sha256; cv=none; b=Et79p/F/4KNH5QZelczL1ZZFZHQrnb8WRjlUspYYSM1zwfgUvn+ifRg/dd3Puvb6COn4xn Lu6B+8dX9TFROdYOq6mVDr7PIGnXJE8er2QpveVch17yo9cCqCVWgxHHi4RJTQHKRzEqm4 7jNXc/uAkhNkSmuOfyGJ295Sz7GUjGqK02X3EkxwX1B6Ou4i1AeFcjj3vJVtW5U3PLK7p2 E5L2Cvj+tP6AQv7g4pQXuithdfBUSTM0ffq7AcIOV+qfSl1Fm/Gno21+3fQ2Q57SWoE03s WOmHSrbJHsaf6ipMi62jtdFNudZCAwdfWlc4XLIczfTmtxH4CvgbmwED3LraHA== 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 11B6C82B68 for ; Sat, 21 Dec 2024 18:29:40 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tP2vZ-0005Rh-8H; Sat, 21 Dec 2024 12:06:09 -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 1tP2vY-0005RT-Lf for guix-patches@gnu.org; Sat, 21 Dec 2024 12:06:08 -0500 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 1tP2vY-0003QQ-1D; Sat, 21 Dec 2024 12:06:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=XBnWVgPt+dXrwelp+ecr17pGs1zoO5nRvpNKyO4JC0o=; b=ZXrEkrz8xfHLNHWt8zgKfO6azqMQNnK16zt5o93VTZ0u807NAwc6k9BvnFt/a21lwUjgBZs0pFw+NpIY37LSIyDkufqkJg5/f6NxKx2IB/dGx50H79qYHxG4JefSFzcjVuPkMKbOZPV9tjepucg+HJnTBPiYh/FBV9kNWnb0EjnXuA3gqPE+j/UOX/JfiEvP6zenW3X5DRY5P+gnLWEgwLQp6TcwENXWIIfA+h+QRTjxD7OSXn75PZ9SgMkUYiNnqGr5KLcgr2wsowvYxHFM1lhQNdXGgDAfyn9F2YxSsPpdqK+1RoIEYEsSze0zjCMQyhSVeweyvI6rNYptOVnUqg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tP2vS-0005Qz-Ir; Sat, 21 Dec 2024 12:06:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75010] [PATCH 1/7] monads: Add 'mmatch'. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 21 Dec 2024 17:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75010 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75010@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 75010-submit@debbugs.gnu.org id=B75010.173480070920659 (code B ref 75010); Sat, 21 Dec 2024 17:06:02 +0000 Received: (at 75010) by debbugs.gnu.org; 21 Dec 2024 17:05:09 +0000 Received: from localhost ([127.0.0.1]:47509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP2ua-0005Mj-MS for submit@debbugs.gnu.org; Sat, 21 Dec 2024 12:05:09 -0500 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:38121 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP2uY-0005I2-Bd for 75010@debbugs.gnu.org; Sat, 21 Dec 2024 12:05:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1734800696; h=from:from: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; bh=XBnWVgPt+dXrwelp+ecr17pGs1zoO5nRvpNKyO4JC0o=; b=DH+pAVrZ7HAbYWtDndS5FRIBPhlzp4nq1BrN5dF1r2SNXjqRarAWh5aL+JZJ7MIgeDcYgS lSGTnIst7QBmb1RG1Lb1gXBcCnhngUTRKQ7p3PMczg28QOXEI5ysYzmJp8//39cps4CSbH cE2Zet2ONQW6chpTElZ73HTv1A566ymHteGmred+/a/iDgRL9LFs6DzSxAzumeeeBnWfBw hFimLDdtOjSRh9TQ6n+NZbAd7t4DoOKouqnBKj74U+SYlbA6pAUn3U0u7BNlm7Gy2gnn/Q TL8AxRJwCfu1aV8fb2arF3eTfs6zMJGaPJapWe+diaIE8SOQXtjptIfOiNL3pg== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id 32d18722 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for <75010@debbugs.gnu.org>; Sat, 21 Dec 2024 17:04:56 +0000 (UTC) Date: Sat, 21 Dec 2024 18:04:05 +0100 Message-ID: <4bfa279cae2316d7a7a4e0640d13a0763ad86f92.1734798943.git.herman@rimm.ee> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches From: Herman Rimm via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 11B6C82B68 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -2.01 X-Spam-Score: -2.01 X-TUID: fJuaNb7vvdyC * doc/guix.texi (The Store Monad): Document mmatch. * guix/monads.scm (mmatch): Add macro. Change-Id: I558f8e025f6cf788c9fc475e99d49690d7a98f41 --- doc/guix.texi | 6 ++++++ guix/monads.scm | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index f7b7569887..c86f644360 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11814,6 +11814,12 @@ The Store Monad (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). @end defmac +@defmac mmatch monad mexp (pattern body) @dots{} +Match monadic object @var{mexp} against clause @var{pattern}s, in the +order in which they appear. The last expression of each clause +@var{body} must be a monadic expression. +@end defmac + @defmac mbegin monad mexp @dots{} Bind @var{mexp} and the following monadic expressions in sequence, returning the result of the last expression. Every expression in the diff --git a/guix/monads.scm b/guix/monads.scm index 0bd8ac9315..0e8ca868ce 100644 --- a/guix/monads.scm +++ b/guix/monads.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2017, 2022 Ludovic Courtès +;;; Copyright © 2024 Herman Rimm ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ (define-module (guix monads) with-monad mlet mlet* + mmatch mbegin mwhen munless @@ -355,6 +357,15 @@ (define-syntax mlet (let ((var temp) ...) body ...))))))) +(define-syntax mmatch + (syntax-rules () + "Match the monadic object MEXP against the patterns of CLAUSES ... +in the order in which they appear. The last expression of each clause +body must be a monadic expression." + ((_ monad mexp clauses ...) + (with-monad monad + (>>= mexp (match-lambda clauses ...)))))) + (define-syntax mbegin (syntax-rules (%current-monad) "Bind MEXP and the following monadic expressions in sequence, returning -- 2.45.2