summary refs log tree commit diff
path: root/guix/monads.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/monads.scm')
-rw-r--r--guix/monads.scm16
1 files changed, 9 insertions, 7 deletions
diff --git a/guix/monads.scm b/guix/monads.scm
index ec2b7f8b3b..c2c6f1a03d 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -209,13 +209,15 @@ monadic value seeded by INIT."
 
 (define (mapm monad mproc lst)
   "Map MPROC over LST, a list of monadic values in MONAD, and return a monadic
-list."
-  (foldm monad
-         (lambda (item result)
-           (mlet monad ((item (mproc item)))
-             (return (cons item result))))
-         '()
-         (reverse lst)))
+list.  LST items are bound from left to right, so effects in MONAD are known
+to happen in that order."
+  (mlet monad ((result (foldm monad
+                              (lambda (item result)
+                                (mlet monad ((item (mproc item)))
+                                  (return (cons item result))))
+                              '()
+                              lst)))
+    (return (reverse result))))
 
 (define-inlinable (sequence monad lst)
   "Turn the list of monadic values LST into a monadic list of values, by