Subject: Re: [bug#76485] [PATCH v2] gexp: ‘with-parameters’ properly handles‘%graft?’.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 04 Mar 2025 23:09:09 +0100

Hello,

David Elsing <[email-masked]> skribis:

> Fixes <https://issues.guix.gnu.org/75879>.
>
> * .dir-locals.el (scheme-mode): Remove mparameterize indentation rules.
> Add state-parameterize and store-parameterize indentation rules.
> * etc/manifests/system-tests.scm (test-for-current-guix): Replace
> mparameterize with store-parameterize.
> * etc/manifests/time-travel.scm (guix-instance-compiler): Likewise.
> * gnu/tests.scm (compile-system-test): Likewise.
> * guix/gexp.scm (compile-parameterized): Use state-call-with-parameters.
> * guix/monads.scm (mparameterize): Remove macro.
> (state-call-with-parameters): New procedure.
> (state-parameterize): New macro.
> * guix/store.scm (store-parameterize): New macro.
> * tests/gexp.scm ("with-parameters for %graft?"): New test.
> * tests/monads.scm ("mparameterize"): Remove test.
> ("state-parameterize"): New test.
>
> Co-authored-by: Ludovic Courtès <[email-masked]>

Applied with the change below, in accordance with the deprecation
policy.

Thank you!

Ludo’.

PS: Let me know if I got the copyright line wrong.

diff --git a/guix/monads.scm b/guix/monads.scm
index 0df82bb4653..e1b056dc95f 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 <[email-masked]>
+;;; Copyright © 2013-2015, 2017, 2022, 2025 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2025 David Elsing <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix monads)
   #:use-module ((system syntax)
                 #:select (syntax-local-binding))
+  #:autoload   (guix deprecation) (warn-about-deprecation)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
@@ -58,7 +60,8 @@ (define-module (guix monads)
             state-push
             state-pop
             run-with-state
-            state-parameterize))
+            state-parameterize
+            mparameterize))
 
 ;;; Commentary:
 ;;;
@@ -618,4 +621,15 @@ (define-syntax state-parameterize
            (lambda ()
              (mbegin %state-monad body ...))))))))
 
+(define-syntax mparameterize                  ;can be removed after 2026-03-05
+  (lambda (s)
+    "This is the old form for 'state-parameterize', which pretended to work
+with any monad but was in fact specialized for '%state-monad'."
+    (syntax-case s ()
+      ((_ monad bindings body ...)
+       (begin
+         (warn-about-deprecation 'mparameterize (current-source-location)
+                                 #:replacement 'state-parameterize)
+         #'(state-parameterize bindings body ...))))))
+
 ;;; monads.scm end here