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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user