From 751630c9c3f7f3e87dfccc5f5ba8cf61cdd6f8fd Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 8 Jun 2015 22:49:50 +0200 Subject: monads: Allow n-ary '>>=' expressions. Suggested by Federico Beffa . * 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. --- tests/monads.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/monads.scm') 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 -- cgit v1.2.3