1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-27 19:41:50 +02:00

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.
This commit is contained in:
Ludovic Courtès
2015-06-08 22:49:50 +02:00
parent ae9b96c784
commit 751630c9c3
3 changed files with 56 additions and 7 deletions
+13
View File
@@ -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