aboutsummaryrefslogtreecommitdiff
path: root/tests/monads.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-06-08 22:49:50 +0200
committerLudovic Courtès <ludo@gnu.org>2015-06-08 23:00:49 +0200
commit751630c9c3f7f3e87dfccc5f5ba8cf61cdd6f8fd (patch)
tree2da2fcf7e6e300c98f2777e0bcb5670252ff4803 /tests/monads.scm
parentae9b96c7846cc7d4528da5c6d861d6440cf46e33 (diff)
downloadguix-751630c9c3f7f3e87dfccc5f5ba8cf61cdd6f8fd.tar
guix-751630c9c3f7f3e87dfccc5f5ba8cf61cdd6f8fd.tar.gz
monads: Allow n-ary '>>=' expressions.
Suggested by Federico Beffa <beffa@fbengineering.ch>. * guix/monads.scm (bind-syntax): New macro. (with-monad): Use it instead of 'identifier-syntax'. * tests/monads.scm (">>= with more than two arguments"): New test. * doc/guix.texi (The Store Monad): Explain that there can be several MPROC. Add an example.
Diffstat (limited to 'tests/monads.scm')
-rw-r--r--tests/monads.scm13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/monads.scm b/tests/monads.scm
index 5529a6188a..d3ef065f24 100644
--- a/tests/monads.scm
+++ b/tests/monads.scm
@@ -103,6 +103,19 @@
%monads
%monad-run))
+(test-assert ">>= with more than two arguments"
+ (every (lambda (monad run)
+ (let ((1+ (lift1 1+ monad))
+ (2* (lift1 (cut * 2 <>) monad)))
+ (with-monad monad
+ (let ((number (random 777)))
+ (= (run (>>= (return number)
+ 1+ 1+ 1+
+ 2* 2* 2*))
+ (* 8 (+ number 3)))))))
+ %monads
+ %monad-run))
+
(test-assert "mbegin"
(every (lambda (monad run)
(with-monad monad