1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-28 03:51:53 +02:00

monads: Add 'mbegin'.

* guix/monads.scm (mbegin): New macro.
* tests/monads.scm ("mbegin"): New test.
* doc/guix.texi (The Store Monad): Document it.
This commit is contained in:
Ludovic Courtès
2014-10-08 23:35:08 +02:00
parent 2e1bafb034
commit 405a9d4ec9
4 changed files with 40 additions and 1 deletions
+16 -1
View File
@@ -32,7 +32,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-64))
;; Test the (guix store) module.
;; Test the (guix monads) module.
(define %store
(open-connection-for-tests))
@@ -99,6 +99,21 @@
%monads
%monad-run))
(test-assert "mbegin"
(every (lambda (monad run)
(with-monad monad
(let* ((been-there? #f)
(number (mbegin monad
(return 1)
(begin
(set! been-there? #t)
(return 2))
(return 3))))
(and (= (run number) 3)
been-there?))))
%monads
%monad-run))
(test-assert "mlet* + text-file + package-file"
(run-with-store %store
(mlet* %store-monad ((guile (package-file %bootstrap-guile "bin/guile"))