From 19077c72c92c8e417421cc7a0ec64ef8495fb2b6 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Wed, 27 Apr 2022 23:44:14 -0400 Subject: [PATCH] FIX don't eval either twice in bind --- local/lib/either/either.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/local/lib/either/either.el b/local/lib/either/either.el index eebb72d..7ba6e2d 100644 --- a/local/lib/either/either.el +++ b/local/lib/either/either.el @@ -39,10 +39,12 @@ left/right slot." (defmacro either>>= (either form) "Bind EITHER to FORM where the right slot is bound to 'it'." (declare (indent 1)) - `(pcase ,either - (`(:left ,_) ,either) - (`(:right ,it) ,form) - (e (error "Learn to use monads, dummy; this isn't one: %s" e)))) + (let ((e (make-symbol "--either"))) + `(let ((,e ,either)) + (pcase ,e + (`(:left ,_) ,e) + (`(:right ,it) ,form) + (e (error "Learn to use monads, dummy; this isn't one: %s" e)))))) (defun either-foldM (fun init xs) "Mondically apply FUN to XS (a list).